|
| 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 |
0 commit comments