|
| 1 | +# Initiation half of the release process for this repository. |
| 2 | +# |
| 3 | +# This is triggered manually through the github actions UI and will execute |
| 4 | +# `./publish bump` (or `bump-patch`). Afterwards the result will be pushed to a |
| 5 | +# branch in the main repository and a PR will be opened. This PR, when merged, |
| 6 | +# will trigger the second half in `publish.yml`. |
| 7 | + |
| 8 | +name: "Automated Release Process" |
| 9 | +on: |
| 10 | + # Allow manually triggering this request via the button on the action |
| 11 | + # workflow page. |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + action: |
| 15 | + description: 'Publish script argument: "bump", or "bump-patch"' |
| 16 | + required: false |
| 17 | + default: 'bump' |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: write |
| 21 | + pull-requests: write |
| 22 | + |
| 23 | +jobs: |
| 24 | + release_process: |
| 25 | + name: Run the release process |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + submodules: true |
| 31 | + - name: Setup |
| 32 | + run: | |
| 33 | + rustc ci/publish.rs |
| 34 | + git config user.name 'Auto Release Process' |
| 35 | + git config user.email '[email protected]' |
| 36 | + git remote set-url origin https://git:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} |
| 37 | +
|
| 38 | + - name: Bump version number |
| 39 | + run: ./publish ${{ github.event.inputs.action }} |
| 40 | + |
| 41 | + - name: Prep PR metadata |
| 42 | + run: | |
| 43 | + set -ex |
| 44 | + git fetch origin |
| 45 | +
|
| 46 | + cur=$(./ci/print-current-version.sh) |
| 47 | +
|
| 48 | + git commit --allow-empty -a -F-<<EOF |
| 49 | + Release ${{ github.event.repository.name }} $cur |
| 50 | +
|
| 51 | + [automatically-tag-and-release-this-commit] |
| 52 | + EOF |
| 53 | +
|
| 54 | + # Push the result to a branch and setup metadata for the step below |
| 55 | + # that creates a PR |
| 56 | + git push origin HEAD:ci/release-$cur |
| 57 | + echo "PR_HEAD=ci/release-$cur" >> $GITHUB_ENV |
| 58 | + echo "PR_TITLE=Release ${{ github.event.repository.name }} $cur" >> $GITHUB_ENV |
| 59 | + echo "PR_BASE=main" >> $GITHUB_ENV |
| 60 | + cat > pr-body <<-EOF |
| 61 | + This is an automated pull request from CI to release |
| 62 | + ${{ github.event.repository.name }} $cur when merged. The commit |
| 63 | + message for this PR has a marker that is detected by CI to create |
| 64 | + tags and publish crate artifacts. |
| 65 | +
|
| 66 | + When first opened this PR will not have CI run because it is generated |
| 67 | + by a bot. A maintainer should close this PR and then reopen it to |
| 68 | + trigger CI to execute which will then enable merging this PR. |
| 69 | + EOF |
| 70 | +
|
| 71 | + - name: Make a PR |
| 72 | + run: gh pr create -B "$PR_BASE" -H "$PR_HEAD" --title "$PR_TITLE" --body "$(cat ./pr-body)" |
| 73 | + env: |
| 74 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments