-
Notifications
You must be signed in to change notification settings - Fork 6
302 lines (291 loc) · 10.8 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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
name: Release
on:
push:
tags:
- 'v*'
env:
RUSTFLAGS: -D warnings -W unreachable-pub -W rust-2021-compatibility
RUSTUP_MAX_RETRIES: 10
CARGO_INCREMENTAL: 0
defaults:
run:
shell: bash
jobs:
version:
name: Version
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.version.outputs.VERSION }}
steps:
- id: version
run: |
echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT
linux-releases:
needs: version
name: Linux (${{ matrix.target.triple }}, glibc${{ matrix.target.glibc }})
runs-on: ubuntu-latest
strategy:
matrix:
target:
- { image: "ubuntu:22.04", triple: x86_64-unknown-linux-gnu, glibc: 2.35 }
- { image: "ubuntu:20.04", triple: x86_64-unknown-linux-gnu, glibc: 2.31 }
- { image: "debian:10", triple: x86_64-unknown-linux-gnu, glibc: 2.28 }
# - { image: "centos:centos7", triple: x86_64-unknown-linux-gnu, glibc: 2.17 }
container:
image: ${{ matrix.target.image }}
steps:
- name: "Print glibc version"
run: ldd --version
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
key: ${{ runner.os }}-cargo-stable-${{ matrix.target.triple }}-glibc${{ matrix.target.glibc }}-${{ hashFiles('**/Cargo.toml') }}
path: |
~/.cargo/bin/
~/.cargo/git/db/
~/.cargo/registry/cache/
~/.cargo/registry/index/
target/
- name: "Install packages (Ubuntu)"
if: ${{ startsWith(matrix.target.image, 'ubuntu') }}
run: apt-get update && apt-get install curl build-essential -y
- name: "Install packages (Debian)"
if: ${{ startsWith(matrix.target.image, 'debian') }}
run: apt-get update && apt-get install curl build-essential -y
- name: "Install packages (CentOS)"
if: ${{ startsWith(matrix.target.image, 'centos') }}
run: yum install gcc -y
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: ${{ matrix.target.triple }}
- name: "Run prepare tests"
run: ci/prepare-tests.sh
- run: |
cargo build --release --workspace
cargo test --release --workspace
- name: "Strip release binary"
run: |
# strip target/release/pica-lint
strip target/release/pica
- name: "Build release archive"
id: build-archive
shell: bash
run: |
staging="pica-${{ needs.version.outputs.VERSION }}-${{ matrix.target.triple }}-glibc${{ matrix.target.glibc }}"
mkdir "$staging"
cp README.md LICENSE UNLICENSE "$staging/"
cp "target/release/pica" "$staging/"
./target/release/pica completions bash > "$staging/pica.bash"
./target/release/pica completions fish > "$staging/pica.fish"
./target/release/pica completions zsh > "$staging/pica.zsh"
tar cfvz "$staging.tar.gz" "$staging/"
echo "filename=$staging.tar.gz" >> $GITHUB_OUTPUT
echo "ASSET_PATH=$staging.tar.gz" >> $GITHUB_ENV
- uses: actions/upload-artifact@v3
with:
name: ${{ env.ASSET_PATH }}
path: ${{ env.ASSET_PATH }}
retention-days: 5
windows-releases:
needs: version
name: Windows (${{matrix.target.triple}})
runs-on: windows-latest
strategy:
matrix:
target:
- { triple: x86_64-pc-windows-msvc, variant: "MSVC" }
- { triple: x86_64-pc-windows-gnu, variant: "GNU" }
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
key: ${{ runner.os }}-cargo-stable-${{ matrix.target.triple }}-${{ hashFiles('**/Cargo.toml') }}
path: |
~/.cargo/bin/
~/.cargo/git/db/
~/.cargo/registry/cache/
~/.cargo/registry/index/
target/
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: ${{ matrix.target.triple }}
- name: "Run prepare tests"
run: ci/prepare-tests.sh
- run: |
cargo build --release --workspace
cargo test --release --workspace
- name: "Build release archive"
id: build-archive
shell: bash
run: |
staging="pica-${{ needs.version.outputs.VERSION }}-${{ matrix.target.triple }}"
mkdir "$staging"
cp README.md LICENSE UNLICENSE "$staging/"
cp "target/release/pica.exe" "$staging/"
cp "target/release/pica-lint.exe" "$staging/"
7z a "$staging.zip" "$staging/"
echo "ASSET_PATH=$staging.zip" >> $GITHUB_ENV
- uses: actions/upload-artifact@v3
with:
name: ${{ env.ASSET_PATH }}
path: ${{ env.ASSET_PATH }}
retention-days: 5
macos-releases:
name: macOS (${{ matrix.target.triple }})
needs: version
runs-on: macos-latest
strategy:
matrix:
target:
- { triple: x86_64-apple-darwin }
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
key: ${{ runner.os }}-cargo-stable-${{ matrix.target.triple }}-${{ hashFiles('**/Cargo.toml') }}
path: |
~/.cargo/bin/
~/.cargo/git/db/
~/.cargo/registry/cache/
~/.cargo/registry/index/
target/
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: ${{ matrix.target.triple }}
- name: "Run prepare tests"
run: ci/prepare-tests.sh
- run: |
cargo build --release --workspace
cargo test --release --workspace
- name: "Strip release binary"
run: |
strip target/release/pica-lint
strip target/release/pica
- name: "Build release archive"
shell: bash
run: |
staging="pica-${{ needs.version.outputs.VERSION }}-${{ matrix.target.triple }}"
mkdir "$staging"
cp README.md LICENSE UNLICENSE "$staging/"
cp "target/release/pica-lint" "$staging/"
cp "target/release/pica" "$staging/"
tar cfvz "$staging.tar.gz" "$staging/"
echo "ASSET_PATH=$staging.tar.gz" >> $GITHUB_ENV
- uses: actions/upload-artifact@v3
with:
name: ${{ env.ASSET_PATH }}
path: ${{ env.ASSET_PATH }}
retention-days: 5
packages:
needs: [linux-releases, version]
name: Package (${{ matrix.target.format }}, glibc${{ matrix.target.glibc }})
runs-on: ubuntu-latest
strategy:
matrix:
target:
# - { triple: x86_64-unknown-linux-gnu, glibc: 2.17, format: deb }
# - { triple: x86_64-unknown-linux-gnu, glibc: 2.17, format: rpm }
- { triple: x86_64-unknown-linux-gnu, glibc: 2.28, format: deb }
- { triple: x86_64-unknown-linux-gnu, glibc: 2.28, format: rpm }
- { triple: x86_64-unknown-linux-gnu, glibc: 2.31, format: deb }
- { triple: x86_64-unknown-linux-gnu, glibc: 2.31, format: rpm }
- { triple: x86_64-unknown-linux-gnu, glibc: 2.35, format: deb }
- { triple: x86_64-unknown-linux-gnu, glibc: 2.35, format: rpm }
steps:
- uses: actions/checkout@v4
- name: Download binary release
uses: actions/download-artifact@v3
with:
name: pica-${{ needs.version.outputs.VERSION }}-${{ matrix.target.triple }}-glibc${{ matrix.target.glibc }}.tar.gz
- name: Extract binary release
run: |
tar xfvz pica-${{ needs.version.outputs.VERSION }}-${{ matrix.target.triple }}-glibc${{ matrix.target.glibc }}.tar.gz --strip-components=1
- name: Build package
uses: kentik/pkg@master
id: build_rpm
with:
name: pica
version: ${{ needs.version.outputs.VERSION }}-glibc${{ matrix.target.glibc }}
arch: x86_64
format: ${{ matrix.target.format }}
package: .github/actions-rs/package.yaml
- uses: actions/upload-artifact@v3
with:
name: ${{ steps.build_rpm.outputs.package }}
path: ${{ steps.build_rpm.outputs.package }}
retention-days: 5
check:
name: Test Packages (${{ matrix.target.name }})
needs: [packages, version]
runs-on: ubuntu-latest
container: ${{ matrix.target.image }}
strategy:
matrix:
target:
- { name: "Debian 11", image: "debian:11", glibc: 2.31 }
- { name: "Debian 10", image: "debian:10", glibc: 2.28 }
- { name: "Ubuntu 22.04", image: "ubuntu:22.04", glibc: 2.35 }
- { name: "Ubuntu 21.10", image: "ubuntu:21.10", glibc: 2.35 }
- { name: "Ubuntu 20.04", image: "ubuntu:20.04", glibc: 2.31 }
# - { name: "CentOS 7", image: "centos:7", glibc: 2.17 }
- { name: "CentOS 8", image: "centos:8", glibc: 2.28 }
steps:
- name: "Download Package (DEB)"
if: ${{ !startsWith(matrix.target.name, 'CentOS') }}
uses: actions/download-artifact@v3
with:
name: pica_${{ needs.version.outputs.VERSION }}-glibc${{ matrix.target.glibc}}-1_amd64.deb
- name: "Download Package (RPM)"
if: ${{ startsWith(matrix.target.name, 'CentOS') }}
uses: actions/download-artifact@v3
with:
name: pica-${{ needs.version.outputs.VERSION }}-glibc${{ matrix.target.glibc }}-1.x86_64.rpm
- name: Fix CentoOS8
if: matrix.target.image == 'centos:8'
run: |
cd /etc/yum.repos.d/
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
yum update -y
cd
- name: Install Pica (Ubuntu / Debian)
if: ${{ !startsWith(matrix.target.name, 'CentOS') }}
run: dpkg -i pica_${{ needs.version.outputs.VERSION }}-glibc${{ matrix.target.glibc }}-1_amd64.deb
- name: Install Pica (CentOS)
if: ${{ startsWith(matrix.target.name, 'CentOS') }}
run: yum -y install pica-${{ needs.version.outputs.VERSION }}-glibc${{ matrix.target.glibc }}-1.x86_64.rpm
- name: Pica Version
run: |
pica --version
gh-release:
name: "Release"
runs-on: ubuntu-latest
needs:
- linux-releases
- macos-releases
- windows-releases
- check
- packages
- version
steps:
- name: "Download releases/packages"
uses: actions/download-artifact@v3
- name: Assemble data
run: |
mkdir uploads/
mv pica-*/*.tar.gz uploads/
mv pica-*/*.rpm uploads/
mv pica_*/*.deb uploads/
mv pica-*/*.zip uploads/
tree uploads/
cd uploads/
sha256sum * > CHECKSUMS
cd ..
- name: "GH Release"
uses: softprops/action-gh-release@v1
with:
draft: true
files: uploads/*