-
Notifications
You must be signed in to change notification settings - Fork 20
46 lines (39 loc) · 1.2 KB
/
release_rust.yaml
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
36
37
38
39
40
41
42
43
44
45
46
name: Release Rust Package
on:
release:
types:
- created
jobs:
release-rust:
name: Build and publish on crates.io
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Bump Cargo version
run: |
python ./.github/scripts/cargo_version_bumper.py --target Cargo.toml "${{ github.ref_name }}"
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: Cache Cargo dependencies
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check Cargo.toml version matches Release tag
run: |
CARGO_VERSION=$(grep '^version =' Cargo.toml | sed 's/.*"\(.*\)".*/\1/')
if [ "${GITHUB_REF#refs/tags/}" != "$CARGO_VERSION" ]; then
echo "Version mismatch: Cargo.toml ($CARGO_VERSION) doesn't match Release tag (${GITHUB_REF#refs/tags/})"
exit 1
fi
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish