Skip to content

Commit af7f474

Browse files
Luni-4barrbrain
authored andcommitted
CI: Improve the deploy script
The script deploys: - linux-musl binary - aarch64-musl binary - wasm32 binaries - macos binary - windows binary - windows-msvc binaries produced by cargo-c - windows-gnu binaries produced by cargo-c - Cargo.lock
1 parent ee60ee1 commit af7f474

File tree

1 file changed

+283
-18
lines changed

1 file changed

+283
-18
lines changed

.github/workflows/deploy.yml

Lines changed: 283 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@ on:
77
- 'p*'
88

99
jobs:
10-
deploy-windows-binaries:
10+
11+
windows-binaries:
12+
13+
strategy:
14+
matrix:
15+
conf:
16+
- msvc
17+
- gnu
18+
include:
19+
- conf: msvc
20+
toolchain: stable
21+
- conf: gnu
22+
toolchain: stable-x86_64-pc-windows-gnu
1123

1224
runs-on: windows-latest
1325

@@ -17,27 +29,45 @@ jobs:
1729
- name: Install nasm
1830
run: |
1931
$NASM_VERSION="2.14.02"
20-
$NASM_LINK="https://www.nasm.us/pub/nasm/releasebuilds"
21-
curl --ssl-no-revoke -LO "$NASM_LINK/$NASM_VERSION/win64/nasm-$NASM_VERSION-win64.zip"
32+
$LINK="https://www.nasm.us/pub/nasm/releasebuilds/$NASM_VERSION/win64"
33+
curl --ssl-no-revoke -LO "$LINK/nasm-$NASM_VERSION-win64.zip"
2234
7z e -y "nasm-$NASM_VERSION-win64.zip" -o"C:\nasm"
2335
echo "::add-path::C:\nasm"
2436
25-
- name: Install Rust
37+
- name: Install cargo-c
38+
run: |
39+
$LINK = "https://github.com/lu-zero/cargo-c/releases/download/v0.6.5"
40+
$CARGO_C_FILE = "cargo-c-windows-msvc"
41+
curl -LO "$LINK/$CARGO_C_FILE.zip"
42+
7z e -y "$CARGO_C_FILE.zip" -o"${env:USERPROFILE}\.cargo\bin"
43+
44+
- name: Set environment variables
45+
if: matrix.conf == 'msvc'
46+
run: |
47+
$VsPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer"
48+
echo "::add-path::$VsPath;C:\nasm"
49+
50+
- name: Set MSVC x86_64 linker path
51+
if: matrix.conf == 'msvc'
52+
run: |
53+
$LinkGlob = "VC\Tools\MSVC\*\bin\Hostx64\x64"
54+
$LinkPath = vswhere -latest -products * -find "$LinkGlob" |
55+
Select-Object -Last 1
56+
echo "::add-path::$LinkPath"
57+
58+
- name: Install stable
2659
uses: actions-rs/toolchain@v1
2760
with:
2861
profile: minimal
29-
toolchain: stable-x86_64-pc-windows-gnu
62+
toolchain: ${{ matrix.toolchain }}
3063
override: true
3164

32-
- name: Install cargo-c
33-
run: |
34-
cargo install cargo-c
35-
3665
- name: Build rav1e
3766
run: |
3867
cargo build --release
3968
40-
- name: Strip rav1e binary
69+
- name: Strip rav1e gnu-binary
70+
if: matrix.conf == 'gnu'
4171
run: |
4272
strip target/release/rav1e.exe
4373
@@ -47,7 +77,7 @@ jobs:
4777
4878
- name: Rename cargo-c folder
4979
run: |
50-
Rename-Item "C:\usr\local" "C:\usr\rav1e-windows-sdk"
80+
Rename-Item "C:\usr\local" "C:\usr\rav1e-windows-${{ matrix.conf }}-sdk"
5181
5282
- name: Get the version
5383
if: startsWith(github.ref, 'refs/tags/v')
@@ -60,13 +90,238 @@ jobs:
6090
- name: Package pre-release binaries
6191
if: startsWith(github.ref, 'refs/tags/p')
6292
run: |
63-
7z a rav1e-windows.zip "C:\usr\rav1e-windows-sdk"
93+
7z a rav1e-windows-${{ matrix.conf }}.zip `
94+
"C:\usr\rav1e-windows-${{ matrix.conf }}-sdk"
6495
6596
- name: Package release binaries
6697
if: startsWith(github.ref, 'refs/tags/v')
6798
run: |
68-
7z a rav1e-${{ steps.tagName.outputs.version }}-windows.zip `
69-
"C:\usr\rav1e-windows-sdk"
99+
$ZIP_PREFIX = "rav1e-${{ steps.tagName.outputs.version }}-windows"
100+
7z a "$ZIP_PREFIX-${{ matrix.conf }}.zip" `
101+
"C:\usr\rav1e-windows-${{ matrix.conf }}-sdk"
102+
103+
- name: Upload rav1e msvc binary
104+
if: matrix.conf == 'msvc'
105+
uses: actions/upload-artifact@v2
106+
with:
107+
path: target/release/rav1e.exe
108+
109+
- name: Upload pre-release binaries
110+
if: startsWith(github.ref, 'refs/tags/p')
111+
uses: actions/upload-artifact@v2
112+
with:
113+
path: rav1e-windows-${{ matrix.conf }}.zip
114+
115+
- name: Upload release binaries
116+
if: startsWith(github.ref, 'refs/tags/v')
117+
uses: actions/upload-artifact@v2
118+
with:
119+
path: rav1e-${{ steps.tagName.outputs.version }}-windows-${{ matrix.conf }}.zip
120+
121+
122+
linux-binaries:
123+
124+
strategy:
125+
matrix:
126+
target:
127+
- x86_64-unknown-linux-musl
128+
- aarch64-unknown-linux-musl
129+
- wasm32-unknown-unknown
130+
include:
131+
- target: x86_64-unknown-linux-musl
132+
name: linux
133+
binaries: rav1e
134+
strip: strip
135+
- target: aarch64-unknown-linux-musl
136+
name: aarch64-linux
137+
binaries: rav1e
138+
strip: aarch64-linux-gnu-strip
139+
- target: wasm32-unknown-unknown
140+
name: wasm32-linux
141+
binaries: librav1e.a rav1e.wasm
142+
143+
runs-on: ubuntu-latest
144+
145+
steps:
146+
- uses: actions/checkout@v2
147+
148+
- name: Install nasm
149+
if: matrix.target == 'x86_64-unknown-linux-musl'
150+
env:
151+
LINK: http://debian-archive.trafficmanager.net/debian/pool/main/n/nasm
152+
NASM_VERSION: 2.14.02-1
153+
NASM_SHA256: >-
154+
5225d0654783134ae616f56ce8649e4df09cba191d612a0300cfd0494bb5a3ef
155+
run: |
156+
curl -O "$LINK/nasm_${NASM_VERSION}_amd64.deb"
157+
echo "$NASM_SHA256 nasm_${NASM_VERSION}_amd64.deb" | sha256sum --check
158+
sudo dpkg -i "nasm_${NASM_VERSION}_amd64.deb"
159+
160+
- name: Install musl tools
161+
if: matrix.target != 'wasm32-unknown-unknown'
162+
run: |
163+
sudo apt-get install musl-tools
164+
165+
- name: Install aarch64 tools
166+
if: matrix.target == 'aarch64-unknown-linux-musl'
167+
run: |
168+
sudo apt-get install binutils-aarch64-linux-gnu
169+
170+
- name: Install ${{ matrix.target }} target
171+
uses: actions-rs/toolchain@v1
172+
with:
173+
profile: minimal
174+
toolchain: stable
175+
target: ${{ matrix.target }}
176+
override: true
177+
178+
- name: Install cross
179+
if: matrix.target == 'aarch64-unknown-linux-musl'
180+
env:
181+
LINK: https://github.com/rust-embedded/cross/releases/download
182+
CROSS_VERSION: 0.2.0
183+
CROSS_FILE: cross-v0.2.0-x86_64-unknown-linux-musl
184+
run: |
185+
curl -L "$LINK/v$CROSS_VERSION/$CROSS_FILE.tar.gz" |
186+
tar xz -C $HOME/.cargo/bin
187+
188+
- name: Build rav1e for aarch64-musl
189+
if: matrix.target == 'aarch64-unknown-linux-musl'
190+
run: |
191+
cross build --target ${{ matrix.target }} --release
192+
193+
- name: Build rav1e
194+
if: matrix.target != 'aarch64-unknown-linux-musl'
195+
run: |
196+
cargo build --target ${{ matrix.target }} --release
197+
198+
- name: Strip musl rav1e
199+
if: matrix.target != 'wasm32-unknown-unknown'
200+
run: |
201+
${{ matrix.strip }} target/${{ matrix.target }}/release/rav1e
202+
203+
- name: Get the version
204+
if: startsWith(github.ref, 'refs/tags/v')
205+
id: tagName
206+
run: |
207+
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2)
208+
echo "::set-output name=version::$VERSION"
209+
210+
- name: Create a pre-release tar
211+
if: startsWith(github.ref, 'refs/tags/p')
212+
run: |
213+
cd target/${{ matrix.target }}/release
214+
tar -czvf $GITHUB_WORKSPACE/rav1e-${{ matrix.name }}.tar.gz \
215+
${{ matrix.binaries }}
216+
217+
- name: Create a release tar
218+
if: startsWith(github.ref, 'refs/tags/v')
219+
run: |
220+
TAR_FILE=rav1e-${{ steps.tagName.outputs.version }}-${{ matrix.name }}
221+
cd target/${{ matrix.target }}/release
222+
tar -czvf $GITHUB_WORKSPACE/$TAR_FILE.tar.gz ${{ matrix.binaries }}
223+
224+
- name: Upload pre-release binaries
225+
if: startsWith(github.ref, 'refs/tags/p')
226+
uses: actions/upload-artifact@v2
227+
with:
228+
path: rav1e-${{ matrix.name }}.tar.gz
229+
230+
- name: Upload release binaries
231+
if: startsWith(github.ref, 'refs/tags/v')
232+
uses: actions/upload-artifact@v2
233+
with:
234+
path: rav1e-${{ steps.tagName.outputs.version }}-${{ matrix.name }}.tar.gz
235+
236+
macos-binaries:
237+
238+
runs-on: macos-latest
239+
240+
steps:
241+
- uses: actions/checkout@v2
242+
243+
- name: Install nasm
244+
run: |
245+
brew install nasm
246+
247+
- name: Install stable
248+
uses: actions-rs/toolchain@v1
249+
with:
250+
profile: minimal
251+
toolchain: stable
252+
override: true
253+
254+
- name: Build rav1e
255+
run: |
256+
cargo build --release
257+
258+
- name: Strip rav1e
259+
run: |
260+
strip target/release/rav1e
261+
262+
- name: Get the version
263+
if: startsWith(github.ref, 'refs/tags/v')
264+
id: tagName
265+
run: |
266+
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2)
267+
echo "::set-output name=version::$VERSION"
268+
269+
- name: Create a pre-release zip
270+
if: startsWith(github.ref, 'refs/tags/p')
271+
run: |
272+
cd target/release
273+
zip -9 $GITHUB_WORKSPACE/rav1e-macos.zip rav1e
274+
275+
- name: Create a release zip
276+
if: startsWith(github.ref, 'refs/tags/v')
277+
run: |
278+
ZIP_FILE=rav1e-${{ steps.tagName.outputs.version }}-macos.zip
279+
cd target/release
280+
zip -9 $GITHUB_WORKSPACE/$ZIP_FILE rav1e
281+
282+
- name: Upload pre-release binaries
283+
if: startsWith(github.ref, 'refs/tags/p')
284+
uses: actions/upload-artifact@v2
285+
with:
286+
path: rav1e-macos.zip
287+
288+
- name: Upload release binaries
289+
if: startsWith(github.ref, 'refs/tags/v')
290+
uses: actions/upload-artifact@v2
291+
with:
292+
path: rav1e-${{ steps.tagName.outputs.version }}-macos.zip
293+
294+
deploy:
295+
296+
needs: [windows-binaries, linux-binaries, macos-binaries]
297+
298+
runs-on: ubuntu-latest
299+
300+
steps:
301+
- uses: actions/checkout@v2
302+
303+
- name: Download artifacts
304+
uses: actions/download-artifact@v2
305+
with:
306+
name: artifact
307+
308+
- name: Install Rust stable
309+
uses: actions-rs/toolchain@v1
310+
with:
311+
profile: minimal
312+
toolchain: stable
313+
override: true
314+
315+
- name: Create Cargo.lock
316+
run: |
317+
cargo update
318+
319+
- name: Get the version
320+
if: startsWith(github.ref, 'refs/tags/v')
321+
id: tagName
322+
run: |
323+
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2)
324+
echo "::set-output name=version::$VERSION"
70325
71326
- name: Create a pre-release
72327
if: startsWith(github.ref, 'refs/tags/p')
@@ -76,8 +331,13 @@ jobs:
76331
prerelease: true
77332
files: |
78333
Cargo.lock
79-
rav1e-windows.zip
80-
target/release/rav1e.exe
334+
rav1e.exe
335+
rav1e-linux.tar.gz
336+
rav1e-aarch64-linux.tar.gz
337+
rav1e-wasm32-linux.tar.gz
338+
rav1e-macos.zip
339+
rav1e-windows-msvc.zip
340+
rav1e-windows-gnu.zip
81341
env:
82342
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83343

@@ -88,7 +348,12 @@ jobs:
88348
name: v${{ steps.tagName.outputs.version }}
89349
files: |
90350
Cargo.lock
91-
rav1e-${{ steps.tagName.outputs.version }}-windows.zip
92-
target/release/rav1e.exe
351+
rav1e.exe
352+
rav1e-${{ steps.tagName.outputs.version }}-linux.tar.gz
353+
rav1e-${{ steps.tagName.outputs.version }}-aarch64-linux.tar.gz
354+
rav1e-${{ steps.tagName.outputs.version }}-wasm32-linux.tar.gz
355+
rav1e-${{ steps.tagName.outputs.version }}-macos.zip
356+
rav1e-${{ steps.tagName.outputs.version }}-windows-msvc.zip
357+
rav1e-${{ steps.tagName.outputs.version }}-windows-gnu.zip
93358
env:
94359
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)