-
Notifications
You must be signed in to change notification settings - Fork 1
64 lines (59 loc) · 1.87 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
63
64
name: Publish Package
on:
push:
tags:
- '*'
jobs:
publish:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Get current version
id: cv
run: |
curr_vers=$(cargo pkgid | awk -F'#' '{ print $2 }')
echo "Curr_Vers=${curr_vers}"
echo ::set-output name=curr_version::${curr_vers}
- name: Get current tag
id: git
run: |
if git rev-parse --verify --quiet refs/tags/HEAD > /dev/null
then
curr_tag=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "Curr_Tag=${curr_tag}"
echo ::set-output name=curr_tag::${curr_tag}
else
echo "No git tags found. Please create a git tag."
exit 1
fi
- name: Get last tag
id: gitlast
run: |
last_tag=$(git describe --tags $(git rev-list --tags --max-count=2 | tail -1))
echo "Last_Tag=${last_tag}"
echo ::set-output name=last_tag::${last_tag}
- name: Check version and tag
run: |
curr_tag="${{ steps.git.outputs.curr_tag }}"
curr_ver="${{ steps.cv.outputs.curr_version }}"
last_tag="${{ steps.gitlast.outputs.last_tag }}"
if [ $curr_tag != $curr_ver ]
then
echo "Current version and tag do not match!"
exit 1
fi
if [[ $(printf '%s\n' "$last_tag" "$curr_tag" | sort -V | tail -n 1) != $curr_tag ]]
then
echo "Current tag is not newer than the last tag!"
exit 1
fi
- name: Publish to crates.io
uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CRATES_TOKEN }}