From 5e81555b85bcd4d15c6d585d5ad189d6311f2d36 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 24 Mar 2021 10:56:10 +1100 Subject: [PATCH] Add workflow for drafting a new release Drafting a new release can be quite involved. One has to update the changelog correctly, bump the versions in the manifest files, commit everything and raise a PR. This workflow does all of that for you at the click of a button! --- .github/workflows/draft-new-release.yml | 70 +++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/draft-new-release.yml diff --git a/.github/workflows/draft-new-release.yml b/.github/workflows/draft-new-release.yml new file mode 100644 index 00000000..58b85364 --- /dev/null +++ b/.github/workflows/draft-new-release.yml @@ -0,0 +1,70 @@ +name: "Draft new release" + +on: + workflow_dispatch: + inputs: + version: + description: 'The new version in X.Y.Z format.' + required: true + +jobs: + draft-new-release: + name: "Draft a new release" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + token: ${{ secrets.BOTTY_GITHUB_TOKEN }} + + - name: Create release branch + run: git checkout -b release/${{ github.event.inputs.version }} + + - name: Update changelog + uses: thomaseizinger/keep-a-changelog-new-release@1.2.1 + with: + version: ${{ github.event.inputs.version }} + changelogPath: CHANGELOG.md + + - name: Initialize mandatory git config + run: | + git config user.name "${{ secrets.BOTTY_NAME }}" + git config user.email ${{ secrets.BOTTY_EMAIL }} + + - name: Bump version in Cargo.toml + uses: thomaseizinger/set-crate-version@1.0.0 + with: + version: ${{ github.event.inputs.version }} + manifest: swap/Cargo.toml + + - name: Update Cargo.lock + run: cargo update --workspace + + - name: Commit changelog and manifest files + id: make-commit + run: | + curl -fsSL https://dprint.dev/install.sh | sh + /home/runner/.dprint/bin/dprint fmt + + git add CHANGELOG.md Cargo.lock swap/Cargo.toml + git commit --message "Prepare release ${{ github.event.inputs.version }}" + + echo "::set-output name=commit::$(git rev-parse HEAD)" + + - name: Push new branch + run: git push origin release/${{ github.event.inputs.version }} --force + + - name: Create pull request + uses: thomaseizinger/create-pull-request@1.0.0 + with: + GITHUB_TOKEN: ${{ secrets.BOTTY_GITHUB_TOKEN }} + head: release/${{ github.event.inputs.version }} + base: master + title: Release version ${{ github.event.inputs.version }} + reviewers: ${{ github.actor }} + body: | + Hi @${{ github.actor }}! + + 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 }}. + I've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}. + + Merging this PR will create a GitHub release and upload any assets that are created as part of the release build.