|
| 1 | +name: "Draft new release" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "The version you want to release." |
| 8 | + required: true |
| 9 | + |
| 10 | +jobs: |
| 11 | + draft-new-release: |
| 12 | + name: "Draft a new release" |
| 13 | + runs-on: ubuntu-latest |
| 14 | + if: github.ref_name == 'develop' |
| 15 | + outputs: |
| 16 | + commitSha: ${{ steps.make-commit.outputs.commit }} |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + token: ${{ secrets.ACTIONS_NICHOLAS_PAT }} |
| 21 | + |
| 22 | + - name: Create release branch |
| 23 | + run: | |
| 24 | + git checkout -b release/v${{ github.event.inputs.version }}; |
| 25 | +
|
| 26 | + - name: Create draft release |
| 27 | + uses: release-drafter/release-drafter@v6 |
| 28 | + with: |
| 29 | + config-name: release-draft.yml |
| 30 | + version: v${{ github.event.inputs.version }} |
| 31 | + tag: v${{ github.event.inputs.version }} |
| 32 | + name: v${{ github.event.inputs.version }} |
| 33 | + prerelease: false |
| 34 | + publish: false |
| 35 | + env: |
| 36 | + GITHUB_TOKEN: ${{ secrets.ACTIONS_NICHOLAS_PAT }} |
| 37 | + |
| 38 | + - name: Set up JDK 17 |
| 39 | + uses: actions/setup-java@v4 |
| 40 | + with: |
| 41 | + java-version: "17" |
| 42 | + distribution: "corretto" |
| 43 | + cache: 'maven' |
| 44 | + |
| 45 | + - name: Bump version in pom.xml files |
| 46 | + run: | |
| 47 | + |
| 48 | + # Update parent and child module pom.xml files |
| 49 | + echo "Updating version in parent and module pom.xml files to ${{ github.event.inputs.version }}-RELEASE..." |
| 50 | + mvn versions:set -DnewVersion=${{ github.event.inputs.version }}-RELEASE -DgenerateBackupPoms=false |
| 51 | + |
| 52 | + # Update standalone module pom.xml files |
| 53 | + echo "Updating standalone module versions..." |
| 54 | + mvn versions:set -DnewVersion=${{ github.event.inputs.version }}-RELEASE -DgenerateBackupPoms=false -f acceptance-tests/pom.xml |
| 55 | + mvn versions:set -DnewVersion=${{ github.event.inputs.version }}-RELEASE -DgenerateBackupPoms=false -f generate-race-cpcplus/pom.xml |
| 56 | + mvn versions:set -DnewVersion=${{ github.event.inputs.version }}-RELEASE -DgenerateBackupPoms=false -f qrda3-update-measures/pom.xml |
| 57 | + echo "Version update complete." |
| 58 | +
|
| 59 | + # In order to make a commit, we need to initialize a user. |
| 60 | + # You may choose to write something less generic here if you want, it doesn't matter functionality-wise. |
| 61 | + - name: Initialize mandatory git config |
| 62 | + run: | |
| 63 | + git config user.name "GitHub actions" |
| 64 | + git config user.email noreply@github.com |
| 65 | +
|
| 66 | + - name: Commit pom files |
| 67 | + run: | |
| 68 | + git add '**/pom.xml' pom.xml |
| 69 | + git commit --message "Prepare release v${{ github.event.inputs.version }}" |
| 70 | +
|
| 71 | + - name: Fetch commit hash |
| 72 | + id: make-commit |
| 73 | + run: echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT |
| 74 | + |
| 75 | + - name: Push new branch |
| 76 | + run: | |
| 77 | + git push origin release/v${{ github.event.inputs.version }} |
| 78 | +
|
| 79 | + - name: Create pull request to master branch |
| 80 | + uses: thomaseizinger/create-pull-request@1.4.0 |
| 81 | + env: |
| 82 | + GITHUB_TOKEN: ${{ secrets.ACTIONS_NICHOLAS_PAT }} # MUST use a PAT here in order to trigger the next workflow: CodeBuild Trigger; see https://docs.github.com/en/actions/using-workflows/triggering-a-workflow |
| 83 | + with: |
| 84 | + head: release/v${{ github.event.inputs.version }} |
| 85 | + base: master |
| 86 | + draft: true |
| 87 | + title: Deploy Release version v${{ github.event.inputs.version }} to Prod |
| 88 | + body: | |
| 89 | + Hi @${{ github.actor }}! |
| 90 | +
|
| 91 | + This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}. |
| 92 | + The changelog was updated and the version was bumped in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}. |
| 93 | +
|
| 94 | + Merging this PR will create a GitHub release. |
0 commit comments