Skip to content

Commit 7142daf

Browse files
authored
PHPC-1674: Automate Driver Releases (#1538)
* Add script to update version number in phongo_version.h * Add support for release notes in prep_release.php * Add workflow to create PECL package for tags * Use PECL-compatible stability suffixes in version * Add dummy changelog for branch packages * Use package version from phongo_version.h for install * Disable install step as it currently fails * Upload release artifact for tags * Extract linux build to action * Simplify Windows builds * Create packages for Windows in package workflow * Extract and reuse Windows build workflow * Don't create artifacts when not necessary * Remove branch build trigger * Fix errors in packaging workflow * Add release workflow * Update release message * Write changelog file for PECL package * Add more output to build step * Update release documentation * Fix reading changelog for PECL packaging * Remove explicit phpize installation * Remove unnecessary fetch-depth usage * Use script parameter instead of hardcoded changelog file name * Improve update-release-version command names * Remove obsolete comment * Update JIRA version field description * Update release documentation * Fix wrong version number format * Clarify manual release process steps * Add section on announcing releases * Fix wrong heading level * Install PECL package to ensure it's functional * Only install required extensions * Use GFM note syntax * Extract release documentation
1 parent c197628 commit 7142daf

16 files changed

+747
-345
lines changed

.github/workflows/arginfo-files.yml

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ jobs:
3232
uses: "shivammathur/setup-php@v2"
3333
with:
3434
php-version: "${{ matrix.php-version }}"
35-
tools: "phpize"
3635

3736
- name: "Run phpize"
3837
run: phpize

.github/workflows/clang-format.yml

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ jobs:
3232
uses: "shivammathur/setup-php@v2"
3333
with:
3434
php-version: "${{ matrix.php-version }}"
35-
tools: "phpize"
3635

3736
- name: "Configure driver"
3837
run: .github/workflows/configure.sh
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "Linux Build"
2+
description: "Builds the driver"
3+
inputs:
4+
version:
5+
description: "PHP version to build for"
6+
required: true
7+
runs:
8+
using: composite
9+
steps:
10+
- name: "Install PHP"
11+
uses: "shivammathur/setup-php@v2"
12+
with:
13+
php-version: "${{ inputs.version }}"
14+
# Only install required extensions
15+
extensions: "none,date,json,spl,standard,xml"
16+
17+
- name: "Configure driver"
18+
run: .github/workflows/configure.sh
19+
shell: bash
20+
21+
- name: "Build driver"
22+
run: "make all"
23+
shell: bash

.github/workflows/package-release.yml

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: "Package Release"
2+
run-name: "Package Release ${{ github.ref_name }}"
3+
4+
on:
5+
push:
6+
tags:
7+
- "*"
8+
9+
jobs:
10+
build-pecl:
11+
name: "Create PECL package"
12+
runs-on: "ubuntu-latest"
13+
14+
steps:
15+
- name: "Checkout"
16+
uses: "actions/checkout@v4"
17+
with:
18+
# Manually specify a ref. When actions/checkout is run for a tag without a ref, it looks up the underlying
19+
# commit and specifically fetches this to the refs/tags/<tag> ref, which denies us access to the tag message
20+
ref: ${{ github.ref }}
21+
submodules: true
22+
23+
- name: "Build Driver"
24+
uses: ./.github/workflows/linux/build
25+
with:
26+
version: "8.3"
27+
28+
- name: "Write changelog file for packaging"
29+
run: git tag -l ${{ github.ref_name }} --format='%(contents)' > changelog
30+
31+
# This will fill in the release notes from the previously generated changelog
32+
- name: "Build package.xml"
33+
run: "make package.xml RELEASE_NOTES_FILE=$(pwd)/changelog"
34+
35+
- name: "Build release archive"
36+
run: "make package"
37+
38+
# PECL always uses the version for the package name.
39+
# Read it from the version file and store in env to use when uploading artifacts
40+
- name: "Read current package version"
41+
run: echo "PACKAGE_VERSION=$(./bin/update-release-version.php get-version)" >> "$GITHUB_ENV"
42+
43+
- name: "Install release archive to verify correctness"
44+
run: sudo pecl install mongodb-${{ env.PACKAGE_VERSION }}.tgz
45+
46+
- name: "Upload artifact"
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: mongodb-${{ env.PACKAGE_VERSION }}.tgz
50+
path: mongodb-${{ env.PACKAGE_VERSION }}.tgz
51+
retention-days: 3
52+
53+
- name: "Upload release artifact"
54+
run: gh release upload ${{ github.ref_name }} mongodb-${{ env.PACKAGE_VERSION }}.tgz
55+
continue-on-error: true
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
59+
build-windows:
60+
name: "Create Windows package"
61+
runs-on: windows-2022
62+
defaults:
63+
run:
64+
shell: cmd
65+
66+
strategy:
67+
fail-fast: false
68+
matrix:
69+
# Note: keep this in sync with the Windows matrix in windows-tests.yml
70+
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
71+
arch: [ x64, x86 ]
72+
ts: [ ts, nts ]
73+
74+
steps:
75+
- uses: actions/checkout@v4
76+
with:
77+
submodules: true
78+
79+
- name: "Build Driver"
80+
id: build-driver
81+
uses: ./.github/workflows/windows/build
82+
with:
83+
version: ${{ matrix.php }}
84+
arch: ${{ matrix.arch }}
85+
ts: ${{ matrix.ts }}
86+
87+
- name: "Copy DLL and PDB files to CWD"
88+
run: |
89+
cp %BUILD_DIR%\php_mongodb.dll .
90+
cp %BUILD_DIR%\php_mongodb.pdb .
91+
env:
92+
BUILD_DIR: ${{ steps.build-driver.outputs.build-dir }}
93+
94+
- name: "Upload DLL and PDB files as build artifacts"
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: php_mongodb-${{ github.ref_name }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
98+
path: |
99+
php_mongodb.dll
100+
php_mongodb.pdb
101+
retention-days: 3
102+
103+
- name: "Create and upload release artifact"
104+
run: |
105+
set ARCHIVE=php_mongodb-${{ github.ref_name }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}.zip
106+
zip %ARCHIVE% php_mongodb.dll php_mongodb.pdb CREDITS CONTRIBUTING.md LICENSE README.md THIRD_PARTY_NOTICES
107+
gh release upload ${{ github.ref_name }} %ARCHIVE%
108+
continue-on-error: true
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
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+
jira-version-number:
12+
description: "JIRA version ID (e.g. 54321)"
13+
required: true
14+
type: "string"
15+
16+
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: "[email protected]"
21+
default-release-message: |
22+
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.
23+
24+
**Release Highlights**
25+
26+
TODO: one or more paragraphs describing important changes in this release
27+
28+
A complete list of resolved issues in this release may be found in [JIRA](https://jira.mongodb.org/secure/ReleaseNote.jspa?version={1}&projectId=12484).
29+
30+
**Documentation**
31+
32+
Documentation is available on [PHP.net](https://php.net/set.mongodb).
33+
34+
**Installation**
35+
36+
You can either download and install the source manually, or you can install the extension with:
37+
38+
```
39+
pecl install mongodb-{0}
40+
```
41+
42+
or update with:
43+
44+
```
45+
pecl upgrade mongodb-{0}
46+
```
47+
48+
Windows binaries are attached to the GitHub release notes.
49+
50+
jobs:
51+
prepare-release:
52+
name: "Prepare release"
53+
runs-on: ubuntu-latest
54+
55+
steps:
56+
- name: "Create release output"
57+
run: echo '🎬 Release process for version ${{ inputs.version }} started by @${{ github.triggering_actor }}' >> $GITHUB_STEP_SUMMARY
58+
59+
- uses: actions/checkout@v4
60+
with:
61+
submodules: true
62+
token: ${{ env.GH_TOKEN }}
63+
64+
- name: "Install PHP"
65+
uses: "shivammathur/setup-php@v2"
66+
with:
67+
php-version: "${{ matrix.php-version }}"
68+
69+
- name: "Update version information to stable release"
70+
run: ./bin/update-release-version.php to-stable
71+
72+
- name: "Read current package version"
73+
run: echo "PACKAGE_VERSION=$(./bin/update-release-version.php get-version)" >> "$GITHUB_ENV"
74+
75+
# Sanity check - the version from the input and the one determined by phongo_version.h need to be the same
76+
- name: "Check version for consistency"
77+
if: ${{ inputs.version != env.PACKAGE_VERSION }}
78+
# We exit with an error to abort the workflow. This is only run if the versions don't match
79+
run: |
80+
echo '❌ Release failed due to version mismatch: expected ${{ inputs.version }}, got ${{ env.PACKAGE_VERSION }} from code' >> $GITHUB_STEP_SUMMARY
81+
exit 1
82+
83+
#
84+
# Preliminary checks done - commence the release process
85+
#
86+
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+
92+
# Create the "Package x.y.z" commit that will be the base of our tag
93+
- name: "Create release commit"
94+
run: git commit -m "Package ${{ env.PACKAGE_VERSION }}" phongo_version.h
95+
96+
# Create a draft release with a changelog
97+
# TODO: Consider using the API to generate changelog
98+
- name: "Create draft release with generated changelog"
99+
run: gh release create ${{ env.PACKAGE_VERSION }} --target ${{ github.ref_name }} --generate-notes --draft
100+
101+
- name: "Read changelog from draft release"
102+
run: gh release view ${{ env.PACKAGE_VERSION }} --json body --template '{{ .body }}' >> changelog
103+
104+
# TODO: Sign tag
105+
- name: "Create release tag"
106+
run: git tag -a -F changelog ${{ env.PACKAGE_VERSION }}
107+
108+
- name: "Update version information to next patch development release"
109+
run: |
110+
./bin/update-release-version.php to-next-patch-dev
111+
git commit -m "Back to -dev" phongo_version.h
112+
113+
# TODO: Manually merge using ours strategy. This avoids merge-up pull requests being created
114+
# Process is:
115+
# 1. switch to next branch (according to merge-up action)
116+
# 2. merge release branch using --strategy=ours
117+
# 3. push next branch
118+
# 4. switch back to release branch, then push
119+
120+
- name: "Push changes from release branch"
121+
run: git push
122+
123+
- name: "Prepare release message"
124+
run: |
125+
echo "${{ format(env.default-release-message, env.PACKAGE_VERSION, inputs.jira-version-number) }}" > release-message
126+
cat changelog >> release-message
127+
128+
# Update release with correct release information
129+
- name: "Update release information"
130+
run: echo "RELEASE_URL=$(gh release edit ${{ env.PACKAGE_VERSION }} --title "${{ env.PACKAGE_VERSION }}" --notes-file release-message)" >> "$GITHUB_ENV"
131+
132+
# Pushing the release tag starts build processes that then produce artifacts for the release
133+
- name: "Push release tag"
134+
run: git push origin ${{ env.PACKAGE_VERSION }}
135+
136+
- name: "Set summary"
137+
run: |
138+
echo '🚀 Created tag and drafted release for version [${{ inputs.version }}](${{ env.RELEASE_URL }})' >> $GITHUB_STEP_SUMMARY
139+
echo '✍️ You may now update the release notes and publish the release when ready' >> $GITHUB_STEP_SUMMARY

.github/workflows/tests.yml

+4-11
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ jobs:
5454
- name: "Checkout"
5555
uses: "actions/checkout@v4"
5656
with:
57-
fetch-depth: 2
5857
submodules: true
5958

6059
- id: setup-mongodb
@@ -63,17 +62,11 @@ jobs:
6362
version: ${{ matrix.mongodb-version }}
6463
topology: ${{ matrix.topology }}
6564

66-
- name: "Install PHP"
67-
uses: "shivammathur/setup-php@v2"
65+
- name: "Build Driver"
66+
id: build-driver
67+
uses: ./.github/workflows/linux/build
6868
with:
69-
php-version: "${{ matrix.php-version }}"
70-
tools: "phpize"
71-
72-
- name: "Configure driver"
73-
run: .github/workflows/configure.sh
74-
75-
- name: "Build driver"
76-
run: "make all"
69+
version: ${{ matrix.php-version }}
7770

7871
- name: "Run Tests"
7972
run: TEST_PHP_ARGS="-q -x --show-diff -g FAIL,XFAIL,BORK,WARN,LEAK,SKIP" make test

.github/workflows/windows-release-build.yml

-37
This file was deleted.

0 commit comments

Comments
 (0)