cargo-binstall/.github/workflows/release.yml
Jiahao XU abecd9ae14
ci: Publish to crates.io in release.yml after tagging (#1152)
Fixed #1046

so that we don't have to manually run `cargo-publish` after the CI is
merged.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-06-21 10:04:09 +00:00

65 lines
1.8 KiB
YAML

name: On release
on:
pull_request:
types: closed
branches: [main] # target branch of release PRs
jobs:
info:
if: github.event.pull_request.merged
outputs:
is-release: ${{ steps.meta.outputs.is-release }}
crate: ${{ steps.meta.outputs.crates-names }}
version: ${{ steps.meta.outputs.version-actual }}
notes: ${{ steps.meta.outputs.notes }}
runs-on: ubuntu-latest
steps:
- id: meta
uses: cargo-bins/release-meta@v1
with:
event-data: ${{ toJSON(github.event) }}
extract-notes-under: '### Release notes'
test:
if: needs.info.outputs.is-release == 'true'
needs: info
uses: ./.github/workflows/ci.yml
tag:
if: needs.info.outputs.is-release == 'true'
needs:
- info
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Push lib release tag
if: needs.info.outputs.crate != 'cargo-binstall'
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ needs.info.outputs.version }}
tag_prefix: ${{ needs.info.outputs.crate }}-v
- name: Push cli release tag
if: needs.info.outputs.crate == 'cargo-binstall'
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ needs.info.outputs.version }}
tag_prefix: v
- name: Publish to crates.io
run: |
cargo publish --no-verify -p '${{ needs.info.outputs.crate }}'
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
package:
if: needs.info.outputs.is-release == 'true' && needs.info.outputs.crate == 'cargo-binstall'
needs:
- info
- tag
uses: ./.github/workflows/release-build.yml
with:
publish: ${{ toJSON(needs.info.outputs) }}