Skip to content

update pkg version to update docs #3

update pkg version to update docs

update pkg version to update docs #3

Workflow file for this run

name: Release & Publish
on:
push:
branches: [main]
workflow_dispatch:
jobs:
ensure-doc:
name: Ensure documentation builds
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: IronCoreLabs/rust-toolchain@v1
with:
toolchain: nightly
- uses: dtolnay/install@cargo-docs-rs
- run: cargo docs-rs
release:
name: Release
runs-on: ubuntu-latest
needs: ensure-doc
steps:
- uses: actions/checkout@v4
- name: Retreive version from Cargo.toml
id: new-version
run: echo "version=$(grep -m1 version Cargo.toml | cut -d '"' -f2)" >> $GITHUB_OUTPUT
- name: Retreive version from Crates.io
id: old-version
# check exact repo name via api call since a crate named `exprs` exists and conflicts with this repo
run: |
VERSION=$(curl -s https://crates.io/api/v1/crates/${GITHUB_REPOSITORY#*/} | jq -r '.versions[0].num')
if [ "$VERSION" == "null" ]; then
echo "version=" >> $GITHUB_OUTPUT
else
echo "version=$VERSION" >> $GITHUB_OUTPUT
fi
- name: Compare versions
id: compare-versions
# if old-version is empty, then this is the first release
# else we compare the two versions
run: echo "should-release=$(if [ -z "${{ steps.old-version.outputs.version }}" ]; then echo true; else echo ${{ steps.new-version.outputs.version }} != ${{ steps.old-version.outputs.version }}; fi)" >> $GITHUB_OUTPUT
# if we are releasing, then can install rust and publish to crates.io
- name: Install Rust
if: steps.compare-versions.outputs.should-release == 'true'
uses: IronCoreLabs/rust-toolchain@v1
- name: Release
if: steps.compare-versions.outputs.should-release == 'true'
uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}