-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (42 loc) · 1.4 KB
/
publish_crate.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
name: Publish to Crates
on:
push:
tags:
- "*.*.*"
jobs:
update_and_publish:
name: Update Cargo.toml Version and Publish to Crates
runs-on: ubuntu-latest
environment: crates
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Pull changes
run: git pull origin main
- name: Set up Rust
uses: moonrepo/setup-rust@v1
- name: Format Code
run: cargo fmt --all
- name: Lint Code
run: cargo clippy --all -- -D warnings
- name: Update Cargo.toml Version
run: |
VERSION=$(echo "${GITHUB_REF#refs/tags/}")
sed -i'' -e "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
if ! git diff --quiet; then
git commit -am "Bump version to $VERSION"
else
echo "No changes to commit"
fi
- name: Pull changes
run: git pull origin main
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Cargo and Publish
run: cargo publish --token ${CRATES_TOKEN}
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}