-
-
Notifications
You must be signed in to change notification settings - Fork 56
89 lines (76 loc) · 2.65 KB
/
release.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: release
on:
push:
branches:
- main
paths:
- "Cargo.toml"
- ".github/workflows/release.yml"
jobs:
git-tag:
runs-on: ubuntu-latest
steps:
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Checkout
uses: actions/checkout@v4
- name: Get releasing version
working-directory: .
run: echo NEXT_VERSION=$(sed -nE 's/^\s*version = "(.*?)"/\1/p' Cargo.toml) >> $GITHUB_ENV
- name: Check published version
run: echo PREV_VERSION=$(cargo search salvo --limit 1 | sed -nE 's/^[^"]*"//; s/".*//1p' -) >> $GITHUB_ENV
- name: Cancel run
if: env.NEXT_VERSION == env.PREV_VERSION
uses: andymckay/[email protected]
- name: Auto tag latest version
uses: bullrich/commit-autotag@main
if: env.NEXT_VERSION != env.PREV_VERSION
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
strategy: regex
root: Cargo.toml
regex_pattern: "version\\s*=\\s*\"([0-9\\.]+)\""
tag_prefix: "v"
version: "${{ env.NEXT_VERSION }}"
publish:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 1
matrix:
package:
- crate: engineioxide
path: engineioxide
- crate: socketioxide
path: socketioxide
steps:
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Checkout
uses: actions/checkout@v4
- name: Get releasing version
working-directory: ${{ matrix.package.path }}
run: echo NEXT_VERSION=$(sed -nE 's/^\s*version = "(.*?)"/\1/p' Cargo.toml) >> $GITHUB_ENV
- name: Check published version
run: echo PREV_VERSION=$(cargo search ${{ matrix.package.crate }} --limit 1 | sed -nE 's/^[^"]*"//; s/".*//1p' -) >> $GITHUB_ENV
- name: Cargo login
if: env.NEXT_VERSION != env.PREV_VERSION
run: cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Cargo package
if: env.NEXT_VERSION != env.PREV_VERSION
working-directory: ${{ matrix.package.path }}
run: |
echo "Releasing version: $NEXT_VERSION"
echo "Published version: $PREV_VERSION"
echo "Cargo Packaging..."
cargo package
- name: Publish ${{ matrix.package.name }}
if: env.NEXT_VERSION != env.PREV_VERSION
working-directory: ${{ matrix.package.path }}
run: |
echo "Cargo Publishing..."
cargo publish --no-verify
echo "New version of $NEXT_VERSION has been published"