1
1
name : " Package Release"
2
- run-name : " Package Release ${{ github.ref_name }}"
2
+ run-name : " Package Release ${{ inputs.version }}"
3
3
4
4
on :
5
- push :
6
- tags :
7
- - " *"
5
+ workflow_call :
6
+ inputs :
7
+ version :
8
+ description : " The version being built"
9
+ type : string
10
+ required : true
11
+ ref :
12
+ description : " The git reference to build"
13
+ type : string
14
+ required : true
8
15
9
16
jobs :
10
17
build-pecl :
@@ -13,25 +20,15 @@ jobs:
13
20
runs-on : " ubuntu-latest"
14
21
permissions :
15
22
id-token : write
23
+ contents : write
16
24
17
25
steps :
18
- - name : " Create temporary app token"
19
- uses : actions/create-github-app-token@v1
20
- id : app-token
26
+ - name : " Generate token and checkout repository"
27
+ uses : mongodb-labs/drivers-github-tools/secure-checkout@v2
21
28
with :
22
- app-id : ${{ vars.APP_ID }}
23
- private-key : ${{ secrets.APP_PRIVATE_KEY }}
24
-
25
- - name : " Store GitHub token in environment"
26
- run : echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV"
27
- shell : bash
28
-
29
- - name : " Checkout"
30
- uses : " actions/checkout@v4"
31
- with :
32
- # Manually specify a ref. When actions/checkout is run for a tag without a ref, it looks up the underlying
33
- # commit and specifically fetches this to the refs/tags/<tag> ref, which denies us access to the tag message
34
- ref : ${{ github.ref }}
29
+ app_id : ${{ vars.APP_ID }}
30
+ private_key : ${{ secrets.APP_PRIVATE_KEY }}
31
+ ref : ${{ inputs.ref }}
35
32
submodules : true
36
33
37
34
- name : " Set up drivers-github-tools"
47
44
version : " 8.3"
48
45
49
46
- name : " Write changelog file for packaging"
50
- run : git tag -l ${{ github.ref_name }} --format='%(contents)' > changelog
47
+ run : |
48
+ gh api \
49
+ --method POST \
50
+ -H "Accept: application/vnd.github+json" \
51
+ -H "X-GitHub-Api-Version: 2022-11-28" \
52
+ /repos/${{ github.repository }}/releases/generate-notes \
53
+ -f "tag_name=${{ inputs.version }}" --jq '.body' > changelog
51
54
52
55
# This will fill in the release notes from the previously generated changelog
53
56
- name : " Build package.xml"
@@ -77,142 +80,24 @@ jobs:
77
80
- name : " Copy signature file"
78
81
run : cp ${RELEASE_ASSETS}/${{ env.PACKAGE_FILE }}.sig .
79
82
80
- - name : " Upload artifacts"
81
- uses : actions/upload-artifact@v4
82
- with :
83
- name : ${{ env.PACKAGE_FILE }}
84
- path : |
85
- ${{ env.PACKAGE_FILE }}
86
- ${{ env.PACKAGE_FILE }}.sig
87
- retention-days : 3
88
-
89
83
- name : " Upload release artifacts"
90
- run : gh release upload ${{ github.ref_name }} ${{ env.PACKAGE_FILE }} ${{ env.PACKAGE_FILE }}.sig
91
- continue-on-error : true
84
+ run : gh release upload ${{ inputs.version }} ${{ env.PACKAGE_FILE }} ${{ env.PACKAGE_FILE }}.sig
92
85
93
86
build-windows :
94
- name : " Create Windows package"
95
- # windows-latest is required to use enableCrossOsArchive with Ubuntu in the
96
- # next step. See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cross-os-cache
97
- runs-on : windows-latest
98
- defaults :
99
- run :
100
- shell : cmd
101
-
87
+ name : " Create Windows packages"
88
+ uses : ./.github/workflows/build-windows-package.yml
89
+ with :
90
+ version : ${{ inputs.version }}
91
+ ref : refs/tags/${{ inputs.version }}
92
+ php : ${{ matrix.php }}
93
+ arch : ${{ matrix.arch }}
94
+ ts : ${{ matrix.ts }}
95
+ upload_release_asset : true
96
+ secrets : inherit
102
97
strategy :
103
98
fail-fast : false
104
99
matrix :
105
100
# Note: keep this in sync with the Windows matrix in windows-tests.yml
106
101
php : [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
107
102
arch : [ x64, x86 ]
108
103
ts : [ ts, nts ]
109
-
110
- steps :
111
- - uses : actions/checkout@v4
112
- with :
113
- submodules : true
114
-
115
- - name : " Build Driver"
116
- id : build-driver
117
- uses : ./.github/actions/windows/build
118
- with :
119
- version : ${{ matrix.php }}
120
- arch : ${{ matrix.arch }}
121
- ts : ${{ matrix.ts }}
122
-
123
- - name : " Copy DLL and PDB files to CWD"
124
- run : |
125
- cp %BUILD_DIR%\php_mongodb.dll .
126
- cp %BUILD_DIR%\php_mongodb.pdb .
127
- env :
128
- BUILD_DIR : ${{ steps.build-driver.outputs.build-dir }}
129
-
130
- - name : " Cache build artifacts for subsequent builds"
131
- uses : actions/cache/save@v4
132
- with :
133
- key : ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
134
- enableCrossOsArchive : true
135
- path : |
136
- php_mongodb.dll
137
- php_mongodb.pdb
138
-
139
- sign-and-publish-windows :
140
- environment : release
141
- name : " Sign and Publish Windows package"
142
- needs : [build-windows]
143
- # ubuntu-latest is required to use enableCrossOsArchive
144
- # See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cross-os-cache
145
- runs-on : " ubuntu-latest"
146
- permissions :
147
- id-token : write
148
-
149
- strategy :
150
- fail-fast : false
151
- matrix :
152
- # Note: keep this in sync with the Windows matrix in windows-tests.yml
153
- php : [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
154
- arch : [ x64, x86 ]
155
- ts : [ ts, nts ]
156
-
157
- steps :
158
- - name : " Create temporary app token"
159
- uses : actions/create-github-app-token@v1
160
- id : app-token
161
- with :
162
- app-id : ${{ vars.APP_ID }}
163
- private-key : ${{ secrets.APP_PRIVATE_KEY }}
164
-
165
- - name : " Store GitHub token in environment"
166
- run : echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV"
167
- shell : bash
168
-
169
- - uses : actions/checkout@v4
170
-
171
- - name : " Set up drivers-github-tools"
172
- uses : mongodb-labs/drivers-github-tools/setup@v2
173
- with :
174
- aws_role_arn : ${{ secrets.AWS_ROLE_ARN }}
175
- aws_region_name : ${{ vars.AWS_REGION_NAME }}
176
- aws_secret_id : ${{ secrets.AWS_SECRET_ID }}
177
-
178
- - name : Restore cached build artifacts
179
- id : cache-build-artifacts
180
- uses : actions/cache/restore@v4
181
- with :
182
- fail-on-cache-miss : true
183
- key : ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
184
- enableCrossOsArchive : true
185
- path : |
186
- php_mongodb.dll
187
- php_mongodb.pdb
188
-
189
- - name : " Create detached DLL signature"
190
- uses : mongodb-labs/drivers-github-tools/gpg-sign@v2
191
- with :
192
- filenames : php_mongodb.dll
193
-
194
- # Copy the signature file from the release asset directory to avoid directory issues in the ZIP file
195
- - name : " Copy signature file"
196
- run : cp ${RELEASE_ASSETS}/php_mongodb.dll.sig .
197
-
198
- - name : " Upload DLL and PDB files as build artifacts"
199
- uses : actions/upload-artifact@v4
200
- with :
201
- name : php_mongodb-${{ github.ref_name }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
202
- path : |
203
- php_mongodb.dll
204
- php_mongodb.dll.sig
205
- php_mongodb.pdb
206
- CREDITS
207
- CONTRIBUTING.md
208
- LICENSE
209
- README.md
210
- THIRD_PARTY_NOTICES
211
- retention-days : 3
212
-
213
- - name : " Create and upload release artifact"
214
- run : |
215
- ARCHIVE=php_mongodb-${{ github.ref_name }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}.zip
216
- zip ${ARCHIVE} php_mongodb.dll php_mongodb.dll.sig php_mongodb.pdb CREDITS CONTRIBUTING.md LICENSE README.md THIRD_PARTY_NOTICES
217
- gh release upload ${{ github.ref_name }} ${ARCHIVE}
218
- continue-on-error : true
0 commit comments