Publish crate to crates.io #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish crate to crates.io | |
on: | |
workflow_call: | |
secrets: | |
CRATES_IO_TOKEN: | |
description: crates.io token | |
required: true | |
workflow_dispatch: | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Publish lib to crates.io if it is not published | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | |
run: | | |
crate_name="tinted-builder" | |
version="$(cargo read-manifest --manifest-path ./tinted-builder/Cargo.toml | jq -r ".version")" | |
response=$(curl -s "https://crates.io/api/v1/crates/$crate_name") | |
if ! echo "$response" | grep -q "\"num\":\"$version\""; then | |
cargo publish -p tinted-builder --locked | |
fi | |
- name: Publish cli to crates.io | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | |
run: cargo publish -p tinted-builder-rust --locked |