Skip to content

Commit f6f6397

Browse files
authored
chore(ci): add release pipeline (#239)
1 parent 43af429 commit f6f6397

File tree

2 files changed

+85
-2
lines changed

2 files changed

+85
-2
lines changed

.github/workflows/github-ci.yml

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
tags:
8-
- v*
97
pull_request:
108
branches:
119
- main

.github/workflows/release.yml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: release
2+
on:
3+
push:
4+
branches:
5+
- release
6+
paths:
7+
- "**/Cargo.toml"
8+
- ".github/workflows/release.yml"
9+
10+
jobs:
11+
git-tag:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: dtolnay/rust-toolchain@stable
15+
with:
16+
components: rustfmt, clippy
17+
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Get releasing version
22+
working-directory: .
23+
run: echo NEXT_VERSION=$(sed -nE 's/^\s*version = "(.*?)"/\1/p' Cargo.toml) >> $GITHUB_ENV
24+
25+
- name: Check published version
26+
run: echo PREV_VERSION=$(cargo search salvo --limit 1 | sed -nE 's/^[^"]*"//; s/".*//1p' -) >> $GITHUB_ENV
27+
28+
- name: Auto tag latest version
29+
uses: bullrich/commit-autotag@main
30+
if: env.NEXT_VERSION != env.PREV_VERSION
31+
env:
32+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
33+
with:
34+
strategy: regex
35+
root: Cargo.toml
36+
regex_pattern: "version\\s*=\\s*\"([0-9\\.]+)\""
37+
tag_prefix: "v"
38+
# version: "${{ env.NEXT_VERSION }}"
39+
40+
publish:
41+
runs-on: ubuntu-latest
42+
strategy:
43+
fail-fast: false
44+
max-parallel: 1
45+
matrix:
46+
package:
47+
- crate: socketioxide
48+
path: socketioxide
49+
- crate: engineioxide
50+
path: engineioxide
51+
steps:
52+
- uses: dtolnay/rust-toolchain@stable
53+
with:
54+
components: rustfmt, clippy
55+
56+
- name: Checkout
57+
uses: actions/checkout@v4
58+
59+
- name: Get releasing version
60+
working-directory: ${{ matrix.package.path }}
61+
run: echo NEXT_VERSION=$(sed -nE 's/^\s*version = "(.*?)"/\1/p' Cargo.toml) >> $GITHUB_ENV
62+
63+
- name: Check published version
64+
run: echo PREV_VERSION=$(cargo search ${{ matrix.package.crate }} --limit 1 | sed -nE 's/^[^"]*"//; s/".*//1p' -) >> $GITHUB_ENV
65+
66+
- name: Cargo login
67+
if: env.NEXT_VERSION != env.PREV_VERSION
68+
run: cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }}
69+
70+
- name: Cargo package
71+
if: env.NEXT_VERSION != env.PREV_VERSION
72+
working-directory: ${{ matrix.package.path }}
73+
run: |
74+
echo "Releasing version: $NEXT_VERSION"
75+
echo "Published version: $PREV_VERSION"
76+
echo "Cargo Packaging..."
77+
cargo package
78+
79+
- name: Publish ${{ matrix.package.name }}
80+
if: env.NEXT_VERSION != env.PREV_VERSION
81+
working-directory: ${{ matrix.package.path }}
82+
run: |
83+
echo "Cargo Publishing..."
84+
cargo publish --no-verify
85+
echo "New version $NEXT_VERSION has been published"

0 commit comments

Comments
 (0)