From 280bc974eb6f17b88f5547dc7efcb4d87bd14256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Saparelli?= Date: Sun, 4 Sep 2022 21:38:08 +1200 Subject: [PATCH] Use release PR action (#330) --- .github/scripts/release-pr-template.ejs | 52 ++++++++++++++++++++ .github/scripts/release-pr.txt | 28 ----------- .github/workflows/release-pr.yml | 65 +++++++------------------ 3 files changed, 70 insertions(+), 75 deletions(-) create mode 100644 .github/scripts/release-pr-template.ejs delete mode 100644 .github/scripts/release-pr.txt diff --git a/.github/scripts/release-pr-template.ejs b/.github/scripts/release-pr-template.ejs new file mode 100644 index 00000000..4cb6353c --- /dev/null +++ b/.github/scripts/release-pr-template.ejs @@ -0,0 +1,52 @@ +This is a release PR for version **<%= version.actual %>**<% + if (version.actual != version.desired) { +%> (performing a <%= version.desired %> bump).<% + } else { +%>.<% + } +%> + +<% if (pr.mergeStrategy == "merge") { %> +**Use a merge commit.** +<% } else if (pr.mergeStrategy == "rebase") { %> +**Use rebase merge.** +<% } else if (pr.mergeStrategy == "squash") { %> +**Use squash merge.** +<% } else if (pr.mergeStrategy == "bors") { %> +**Merge by commenting:** +| bors r+ | +|:-:| +<% } %> + +<% if (crate.name == "cargo-binstall") { %> +Upon merging, this will automatically build the CLI and create a GitHub release. +<% } else { %> +Upon merging, this will create the tag `<%= crate.name %>-<%= version.actual %>`. +<% } %> + +You will still need to manually publish the cargo crate: + +``` +$ git pull +$ git switch --detach v{version} +$ cargo publish +``` + +<% if (pr.releaseNotes) { %> +--- + +_Edit release notes into the section below:_ + + +### Release notes + +_Binstall is a tool to fetch and install Rust-based executables as binaries. It aims to be a drop-in replacement for \`cargo install\` in most cases. Install it today with \`cargo install cargo-binstall\`, from the binaries below, or if you already have it, upgrade with \`cargo binstall cargo-binstall\`._ + +#### In this release: + +- + +#### Other changes: + +- +<% } %> diff --git a/.github/scripts/release-pr.txt b/.github/scripts/release-pr.txt deleted file mode 100644 index e8fe3f7d..00000000 --- a/.github/scripts/release-pr.txt +++ /dev/null @@ -1,28 +0,0 @@ -This is a release PR for version **%version%**. - -**Use squash merge.** -Upon merging, this will automatically build the CLI and create a GitHub release. -You still need to manually publish the cargo crate. - -``` -$ git pull -$ git checkout v%version% -$ cargo publish -``` - ---- - -_Edit release notes into the section below:_ - - -### Release notes - -_Binstall is a tool to fetch and install Rust-based executables as binaries. It aims to be a drop-in replacement for `cargo install` in most cases. Install it today with `cargo install cargo-binstall`, from the binaries below, or if you already have it, upgrade with `cargo binstall cargo-binstall`._ - -#### In this release: - -- - -#### Other changes: - -- diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index 1da166bb..09eaf88a 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -2,6 +2,17 @@ name: Open a release PR on: workflow_dispatch: inputs: + crate: + description: Crate to release + required: true + type: choice + options: + - bin + - lib + - detect-targets + - detect-wasi + - flock + - normalize-path version: description: Version to release required: true @@ -20,50 +31,10 @@ jobs: with: ref: main - - name: Extract info - run: | - set -euxo pipefail - - branch_name="release-${{ inputs.version }}" - echo "branch_name=${branch_name}" >> $GITHUB_ENV - - - name: Make release branch - run: git switch -c "${{ env.branch_name }}" - - - name: Do release - run: | - set -euxo pipefail - git config user.name github-actions - git config user.email github-actions@github.com - cargo release \ - --execute \ - --no-push \ - --no-tag \ - --no-publish \ - --no-confirm \ - --verbose \ - --config release.toml \ - --allow-branch "${{ env.branch_name }}" \ - --dependent-version upgrade \ - "${{ inputs.version }}" - - - name: Push new branch - run: | - set -euxo pipefail - git push origin "${{ env.branch_name }}" - - - name: Create PR - run: | - set -euxo pipefail - - nl=$'\n' - br=$'\n\n' - fence=$'```\n' - ecnef=$'\n```' - - title='release: v${{ inputs.version }}' - body=$(sed 's/%version%/${{ inputs.version }}/g' .github/scripts/release-pr.txt) - - gh pr create --title "$title" --body "$body" --base main --head "${{ env.branch_name }}" --label "release" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: cargo-bins/release-pr@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + version: ${{ inputs.version }} + crate-path: crates/${{ inputs.crate }} + pr-release-notes: true + pr-template-file: .github/scripts/release-pr-template.ejs