-
-
Notifications
You must be signed in to change notification settings - Fork 3
170 lines (131 loc) · 4.1 KB
/
main.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Main Workflow
on:
push:
branches:
- "**"
tags:
- "v0.*"
- "v1.*"
pull_request:
branches:
- "**"
jobs:
check_pkg:
name: Check Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Clone repository
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Check Package
run: cargo check
test_pkg:
needs: [check_pkg]
name: Test Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Clone repository
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Test Package
run: cargo test --all-features
lint_pkg:
needs: [check_pkg]
name: Lint Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Clone repository
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Check Package Format
run: cargo fmt --all -- --check
- name: Lint Package
run: cargo clippy --all-features
crates_publish:
needs: [lint_pkg, test_pkg]
name: Publish Cargo Package
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Clone repository
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Login to crates.io
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish Package
run: cargo publish
github_release:
needs: [crates_publish]
name: Publish GitHub Release
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
rs_target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
include:
- rs_target: x86_64-unknown-linux-gnu
os: ubuntu-latest
pkg_name: tivilsta-x86_64-unknown-linux-gnu.tar.gz
- rs_target: x86_64-unknown-linux-musl
os: ubuntu-latest
pkg_name: tivilsta-x86_64-unknown-linux-musl.tar.gz
- rs_target: x86_64-apple-darwin
os: macOS-latest
pkg_name: tivilsta-x86_64-apple-darwin.tar.gz
- rs_target: x86_64-pc-windows-msvc
os: windows-latest
pkg_name: tivilsta-x86_64-pc-windows-msvc.zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
name: Clone repository
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rs_target }}
- name: Install APT dependencies.
if: matrix.rs_target == 'x86_64-unknown-linux-musl'
run: |
apt update
apt install -y libssl-dev
apt install -y musl-tools
- name: Build for target
run: cargo build --release --target ${{ matrix.rs_target }}
- name: Prepare build artifacts for Windows
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.rs_target }}/release
strip tivilsta.exe
7z a ../../../${{ matrix.pkg_name }} tivilsta.exe
cd -
- name: Prepare build artifacts for Mac/Linux
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.rs_target }}/release
strip tivilsta
tar czvf ../../../${{ matrix.pkg_name }} tivilsta
cd -
- name: Create Release Note
if: matrix.os == 'ubuntu-latest'
run: |
previousTag=$(git tag --sort=-creatordate | head -n 2 | tail -n 1)
if [[ -z "${previousTag}" ]]
then
git log --graph --decorate --pretty=format:"%h %d %s (@%aN)" > RELEASE.md
else
git log ${previousTag}..HEAD --graph --decorate --pretty=format:"%h %d %s (@%aN)" > RELEASE.md
fi
- name: Publish GitHub Release for ${{ matrix.rs_target }}
uses: softprops/action-gh-release@v1
with:
files: target/**/release/*
body_path: RELEASE.md