Skip to content

Commit c5668a8

Browse files
authoredJun 4, 2024
PHPC-2391: Update drivers tools to v2 (#1573)
* Use v2 of drivers-github-tools and the corresponding release app * Copy signature file to correct directory
1 parent 6335128 commit c5668a8

File tree

2 files changed

+79
-37
lines changed

2 files changed

+79
-37
lines changed
 

‎.github/workflows/package-release.yml

+53-14
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,24 @@ on:
88

99
jobs:
1010
build-pecl:
11+
environment: release
1112
name: "Create PECL package"
1213
runs-on: "ubuntu-latest"
14+
permissions:
15+
id-token: write
1316

1417
steps:
18+
- name: "Create temporary app token"
19+
uses: actions/create-github-app-token@v1
20+
id: app-token
21+
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+
1529
- name: "Checkout"
1630
uses: "actions/checkout@v4"
1731
with:
@@ -20,6 +34,13 @@ jobs:
2034
ref: ${{ github.ref }}
2135
submodules: true
2236

37+
- name: "Set up drivers-github-tools"
38+
uses: mongodb-labs/drivers-github-tools/setup@v2
39+
with:
40+
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
41+
aws_region_name: ${{ vars.AWS_REGION_NAME }}
42+
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
43+
2344
- name: "Build Driver"
2445
uses: ./.github/actions/linux/build
2546
with:
@@ -44,17 +65,18 @@ jobs:
4465
echo "PACKAGE_FILE=mongodb-${PACKAGE_VERSION}.tgz" >> "$GITHUB_ENV"
4566
4667
- name: "Create detached signature for PECL package"
47-
uses: mongodb-labs/drivers-github-tools/garasign/gpg-sign@v1
68+
uses: mongodb-labs/drivers-github-tools/gpg-sign@v2
4869
with:
4970
filenames: ${{ env.PACKAGE_FILE }}
50-
garasign_username: ${{ secrets.GRS_CONFIG_USER1_USERNAME }}
51-
garasign_password: ${{ secrets.GRS_CONFIG_USER1_PASSWORD }}
52-
artifactory_username: ${{ secrets.ARTIFACTORY_USER }}
53-
artifactory_password: ${{ secrets.ARTIFACTORY_PASSWORD }}
5471

5572
- name: "Install release archive to verify correctness"
5673
run: sudo pecl install ${{ env.PACKAGE_FILE }}
5774

75+
# Copy the signature file from the release asset directory to avoid directory issues in the ZIP file
76+
# This can be removed once we're no longer uploading build artifacts
77+
- name: "Copy signature file"
78+
run: cp ${RELEASE_ASSETS}/${{ env.PACKAGE_FILE }}.sig .
79+
5880
- name: "Upload artifacts"
5981
uses: actions/upload-artifact@v4
6082
with:
@@ -67,8 +89,6 @@ jobs:
6789
- name: "Upload release artifacts"
6890
run: gh release upload ${{ github.ref_name }} ${{ env.PACKAGE_FILE }} ${{ env.PACKAGE_FILE }}.sig
6991
continue-on-error: true
70-
env:
71-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7292

7393
build-windows:
7494
name: "Create Windows package"
@@ -117,11 +137,14 @@ jobs:
117137
php_mongodb.pdb
118138
119139
sign-and-publish-windows:
140+
environment: release
120141
name: "Sign and Publish Windows package"
121142
needs: [build-windows]
122143
# ubuntu-latest is required to use enableCrossOsArchive
123144
# See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cross-os-cache
124145
runs-on: "ubuntu-latest"
146+
permissions:
147+
id-token: write
125148

126149
strategy:
127150
fail-fast: false
@@ -132,8 +155,26 @@ jobs:
132155
ts: [ ts, nts ]
133156

134157
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+
135169
- uses: actions/checkout@v4
136170

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+
137178
- name: Restore cached build artifacts
138179
id: cache-build-artifacts
139180
uses: actions/cache/restore@v4
@@ -146,13 +187,13 @@ jobs:
146187
php_mongodb.pdb
147188
148189
- name: "Create detached DLL signature"
149-
uses: mongodb-labs/drivers-github-tools/garasign/gpg-sign@v1
190+
uses: mongodb-labs/drivers-github-tools/gpg-sign@v2
150191
with:
151192
filenames: php_mongodb.dll
152-
garasign_username: ${{ secrets.GRS_CONFIG_USER1_USERNAME }}
153-
garasign_password: ${{ secrets.GRS_CONFIG_USER1_PASSWORD }}
154-
artifactory_username: ${{ secrets.ARTIFACTORY_USER }}
155-
artifactory_password: ${{ secrets.ARTIFACTORY_PASSWORD }}
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 .
156197

157198
- name: "Upload DLL and PDB files as build artifacts"
158199
uses: actions/upload-artifact@v4
@@ -175,5 +216,3 @@ jobs:
175216
zip ${ARCHIVE} php_mongodb.dll php_mongodb.dll.sig php_mongodb.pdb CREDITS CONTRIBUTING.md LICENSE README.md THIRD_PARTY_NOTICES
176217
gh release upload ${{ github.ref_name }} ${ARCHIVE}
177218
continue-on-error: true
178-
env:
179-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎.github/workflows/release.yml

+26-23
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ on:
1414
type: "string"
1515

1616
env:
17-
# TODO: Use different token
18-
GH_TOKEN: ${{ secrets.MERGE_UP_TOKEN }}
19-
GIT_AUTHOR_NAME: "DBX PHP Release Bot"
20-
GIT_AUTHOR_EMAIL: "dbx-php@mongodb.com"
2117
default-release-message: |
2218
The PHP team is happy to announce that version {0} of the [mongodb](https://pecl.php.net/package/mongodb) PHP extension is now available on PECL.
2319
@@ -49,18 +45,40 @@ env:
4945
5046
jobs:
5147
prepare-release:
48+
environment: release
5249
name: "Prepare release"
5350
runs-on: ubuntu-latest
51+
permissions:
52+
id-token: write
53+
contents: write
5454

5555
steps:
5656
- name: "Create release output"
5757
run: echo '🎬 Release process for version ${{ inputs.version }} started by @${{ github.triggering_actor }}' >> $GITHUB_STEP_SUMMARY
5858

59+
- name: "Create temporary app token"
60+
uses: actions/create-github-app-token@v1
61+
id: app-token
62+
with:
63+
app-id: ${{ vars.APP_ID }}
64+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
65+
66+
- name: "Store GitHub token in environment"
67+
run: echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV"
68+
shell: bash
69+
5970
- uses: actions/checkout@v4
6071
with:
6172
submodules: true
6273
token: ${{ env.GH_TOKEN }}
6374

75+
- name: "Set up drivers-github-tools"
76+
uses: mongodb-labs/drivers-github-tools/setup@v2
77+
with:
78+
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
79+
aws_region_name: ${{ vars.AWS_REGION_NAME }}
80+
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
81+
6482
- name: "Install PHP"
6583
uses: "shivammathur/setup-php@v2"
6684
with:
@@ -84,11 +102,6 @@ jobs:
84102
# Preliminary checks done - commence the release process
85103
#
86104

87-
- name: "Set git author information"
88-
run: |
89-
git config user.name "${GIT_AUTHOR_NAME}"
90-
git config user.email "${GIT_AUTHOR_EMAIL}"
91-
92105
# Create a draft release with a changelog
93106
# TODO: Consider using the API to generate changelog
94107
- name: "Create draft release with generated changelog"
@@ -106,13 +119,9 @@ jobs:
106119
# our tag and creates the release tag. This is run inside the container in
107120
# order to create signed git artifacts
108121
- name: "Create package commit and release tag"
109-
uses: mongodb-labs/drivers-github-tools/garasign/git-sign@v1
122+
uses: mongodb-labs/drivers-github-tools/git-sign@v2
110123
with:
111-
command: "$(pwd)/.github/workflows/commit-and-tag.sh ${{ env.PACKAGE_VERSION }} ${{ vars.GPG_KEY_ID }} tag-message"
112-
garasign_username: ${{ secrets.GRS_CONFIG_USER1_USERNAME }}
113-
garasign_password: ${{ secrets.GRS_CONFIG_USER1_PASSWORD }}
114-
artifactory_username: ${{ secrets.ARTIFACTORY_USER }}
115-
artifactory_password: ${{ secrets.ARTIFACTORY_PASSWORD }}
124+
command: "$(pwd)/.github/workflows/commit-and-tag.sh ${{ env.PACKAGE_VERSION }} ${{ env.GPG_KEY_ID }} tag-message"
116125

117126
# This step needs to happen outside of the container, as PHP is not
118127
# available within.
@@ -121,15 +130,9 @@ jobs:
121130

122131
# Create a signed "back to -dev" commit, again inside the container
123132
- name: "Create dev commit"
124-
uses: mongodb-labs/drivers-github-tools/garasign/git-sign@v1
133+
uses: mongodb-labs/drivers-github-tools/git-sign@v2
125134
with:
126-
# Setup can be skipped as it was already done before
127-
skip_setup: true
128-
command: "git commit -m 'Back to -dev' -s --gpg-sign=${{ vars.GPG_KEY_ID }} phongo_version.h"
129-
garasign_username: ${{ secrets.GRS_CONFIG_USER1_USERNAME }}
130-
garasign_password: ${{ secrets.GRS_CONFIG_USER1_PASSWORD }}
131-
artifactory_username: ${{ secrets.ARTIFACTORY_USER }}
132-
artifactory_password: ${{ secrets.ARTIFACTORY_PASSWORD }}
135+
command: "git commit -m 'Back to -dev' -s --gpg-sign=${{ env.GPG_KEY_ID }} phongo_version.h"
133136

134137
# TODO: Manually merge using ours strategy. This avoids merge-up pull requests being created
135138
# Process is:

0 commit comments

Comments
 (0)