Skip to content

Commit

Permalink
build: add publish workflow (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
neoeinstein authored Apr 12, 2024
1 parent 5582b54 commit 1028b9b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: release

on:
push:
tags:
- "*-v*"

env:
CARGO_TERM_COLOR: always

jobs:
release:
name: Publish Release ${{ github.ref_name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Stable Rust Toolchain
uses: dtolnay/rust-toolchain@stable
- id: parse-tag
name: Verify tag matches cargo manifest
run: |
REF_CRATE=$(echo ${{ github.ref_name }} | cut -d '-' -f 1)
echo "crate=${REF_CRATE}" >> "$GITHUB_OUTPUT"
REF_VERSION=$(echo ${{ github.ref_name }} | cut -d '-' -f 2-)
VERSION=$(cargo read-manifest --manifest-path ${REF_CRATE}/Cargo.toml | jq -r .version)
if [ "${REF_VERSION}" != "v${VERSION}" ]; then
echo "::error::Tag name ${{ github.ref_name }} doesn't match the version in Cargo.toml (${VERSION})";
exit 1;
fi
shell: bash
- name: Publish Rust crate
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
CARGO_PUBLISH_TIMEOUT: '0'
run: cargo publish -p ${{ steps.parse-tag.outputs.crate }}
shell: bash

0 comments on commit 1028b9b

Please sign in to comment.