Skip to content

Commit 63a5d46

Browse files
committed
Add release workflow
1 parent 76c3f33 commit 63a5d46

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)