-
Notifications
You must be signed in to change notification settings - Fork 33
50 lines (49 loc) · 1.49 KB
/
publish.yml
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
47
48
49
50
name: Publish
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
check:
uses: nalexpear/tracing-stackdriver/.github/workflows/check.yml@master
secrets: inherit
semver:
needs: check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2
with:
feature-group: all-features
publish:
needs: semver
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: ⚡ Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Extract release version
run: echo -n "cargo_version=v$(cargo pkgid | cut -d '#' -f2)" >> $GITHUB_ENV
- name: Check release version
if: '${{ env.cargo_version != github.ref_name }}'
uses: actions/github-script@v3
with:
script: |
core.setFailed('Tagged version ${{ github.ref_name }} does not match Cargo version v${{ env.cargo_version }}')
- name: Publish the new version
run: cargo publish --token ${CRATES_TOKEN}
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}