-
-
Notifications
You must be signed in to change notification settings - Fork 199
285 lines (254 loc) · 9.25 KB
/
release-binary.yml
File metadata and controls
285 lines (254 loc) · 9.25 KB
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
# CI pipeline for stable binaries
# Keep in sync with:
# - .github/workflows/debug_build.yml
# - Dockerfile-CI.Dockerfile
# - Dockerfile-CI.alpine.Dockerfile
# - https://github.com/lycheeverse/lychee-action/blob/master/action.yml
name: Release Binary
on:
release:
types:
- published
- created
- prereleased
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.get_release.outputs.tag_name }}
upload_url: ${{ steps.get_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Get release
id: get_release
uses: bruceadams/get-release@v1.3.2
# Skip step if not in the official repository as it would fail.
# Instead fail at the end of this workflow.
if: ${{ github.repository == 'lycheeverse/lychee' }}
env:
GITHUB_TOKEN: ${{ github.token }}
linux:
permissions:
contents: write
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix:
include:
- build: x86_64-gnu
target: x86_64-unknown-linux-gnu
strip: x86_64-linux-gnu-strip
- build: x86_64-musl
target: x86_64-unknown-linux-musl
strip: x86_64-linux-musl-strip
- build: arm-gnueabihf
target: armv7-unknown-linux-gnueabihf
strip: arm-linux-gnueabihf-strip
qemu: qemu-arm
- build: arm-musleabi
target: arm-unknown-linux-musleabi
strip: arm-linux-musleabi-strip
qemu: qemu-arm
- build: arm-musleabihf
target: arm-unknown-linux-musleabihf
strip: arm-linux-musleabihf-strip
qemu: qemu-arm
- build: aarch64-gnu
target: aarch64-unknown-linux-gnu
strip: aarch64-linux-gnu-strip
qemu: qemu-aarch64
- build: aarch64-musl
target: aarch64-unknown-linux-musl
strip: aarch64-linux-musl-strip
qemu: qemu-aarch64
- build: i686-gnu
target: i686-unknown-linux-gnu
strip: x86_64-linux-gnu-strip
qemu: i386
fail-fast: false
steps:
- name: Install musl tools
if: ${{ contains(matrix.target, 'musl') }}
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Install arm tools
if: ${{ contains(matrix.target, 'arm') }}
run: |
echo "GNU_PREFIX=arm-linux-gnueabihf-" >> $GITHUB_ENV
sudo apt-get update && sudo apt-get install -y binutils-arm-linux-gnueabihf
- name: Install aarch64 tools
if: ${{ contains(matrix.target, 'aarch64') }}
run: |
echo "GNU_PREFIX=aarch64-linux-gnu-" >> $GITHUB_ENV
sudo apt-get update && sudo apt-get install -y binutils-aarch64-linux-gnu
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- name: Build ${{ matrix.target }}
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}
use-cross: true
- name: Prepare binary
run: |
bin="target/${{ matrix.target }}/release/lychee"
chmod +x $bin
echo "BIN=$bin" >> $GITHUB_ENV
- name: Strip binary (cross)
run: |
docker run --rm -v \
"$PWD/target:/target:Z" \
"ghcr.io/cross-rs/${{ matrix.target }}:main" \
"${{ matrix.strip }}" \
"/$BIN"
- name: Prepare release directory
run: |
mkdir out out/docs out/complete
cp $BIN out
cp README.md docs/*.md out/docs
- name: Generate man page without emulation
if: matrix.qemu == ''
run: |
$BIN --version
$BIN --generate man > out/docs/lychee.1
- name: Generate man page with emulation
if: matrix.qemu != ''
run: |
docker run --rm -v \
"$PWD/target:/target:Z" \
"ghcr.io/cross-rs/${{ matrix.target }}:main" \
"${{ matrix.qemu }}" "/$BIN" --version
docker run --rm -v \
"$PWD/target:/target:Z" \
"ghcr.io/cross-rs/${{ matrix.target }}:main" \
"${{ matrix.qemu }}" "/$BIN" \
--generate man > "out/docs/lychee.1"
- name: Generate shell completions without emulation
if: matrix.qemu == ''
run: |
$BIN --generate complete-bash > out/complete/lychee.bash
$BIN --generate complete-elvish > out/complete/lychee.elv
$BIN --generate complete-fish > out/complete/lychee.fish
$BIN --generate complete-powershell > out/complete/_lychee.ps1
$BIN --generate complete-zsh > out/complete/_lychee
- name: Generate shell completions with emulation
if: matrix.qemu != ''
run: |
docker run --rm -v \
"$PWD/target:/target:Z" \
"ghcr.io/cross-rs/${{ matrix.target }}:main" \
"${{ matrix.qemu }}" "/$BIN" \
--generate complete-bash > "out/complete/lychee.bash"
docker run --rm -v \
"$PWD/target:/target:Z" \
"ghcr.io/cross-rs/${{ matrix.target }}:main" \
"${{ matrix.qemu }}" "/$BIN" \
--generate complete-elvish > "out/complete/lychee.elv"
docker run --rm -v \
"$PWD/target:/target:Z" \
"ghcr.io/cross-rs/${{ matrix.target }}:main" \
"${{ matrix.qemu }}" "/$BIN" \
--generate complete-fish > "out/complete/lychee.fish"
docker run --rm -v \
"$PWD/target:/target:Z" \
"ghcr.io/cross-rs/${{ matrix.target }}:main" \
"${{ matrix.qemu }}" "/$BIN" \
--generate complete-powershell > "out/complete/_lychee.ps1"
docker run --rm -v \
"$PWD/target:/target:Z" \
"ghcr.io/cross-rs/${{ matrix.target }}:main" \
"${{ matrix.qemu }}" "/$BIN" \
--generate complete-zsh > "out/complete/_lychee"
- name: Package release
run: |
cd out
tar -czf lychee.tar.gz lychee docs/ complete/
- name: Check if possible to release
if: ${{ needs.prepare.outputs.upload_url == '' }}
run: |
echo "Releasing only works on the master/main branch in the official repository."
exit 1
- name: Upload .tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_name: lychee-${{ matrix.target }}.tar.gz
asset_path: out/lychee.tar.gz
upload_url: ${{needs.prepare.outputs.upload_url}}
asset_content_type: application/gzip
macos:
permissions:
contents: write
runs-on: macos-latest
needs: prepare
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- name: Build binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release
use-cross: true
- name: Optimize and package binary
run: |
cd target/release
strip lychee
chmod +x lychee
mkdir docs complete
cp ../../README.md ../../docs/TROUBLESHOOTING.md docs
./lychee --generate man > docs/lychee.1
./lychee --generate complete-bash > complete/lychee.bash
./lychee --generate complete-elvish > complete/lychee.elv
./lychee --generate complete-fish > complete/lychee.fish
./lychee --generate complete-powershell > complete/_lychee.ps1
./lychee --generate complete-zsh > complete/_lychee
tar -czf lychee.tar.gz lychee docs/ complete/
mkdir dmg
mv lychee dmg/
hdiutil create -fs HFS+ -srcfolder dmg -volname lychee lychee.dmg
- name: Upload .dmg
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_name: lychee-arm64-macos.dmg
asset_path: target/release/lychee.dmg
upload_url: ${{needs.prepare.outputs.upload_url}}
asset_content_type: application/octet-stream
- name: Upload .tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_name: lychee-arm64-macos.tar.gz
asset_path: target/release/lychee.tar.gz
upload_url: ${{needs.prepare.outputs.upload_url}}
asset_content_type: application/octet-stream
windows:
permissions:
contents: write
runs-on: windows-latest
needs: prepare
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- name: Build binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release
use-cross: true
- name: Upload binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_name: lychee-x86_64-windows.exe
asset_path: target/release/lychee.exe
upload_url: ${{needs.prepare.outputs.upload_url}}
asset_content_type: application/octet-stream