Skip to content

Publish crate to crates.io #3

Publish crate to crates.io

Publish crate to crates.io #3

Workflow file for this run

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