name: Check for new version
on:
push:
branches:
- main
jobs:
check-new-tag:
runs-on: ubuntu-latest
permissions:
contents: write
actions: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version from Cargo.toml
id: get_version
run: |
# Try to get version from Cargo.toml first
if [ -f "Cargo.toml" ]; then
VERSION=$(grep '^version =' Cargo.toml | cut -d'"' -f2)
else
echo "No Cargo.toml found to determine version"
exit 1
fi
# make sure we have a version
if [ -z "$VERSION" ]; then
echo "No version found in Cargo.toml"
exit 1
fi
# We have a version, the tag has a 'v' prefix
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
echo "Detected version: $VERSION"
- name: Check if the release already exists
uses: insightsengineering/release-existence-action@v1
id: check_release
with:
release-tag: '${{ steps.get_version.outputs.tag }}'
outputs:
release_exists: ${{ steps.check_release.outputs.release-exists }}
version: ${{ steps.get_version.outputs.version }}
tag: ${{ steps.get_version.outputs.tag }}
call-create-lib-release:
name: Call create-lib-release workflow
needs: check-new-tag
if: needs.check-new-tag.outputs.release_exists == 'false'
uses: holtjma/shared_github_workflows/.github/workflows/create-lib-release.yml@v0.7.0
permissions:
contents: write
with:
release_name: 'rust-lib-reference-genome'
tag: ${{ needs.check-new-tag.outputs.tag }}
rust_version: 1.98.0
test_docs: true
publish-to-crates-io:
name: Publish to Crates.io
needs: [check-new-tag, call-create-lib-release]
if: needs.check-new-tag.outputs.release_exists == 'false'
runs-on: ubuntu-latest
container:
image: rust:1.98.0
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Publish to Crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}