-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: "Release New Version" | ||
run-name: "Release ${{ inputs.version }}" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "The version to be released. This is checked for consistency with the branch name and configuration" | ||
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: "dbx-php@mongodb.com" | ||
|
||
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: "Store version numbers in env variables" | ||
run: | | ||
echo RELEASE_VERSION=${{ inputs.version }} >> $GITHUB_ENV | ||
echo RELEASE_BRANCH=$(echo ${{ inputs.version }} | cut -d '.' -f-2) >> $GITHUB_ENV | ||
- name: "Ensure release tag does not already exist" | ||
run: | | ||
if [[ $(git tag -l ${RELEASE_VERSION}) == ${RELEASE_VERSION} ]]; then | ||
echo '❌ Release failed: tag for version ${{ inputs.version }} already exists' >> $GITHUB_STEP_SUMMARY | ||
exit 1 | ||
fi | ||
- name: "Fail if branch names don't match" | ||
if: ${{ github.ref_name != env.RELEASE_BRANCH }} | ||
run: | | ||
echo '❌ Release failed due to branch mismatch: expected ${{ inputs.version }} to be released from ${{ env.RELEASE_BRANCH }}, got ${{ github.ref_name }}' >> $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 draft release with release notes | ||
- name: "Create draft release" | ||
run: echo "RELEASE_URL=$(gh release create ${{ inputs.version }} --target ${{ github.ref_name }} --title "${{ inputs.version }}" --generate-notes --draft)" >> "$GITHUB_ENV" | ||
|
||
# This step creates the signed release tag | ||
- name: "Create release tag" | ||
uses: mongodb-labs/drivers-github-tools/garasign/git-sign@v1 | ||
with: | ||
command: "git tag -m 'Release ${{ inputs.version }}' -s --local-user=${{ vars.GPG_KEY_ID }} ${{ inputs.version }}" | ||
garasign_username: ${{ secrets.GRS_CONFIG_USER1_USERNAME }} | ||
garasign_password: ${{ secrets.GRS_CONFIG_USER1_PASSWORD }} | ||
artifactory_username: ${{ secrets.ARTIFACTORY_USER }} | ||
artifactory_password: ${{ secrets.ARTIFACTORY_PASSWORD }} | ||
|
||
# TODO: Manually merge using ours strategy. This avoids merge-up pull requests being created | ||
# 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 | ||
|
||
# Pushing the release tag starts build processes that then produce artifacts for the release | ||
- name: "Push release tag" | ||
run: git push origin ${{ inputs.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 contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters