-
-
Notifications
You must be signed in to change notification settings - Fork 8
35 lines (26 loc) · 876 Bytes
/
cargo-publish.yml
File metadata and controls
35 lines (26 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
name: Cargo Publish
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Extract versions
id: versions
run: |
TAG="${GITHUB_REF_NAME}" # v0.1.2
TAG_VER="${TAG#v}"
CARGO_VER=$(grep '^version' Cargo.toml | head -1 | cut -d'"' -f2)
echo "tag_ver=$TAG_VER" >> $GITHUB_OUTPUT
echo "cargo_ver=$CARGO_VER" >> $GITHUB_OUTPUT
- name: Verify tag matches Cargo.toml
run: |
test "${{ steps.versions.outputs.tag_ver }}" = "${{ steps.versions.outputs.cargo_ver }}"
- name: Cargo login
run: cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish to crates.io
run: cargo publish --locked