-
-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (52 loc) · 1.94 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
51
52
53
54
55
56
57
58
59
60
61
62
name: Release & Publish
on:
push:
branches: [main]
workflow_dispatch:
jobs:
ensure-doc:
name: Ensure documentation builds
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
submodules: true
- uses: IronCoreLabs/rust-toolchain@v1
with:
toolchain: nightly
- uses: dtolnay/install@cargo-docs-rs
- run: cargo docs-rs
release:
name: Release
runs-on: ubuntu-latest
needs: ensure-doc
steps:
- uses: actions/[email protected]
with:
submodules: true
- name: Retreive version from Cargo.toml
id: new-version
run: echo "version=$(grep -m1 version Cargo.toml | cut -d '"' -f2)" >> $GITHUB_OUTPUT
- name: Retreive version from Crates.io
id: old-version
run: |
VERSION=$(curl -s https://crates.io/api/v1/crates/${GITHUB_REPOSITORY#*/} | jq -r '.versions[0].num')
if [ "$VERSION" == "null" ]; then
echo "version=" >> $GITHUB_OUTPUT
else
echo "version=$VERSION" >> $GITHUB_OUTPUT
fi
- name: Compare versions
id: compare-versions
# if old-version is empty, then this is the first release
# else we compare the two versions
run: echo "should-release=$(if [ -z "${{ steps.old-version.outputs.version }}" ]; then echo true; else if [ "${{ steps.old-version.outputs.version }}" != "${{ steps.new-version.outputs.version }}" ]; then echo true; else echo false; fi; fi)" >> $GITHUB_OUTPUT
# if we are releasing, then can install rust and publish to crates.io
- name: Install Rust
if: steps.compare-versions.outputs.should-release == 'true'
uses: IronCoreLabs/rust-toolchain@v1
- name: Release
if: steps.compare-versions.outputs.should-release == 'true'
uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}