cargo-binstall/.github/workflows/release-cli.yml
Jiahao XU 4599a70839
Fix CI: Dry-run cargo-publish on crate to be published (#1490)
* Fix CI: Dry-run `cargo-publish` on crate to be published

If there's no crate to publish, do not dry-run `cargo-publish`.

Only dry-run `cargo-publish` on crate to be published to avoid
`cargo-publish` error on `cargo-binstall` when one of its direct
dependencies is bumped.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix passing of crate to `release-cli.yml`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix passing of `needs.pr-info.outpus.crate`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix `release-dry-run`: Only run if is release or is not PR event

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix passing of crate

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Rm `just-setup` from `release-cli.yml` since it cannot be cached

release is trigged by the closing of PR, so the cache is saved under the
branch `release/*` which cannot be reused.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix dry-run publish

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-11-11 14:17:16 +00:00

125 lines
3.7 KiB
YAML

name: Release CLI
on:
workflow_call:
inputs:
info:
description: "The release metadata JSON"
required: true
type: string
CARGO_PROFILE_RELEASE_LTO:
description: "Used to speed up CI"
required: false
type: string
CARGO_PROFILE_RELEASE_CODEGEN_UNITS:
description: "Used to speed up CI"
required: false
type: string
jobs:
tag:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- if: fromJSON(inputs.info).is-release == 'true'
name: Push cli release tag
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ fromJSON(inputs.info).version }}
tag_prefix: v
keygen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cargo-bins/cargo-binstall@main
- name: Install binaries required
run: cargo binstall -y --force rsign2 rage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create ephemeral keypair
id: keypair
env:
AGE_KEY_PUBLIC: ${{ vars.AGE_KEY_PUBLIC }}
run: .github/scripts/ephemeral-gen.sh
- uses: actions/upload-artifact@v3
with:
name: minisign.pub
path: minisign.pub
- uses: actions/upload-artifact@v3
with:
name: minisign.key.age
path: minisign.key.age
retention-days: 1
- name: Check that key can be decrypted
env:
AGE_KEY_SECRET: ${{ secrets.AGE_KEY_SECRET }}
shell: bash
run: .github/scripts/ephemeral-sign.sh minisign.pub
package:
needs:
- tag
- keygen
uses: ./.github/workflows/release-packages.yml
secrets: inherit
with:
publish: ${{ inputs.info }}
CARGO_PROFILE_RELEASE_LTO: ${{ inputs.CARGO_PROFILE_RELEASE_LTO }}
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: ${{ inputs.CARGO_PROFILE_RELEASE_CODEGEN_UNITS }}
publish:
needs: package
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: minisign.pub
- run: .github/scripts/ephemeral-crate.sh
- if: fromJSON(inputs.info).is-release != 'true' && fromJSON(inputs.info).crate != ''
name: DRY-RUN Publish to crates.io
env:
crate: ${{ fromJSON(inputs.info).crate }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --dry-run -p "$crate" --allow-dirty --no-default-features
- if: fromJSON(inputs.info).is-release != 'true' && fromJSON(inputs.info).crate != ''
name: Upload crate package as artifact
uses: actions/upload-artifact@v3
with:
name: crate-package
path: target/package/*.crate
- if: fromJSON(inputs.info).is-release == 'true'
name: Publish to crates.io
env:
crate: ${{ fromJSON(inputs.info).crate }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish -p "$crate" --allow-dirty --no-default-features
- if: fromJSON(inputs.info).is-release == 'true'
name: Make release latest
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
release_name: v${{ fromJSON(inputs.info).version }}
tag: v${{ fromJSON(inputs.info).version }}
body: ${{ fromJSON(inputs.info).notes }}
promote: true
file: minisign.pub
- if: fromJSON(inputs.info).is-release == 'true'
name: Delete signing key artifact
uses: geekyeggo/delete-artifact@v2
with:
name: minisign.key.age
failOnError: false