Skip to content

Commit

Permalink
Add publish gh action for crates.io (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
sighol authored Aug 27, 2024
1 parent aef40b1 commit 640b050
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Publish

on:
push:
tags:
- v*

jobs:
version:
name: Version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check version
run: |
version=`cargo metadata | jq -r '.packages[] | select(.name == "${{ env.CRATE_NAME }}") | .version'`
version=v"${version}"
[ "${version}" ] && [ "${version}" == "${{ github.ref_name }}" ]
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy
- name: Run tests
run: cargo test --verbose

publish:
name: Publish
needs: [version, check]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Publish
uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}

0 comments on commit 640b050

Please sign in to comment.