Skip to content

Commit

Permalink
Update the release PR workflow & add a release-it workflow, too
Browse files Browse the repository at this point in the history
Now the workflow for releasing this crate is:

1. Trigger the "Create release PR" workflow with the right version,
2. fix up anything in the release PR (e.g. changelog)
3. squash&merge that PR
4. Another workflow triggers that will tag the release & publish to
   crates.io at the version just released.
  • Loading branch information
antifuchs committed Feb 16, 2024
1 parent 72cbbdd commit 04dc9ac
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/release_it.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Cut a new release
on:
pull_request:
types:
- closed

jobs:
tag_github_release:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')

permissions:
id-token: write # Enable OIDC
contents: write

runs-on: ubuntu-latest
steps:
- run: echo merge commit is $GITHUB_SHA, from PR branch ${{ github.event.pull_request.head.ref }}
- uses: actions-ecosystem/action-regex-match@v2
id: version
with:
text: ${{ github.event.pull_request.head.ref }}
regex: "^release/([^/]+)/(.+)$"
# Name of crate is steps.version.outputs.group1, version is steps.version.outputs.group2.
# TODO: figure out how this works with workspaces & multiple crates

- name: Create release v${{steps.version.outputs.group2}}
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.version.outputs.group2 }}
name: ${{steps.version.outputs.group1}} v${{ steps.version.outputs.group2 }}
target_commitish: ${{github.sha}}

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

- run: cargo publish --token ${CRATES_TOKEN}
env:
CRATES_TOKEN: ${{ secrets.CRATESIO_RELEASE_TOKEN }}
20 changes: 18 additions & 2 deletions .github/workflows/release_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,31 @@ jobs:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: chainguard-dev/actions/setup-gitsign@main
- name: Install cargo-release
uses: taiki-e/install-action@v1
uses: taiki-e/cache-cargo-install-action@v1
with:
tool: cargo-release
- name: Install cargo-semver-checks
uses: taiki-e/cache-cargo-install-action@v1
with:
tool: cargo-semver-checks

- uses: cargo-bins/release-pr@v2
id: pr
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ inputs.version }}
check-semver: true
crate-release-all: true # all in workspace
- uses: actions-ecosystem/action-regex-match@v2
id: pr-id
with:
text: ${{ steps.pr.outputs.pr-url }}
regex: "/pull/([0-9]+)$"
- uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: release
number: ${{ steps.pr-id.outputs.group1 }}

0 comments on commit 04dc9ac

Please sign in to comment.