-
Notifications
You must be signed in to change notification settings - Fork 208
PHPC-1674: Automate Driver Releases #1538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4fd5ef4
4f539b6
8e27e9f
7158423
0df9e50
2a9bf9a
25acaf8
1c49d08
5ef1c98
26bc929
ea94be3
76c3f33
63a5d46
d800bba
4302cda
d6648cb
88d08de
d4b579d
666a988
2833a36
5c46fb3
6972709
067f691
5843f69
f60cd9a
2a4f512
65d64d0
08621e7
090fce6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: "Linux Build" | ||
description: "Builds the driver" | ||
inputs: | ||
version: | ||
description: "PHP version to build for" | ||
required: true | ||
runs: | ||
using: composite | ||
steps: | ||
- name: "Install PHP" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: "${{ inputs.version }}" | ||
# Only install required extensions | ||
extensions: "none,date,json,spl,standard,xml" | ||
|
||
- name: "Configure driver" | ||
run: .github/workflows/configure.sh | ||
shell: bash | ||
|
||
- name: "Build driver" | ||
run: "make all" | ||
shell: bash |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
name: "Package Release" | ||
run-name: "Package Release ${{ github.ref_name }}" | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
|
||
jobs: | ||
build-pecl: | ||
name: "Create PECL package" | ||
runs-on: "ubuntu-latest" | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v4" | ||
with: | ||
# Manually specify a ref. When actions/checkout is run for a tag without a ref, it looks up the underlying | ||
# commit and specifically fetches this to the refs/tags/<tag> ref, which denies us access to the tag message | ||
ref: ${{ github.ref }} | ||
submodules: true | ||
|
||
- name: "Build Driver" | ||
uses: ./.github/workflows/linux/build | ||
with: | ||
version: "8.3" | ||
|
||
- name: "Write changelog file for packaging" | ||
run: git tag -l ${{ github.ref_name }} --format='%(contents)' > changelog | ||
alcaeus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# This will fill in the release notes from the previously generated changelog | ||
- name: "Build package.xml" | ||
run: "make package.xml RELEASE_NOTES_FILE=$(pwd)/changelog" | ||
jmikola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: "Build release archive" | ||
jmikola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
run: "make package" | ||
|
||
# PECL always uses the version for the package name. | ||
# Read it from the version file and store in env to use when uploading artifacts | ||
- name: "Read current package version" | ||
run: echo "PACKAGE_VERSION=$(./bin/update-release-version.php get-version)" >> "$GITHUB_ENV" | ||
|
||
- name: "Install release archive to verify correctness" | ||
run: sudo pecl install mongodb-${{ env.PACKAGE_VERSION }}.tgz | ||
|
||
- name: "Upload artifact" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: mongodb-${{ env.PACKAGE_VERSION }}.tgz | ||
path: mongodb-${{ env.PACKAGE_VERSION }}.tgz | ||
retention-days: 3 | ||
|
||
- name: "Upload release artifact" | ||
run: gh release upload ${{ github.ref_name }} mongodb-${{ env.PACKAGE_VERSION }}.tgz | ||
continue-on-error: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
build-windows: | ||
name: "Create Windows package" | ||
runs-on: windows-2022 | ||
defaults: | ||
run: | ||
shell: cmd | ||
|
||
strategy: | ||
fail-fast: false | ||
alcaeus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
matrix: | ||
# Note: keep this in sync with the Windows matrix in windows-tests.yml | ||
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ] | ||
arch: [ x64, x86 ] | ||
ts: [ ts, nts ] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: "Build Driver" | ||
id: build-driver | ||
uses: ./.github/workflows/windows/build | ||
with: | ||
version: ${{ matrix.php }} | ||
arch: ${{ matrix.arch }} | ||
ts: ${{ matrix.ts }} | ||
|
||
- name: "Copy DLL and PDB files to CWD" | ||
run: | | ||
cp %BUILD_DIR%\php_mongodb.dll . | ||
cp %BUILD_DIR%\php_mongodb.pdb . | ||
env: | ||
BUILD_DIR: ${{ steps.build-driver.outputs.build-dir }} | ||
|
||
- name: "Upload DLL and PDB files as build artifacts" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: php_mongodb-${{ github.ref_name }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }} | ||
path: | | ||
php_mongodb.dll | ||
php_mongodb.pdb | ||
retention-days: 3 | ||
|
||
- name: "Create and upload release artifact" | ||
run: | | ||
set ARCHIVE=php_mongodb-${{ github.ref_name }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}.zip | ||
zip %ARCHIVE% php_mongodb.dll php_mongodb.pdb CREDITS CONTRIBUTING.md LICENSE README.md THIRD_PARTY_NOTICES | ||
gh release upload ${{ github.ref_name }} %ARCHIVE% | ||
continue-on-error: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
name: "Release New Version" | ||
run-name: "Release ${{ inputs.version }}" | ||
|
||
on: | ||
workflow_dispatch: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
inputs: | ||
version: | ||
description: "The version to be released. This is checked for consistency with the branch name and configuration" | ||
required: true | ||
type: "string" | ||
jira-version-number: | ||
description: "JIRA version ID (e.g. 54321)" | ||
required: true | ||
type: "string" | ||
|
||
env: | ||
# TODO: Use different token | ||
GH_TOKEN: ${{ secrets.MERGE_UP_TOKEN }} | ||
GIT_AUTHOR_NAME: "DBX PHP Release Bot" | ||
GIT_AUTHOR_EMAIL: "[email protected]" | ||
default-release-message: | | ||
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. | ||
|
||
**Release Highlights** | ||
|
||
TODO: one or more paragraphs describing important changes in this release | ||
|
||
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). | ||
|
||
**Documentation** | ||
|
||
Documentation is available on [PHP.net](https://php.net/set.mongodb). | ||
|
||
**Installation** | ||
|
||
You can either download and install the source manually, or you can install the extension with: | ||
|
||
``` | ||
pecl install mongodb-{0} | ||
``` | ||
|
||
or update with: | ||
|
||
``` | ||
pecl upgrade mongodb-{0} | ||
``` | ||
|
||
Windows binaries are attached to the GitHub release notes. | ||
|
||
jobs: | ||
prepare-release: | ||
name: "Prepare release" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: "Create release output" | ||
run: echo '🎬 Release process for version ${{ inputs.version }} started by @${{ github.triggering_actor }}' >> $GITHUB_STEP_SUMMARY | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
token: ${{ env.GH_TOKEN }} | ||
|
||
- name: "Install PHP" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: "${{ matrix.php-version }}" | ||
|
||
- name: "Update version information to stable release" | ||
run: ./bin/update-release-version.php to-stable | ||
|
||
- name: "Read current package version" | ||
run: echo "PACKAGE_VERSION=$(./bin/update-release-version.php get-version)" >> "$GITHUB_ENV" | ||
|
||
# Sanity check - the version from the input and the one determined by phongo_version.h need to be the same | ||
- name: "Check version for consistency" | ||
if: ${{ inputs.version != env.PACKAGE_VERSION }} | ||
# We exit with an error to abort the workflow. This is only run if the versions don't match | ||
run: | | ||
echo '❌ Release failed due to version mismatch: expected ${{ inputs.version }}, got ${{ env.PACKAGE_VERSION }} from code' >> $GITHUB_STEP_SUMMARY | ||
exit 1 | ||
|
||
# | ||
# Preliminary checks done - commence the release process | ||
# | ||
|
||
- name: "Set git author information" | ||
run: | | ||
git config user.name "${GIT_AUTHOR_NAME}" | ||
git config user.email "${GIT_AUTHOR_EMAIL}" | ||
|
||
# Create the "Package x.y.z" commit that will be the base of our tag | ||
- name: "Create release commit" | ||
run: git commit -m "Package ${{ env.PACKAGE_VERSION }}" phongo_version.h | ||
|
||
# Create a draft release with a changelog | ||
# TODO: Consider using the API to generate changelog | ||
- name: "Create draft release with generated changelog" | ||
run: gh release create ${{ env.PACKAGE_VERSION }} --target ${{ github.ref_name }} --generate-notes --draft | ||
|
||
- name: "Read changelog from draft release" | ||
run: gh release view ${{ env.PACKAGE_VERSION }} --json body --template '{{ .body }}' >> changelog | ||
|
||
# TODO: Sign tag | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be done in a later step as we currently don't have the signing infrastructure in place. |
||
- name: "Create release tag" | ||
run: git tag -a -F changelog ${{ env.PACKAGE_VERSION }} | ||
|
||
- name: "Update version information to next patch development release" | ||
run: | | ||
./bin/update-release-version.php to-next-patch-dev | ||
git commit -m "Back to -dev" phongo_version.h | ||
|
||
# TODO: Manually merge using ours strategy. This avoids merge-up pull requests being created | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll defer this to a separate PR as it requires some work to make this logic from the merge-up action reusable here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder to ticket this if needed so we don't lose track of it. I assume we already have a ticket to track the earlier TODO for release signing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
# Process is: | ||
# 1. switch to next branch (according to merge-up action) | ||
# 2. merge release branch using --strategy=ours | ||
# 3. push next branch | ||
# 4. switch back to release branch, then push | ||
|
||
- name: "Push changes from release branch" | ||
run: git push | ||
|
||
- name: "Prepare release message" | ||
run: | | ||
echo "${{ format(env.default-release-message, env.PACKAGE_VERSION, inputs.jira-version-number) }}" > release-message | ||
cat changelog >> release-message | ||
|
||
# Update release with correct release information | ||
- name: "Update release information" | ||
run: echo "RELEASE_URL=$(gh release edit ${{ env.PACKAGE_VERSION }} --title "${{ env.PACKAGE_VERSION }}" --notes-file release-message)" >> "$GITHUB_ENV" | ||
|
||
# Pushing the release tag starts build processes that then produce artifacts for the release | ||
- name: "Push release tag" | ||
run: git push origin ${{ env.PACKAGE_VERSION }} | ||
|
||
- name: "Set summary" | ||
run: | | ||
echo '🚀 Created tag and drafted release for version [${{ inputs.version }}](${{ env.RELEASE_URL }})' >> $GITHUB_STEP_SUMMARY | ||
echo '✍️ You may now update the release notes and publish the release when ready' >> $GITHUB_STEP_SUMMARY |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.