Skip to content

Commit d685b6a

Browse files
authored
PHPORM-153: Add automated release workflow (mongodb#2964)
* Add automated release workflow * Use stable version of release tooling * Automatically generate release notes for draft release
1 parent 390c9ec commit d685b6a

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

.github/workflows/release.yml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: "Release New Version"
2+
run-name: "Release ${{ inputs.version }}"
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: "The version to be released. This is checked for consistency with the branch name and configuration"
9+
required: true
10+
type: "string"
11+
12+
env:
13+
# TODO: Use different token
14+
GH_TOKEN: ${{ secrets.MERGE_UP_TOKEN }}
15+
GIT_AUTHOR_NAME: "DBX PHP Release Bot"
16+
GIT_AUTHOR_EMAIL: "[email protected]"
17+
18+
jobs:
19+
prepare-release:
20+
name: "Prepare release"
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: "Create release output"
25+
run: echo '🎬 Release process for version ${{ inputs.version }} started by @${{ github.triggering_actor }}' >> $GITHUB_STEP_SUMMARY
26+
27+
- uses: actions/checkout@v4
28+
with:
29+
submodules: true
30+
token: ${{ env.GH_TOKEN }}
31+
32+
- name: "Store version numbers in env variables"
33+
run: |
34+
echo RELEASE_VERSION=${{ inputs.version }} >> $GITHUB_ENV
35+
echo RELEASE_BRANCH=$(echo ${{ inputs.version }} | cut -d '.' -f-2) >> $GITHUB_ENV
36+
37+
- name: "Ensure release tag does not already exist"
38+
run: |
39+
if [[ $(git tag -l ${RELEASE_VERSION}) == ${RELEASE_VERSION} ]]; then
40+
echo '❌ Release failed: tag for version ${{ inputs.version }} already exists' >> $GITHUB_STEP_SUMMARY
41+
exit 1
42+
fi
43+
44+
- name: "Fail if branch names don't match"
45+
if: ${{ github.ref_name != env.RELEASE_BRANCH }}
46+
run: |
47+
echo '❌ Release failed due to branch mismatch: expected ${{ inputs.version }} to be released from ${{ env.RELEASE_BRANCH }}, got ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
48+
exit 1
49+
50+
#
51+
# Preliminary checks done - commence the release process
52+
#
53+
54+
- name: "Set git author information"
55+
run: |
56+
git config user.name "${GIT_AUTHOR_NAME}"
57+
git config user.email "${GIT_AUTHOR_EMAIL}"
58+
59+
# Create draft release with release notes
60+
- name: "Create draft release"
61+
run: echo "RELEASE_URL=$(gh release create ${{ inputs.version }} --target ${{ github.ref_name }} --title "${{ inputs.version }}" --generate-notes --draft)" >> "$GITHUB_ENV"
62+
63+
# This step creates the signed release tag
64+
- name: "Create release tag"
65+
uses: mongodb-labs/drivers-github-tools/garasign/git-sign@v1
66+
with:
67+
command: "git tag -m 'Release ${{ inputs.version }}' -s --local-user=${{ vars.GPG_KEY_ID }} ${{ inputs.version }}"
68+
garasign_username: ${{ secrets.GRS_CONFIG_USER1_USERNAME }}
69+
garasign_password: ${{ secrets.GRS_CONFIG_USER1_PASSWORD }}
70+
artifactory_username: ${{ secrets.ARTIFACTORY_USER }}
71+
artifactory_password: ${{ secrets.ARTIFACTORY_PASSWORD }}
72+
73+
# TODO: Manually merge using ours strategy. This avoids merge-up pull requests being created
74+
# Process is:
75+
# 1. switch to next branch (according to merge-up action)
76+
# 2. merge release branch using --strategy=ours
77+
# 3. push next branch
78+
# 4. switch back to release branch, then push
79+
80+
- name: "Push changes from release branch"
81+
run: git push
82+
83+
# Pushing the release tag starts build processes that then produce artifacts for the release
84+
- name: "Push release tag"
85+
run: git push origin ${{ inputs.version }}
86+
87+
- name: "Set summary"
88+
run: |
89+
echo '🚀 Created tag and drafted release for version [${{ inputs.version }}](${{ env.RELEASE_URL }})' >> $GITHUB_STEP_SUMMARY
90+
echo '✍️ You may now update the release notes and publish the release when ready' >> $GITHUB_STEP_SUMMARY

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ It is compatible with Laravel 10.x. For older versions of Laravel, please refer
1717
- https://www.mongodb.com/docs/drivers/php/laravel-mongodb/
1818
- https://www.mongodb.com/docs/drivers/php/
1919

20+
## Release Integrity
21+
22+
Releases are created automatically and the resulting release tag is signed using
23+
the [PHP team's GPG key](https://pgp.mongodb.com/php-driver.asc). To verify the
24+
tag signature, download the key and import it using `gpg`:
25+
26+
```shell
27+
gpg --import php-driver.asc
28+
```
29+
30+
Then, in a local clone, verify the signature of a given tag (e.g. `4.4.0`):
31+
32+
```shell
33+
git show --show-signature 4.4.0
34+
```
35+
36+
> [!NOTE]
37+
> Composer does not support verifying signatures as part of its installation
38+
> process.
39+
2040
## Reporting Issues
2141

2242
Think you’ve found a bug in the library? Want to see a new feature? Please open a case in our issue management tool, JIRA:

0 commit comments

Comments
 (0)