-
Notifications
You must be signed in to change notification settings - Fork 2
39 lines (33 loc) · 1017 Bytes
/
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
name: Publish to crates.io
on:
push:
branches:
- main
paths:
- "Cargo.toml"
jobs:
publish:
runs-on: [self-hosted, linux]
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Check for version changes
id: check_version
run: |
old_version=$(git show HEAD~1:Cargo.toml | grep '^version =' | sed 's/version = "\(.*\)"/\1/')
new_version=$(grep '^version =' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
echo "Old version: $old_version"
echo "New version: $new_version"
if [ "$old_version" = "$new_version" ]; then
echo "Version has not changed. Skipping publish."
exit 0
fi
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}