name: Publish
on:
push:
tags:
- v*
env:
CARGO_TERM_COLOR: always
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
jobs:
publish:
name: Publish to crates.io
if: github.repository_owner == 'progdroid'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get Crate Version
id: crate-version
uses: colathro/crate-version@1.0.0
with:
file: "./Cargo.toml"
- name: Check Tag against Crate Version
if: ${{ format('v{0}', steps.crate-version.outputs.version) != github.ref_name }}
run: echo "crate_version ${{ steps.crate-version.outputs.version }} and tag ${{ github.ref_name }}" && exit 1
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}