Merge pull request #2 from evervault/donal/spe-831-add-metadate-to-ca… #2
Workflow file for this run
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: Release rust crate | |
on: | |
push: | |
tags: | |
- "rust/v*" | |
jobs: | |
get-version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.get-version.outputs.version }} | |
steps: | |
- name: Get version from tag | |
id: get-version | |
run: | | |
echo "using version tag ${GITHUB_REF:16}" | |
assert-matching-version: | |
runs-on: ubuntu-latest | |
needs: [get-version] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
components: rustfmt, clippy | |
- name: Ensure version of crate matches release | |
id: get-cargo-version | |
run: | | |
CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | jq '.packages[] | select( .name == "storage-client-interface" ) | .version' | tr -d '"') | |
if [ "$CARGO_VERSION" != "${GITHUB_REF:16}" ]; then | |
echo "Version in tag does not match cargo.toml" | |
echo "Expected $CARGO_VERSION, Found ${GITHUB_REF:16}" | |
exit 1 | |
fi | |
dry-run-publish: | |
runs-on: ubuntu-latest | |
needs: [get-version, assert-matching-version] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
components: rustfmt, clippy | |
- uses: davidB/rust-cargo-make@10579dcff82285736fad5291533b52d3c93d6b3b | |
- name: Package and Publish Cargo to registry | |
run: | | |
cargo publish --dry-run --token ${{ secrets.CARGO_AUTH_TOKEN }} | |
publish-crate: | |
runs-on: ubuntu-latest | |
environment: public-release | |
needs: [get-version, assert-matching-version, dry-run-publish] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
components: rustfmt, clippy | |
- uses: davidB/rust-cargo-make@10579dcff82285736fad5291533b52d3c93d6b3b | |
- name: Package and Publish Cargo to registry | |
run: | | |
cargo publish --token ${{ secrets.CARGO_AUTH_TOKEN }} |