Adapt release workflow for workspace (#331)

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Félix Saparelli 2022-09-04 23:12:10 +12:00 committed by GitHub
parent f5a682ccce
commit e21617cc9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 33 additions and 20 deletions

View file

@ -2,5 +2,7 @@
set -euxo pipefail
message="$(head -n1 <<< "$COMMIT_MESSAGE")"
version="$(cut -d ' ' -f 2 <<< "${message}")"
crate="$(cut -d ' ' -f 2 <<< "${message}")"
version="$(cut -d ' ' -f 3 <<< "${message}")"
echo "::set-output name=crate::${crate}"
echo "::set-output name=version::${version}"

View file

@ -29,7 +29,7 @@ You will still need to manually publish the cargo crate:
```
$ git pull
$ git switch --detach v{version}
$ cargo publish
$ cargo publish -p <%= crate.name %>
```
<% if (pr.releaseNotes) { %>

View file

@ -36,5 +36,5 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ inputs.version }}
crate-path: crates/${{ inputs.crate }}
pr-release-notes: true
pr-release-notes: ${{ inputs.crate == 'bin' }}
pr-template-file: .github/scripts/release-pr-template.ejs

View file

@ -9,9 +9,10 @@ on:
jobs:
info:
runs-on: ubuntu-latest
# the commit message will look like: `release: v{version} (#{pr-number})`
if: "startsWith(github.event.head_commit.message, 'release: v')"
# the commit message will look like: `release: {crate-name} v{version} (#{pr-number})`
if: "startsWith(github.event.head_commit.message, 'release: ')"
outputs:
crate: ${{ steps.version.outputs.crate }}
version: ${{ steps.version.outputs.version }}
notes: ${{ fromJSON(steps.notes.outputs.notes_json) }}
env:
@ -33,7 +34,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Push release tag
- name: Push lib release tag
if: "! startsWith(github.event.head_commit.message, 'release: cargo-binstall v')"
uses: mathieudutour/github-tag-action@v6.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ needs.info.outputs.version }}
tag_prefix: ${{ needs.info.outputs.crate }}-
- name: Push cli release tag
if: "startsWith(github.event.head_commit.message, 'release: cargo-binstall v')"
uses: mathieudutour/github-tag-action@v6.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
@ -41,12 +50,14 @@ jobs:
tag_prefix: ''
build:
if: "startsWith(github.event.head_commit.message, 'release: cargo-binstall v')"
needs: info # not really, but just so it fails fast
uses: ./.github/workflows/build.yml
with:
for_release: true
release:
if: "startsWith(github.event.head_commit.message, 'release: cargo-binstall v')"
needs:
- info
- tag