Skip to content

Commit e07fed6

Browse files
committed
internal: refactor ci build to use matrix
trying to de-dupe stuff to prep for more builds for vscode
1 parent 23f7bd7 commit e07fed6

File tree

1 file changed

+55
-187
lines changed

1 file changed

+55
-187
lines changed

.github/workflows/rust.yml

Lines changed: 55 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -20,232 +20,100 @@ jobs:
2020
with:
2121
paths_ignore: '["docs/**", "*.md"]'
2222

23-
build-linux-x64:
24-
needs: pre_job
25-
if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/')
26-
27-
name: Linux x86_64
28-
runs-on: ubuntu-22.04
29-
30-
steps:
31-
- name: Checkout
32-
uses: actions/checkout@v4
33-
34-
- name: Install Toolchain
35-
uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master
36-
with:
37-
toolchain: stable
38-
target: x86_64-unknown-linux-gnu
39-
profile: minimal
40-
override: true
41-
42-
- name: Cache
43-
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2
44-
45-
- name: Build
46-
run: cargo build --target x86_64-unknown-linux-gnu --release && mv target/x86_64-unknown-linux-gnu/release/squawk target/release/squawk-linux-x64
47-
48-
- name: Artifact
49-
uses: actions/upload-artifact@v4
50-
with:
51-
name: release-squawk-linux-x64
52-
path: target/release/squawk-linux-x64
53-
54-
- name: Release
55-
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1
56-
if: startsWith(github.ref, 'refs/tags/')
57-
with:
58-
files: |
59-
target/release/squawk-linux-x64
60-
env:
61-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62-
63-
build-linux-arm64:
64-
needs: pre_job
65-
if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/')
66-
67-
name: Linux arm64
68-
runs-on: ubuntu-22.04
69-
70-
steps:
71-
- name: Checkout
72-
uses: actions/checkout@v4
73-
74-
- name: Apt
75-
run: sudo apt-get install gcc-aarch64-linux-gnu
76-
77-
- name: Install Toolchain
78-
uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master
79-
with:
80-
toolchain: stable
81-
target: aarch64-unknown-linux-gnu
82-
profile: minimal
83-
override: true
84-
85-
- name: Cache
86-
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2
87-
88-
- name: Build
89-
run: RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc" cargo build --target aarch64-unknown-linux-gnu --release && mv target/aarch64-unknown-linux-gnu/release/squawk target/release/squawk-linux-arm64
90-
91-
- name: Artifact
92-
uses: actions/upload-artifact@v4
93-
with:
94-
name: release-squawk-linux-arm64
95-
path: target/release/squawk-linux-arm64
96-
97-
- name: Release
98-
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1
99-
if: startsWith(github.ref, 'refs/tags/')
100-
with:
101-
files: |
102-
target/release/squawk-linux-arm64
103-
env:
104-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105-
106-
build-linux-musl-x64:
107-
needs: pre_job
108-
if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/')
109-
110-
name: Linux Alpine x86_64
111-
runs-on: ubuntu-22.04
112-
113-
steps:
114-
- name: Checkout
115-
uses: actions/checkout@v4
116-
117-
- name: Install musl-tools
118-
run: |
119-
sudo apt-get update
120-
sudo apt-get install -y musl-tools
121-
122-
- name: Install Toolchain
123-
uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master
124-
with:
125-
toolchain: stable
126-
target: x86_64-unknown-linux-musl
127-
profile: minimal
128-
override: true
129-
130-
- name: Cache
131-
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2
132-
133-
- name: Build
134-
run: RUSTFLAGS="-C linker=rust-lld" cargo build --target x86_64-unknown-linux-musl --release && mv target/x86_64-unknown-linux-musl/release/squawk target/release/squawk-linux-musl-x64
135-
136-
- name: Artifact
137-
uses: actions/upload-artifact@v4
138-
with:
139-
name: release-squawk-linux-musl-x64
140-
path: target/release/squawk-linux-musl-x64
141-
142-
- name: Release
143-
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1
144-
if: startsWith(github.ref, 'refs/tags/')
145-
with:
146-
files: |
147-
target/release/squawk-linux-musl-x64
148-
env:
149-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
150-
151-
build-windows:
152-
needs: pre_job
153-
if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/')
154-
name: Windows
155-
156-
runs-on: windows-latest
157-
158-
steps:
159-
- name: Checkout
160-
uses: actions/checkout@v4
161-
162-
- name: Install Toolchain
163-
uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master
164-
with:
165-
toolchain: stable
166-
target: x86_64-pc-windows-msvc
167-
profile: minimal
168-
override: true
169-
170-
- name: Cache
171-
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2
172-
173-
- name: Build
174-
run: cargo build --target x86_64-pc-windows-msvc --release && mv target/x86_64-pc-windows-msvc/release/squawk.exe target/release/squawk-windows-x64.exe
175-
176-
- name: Artifact
177-
uses: actions/upload-artifact@v4
178-
with:
179-
name: release-squawk-windows-x64.exe
180-
path: target/release/squawk-windows-x64.exe
181-
182-
- name: Release
183-
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1
184-
if: startsWith(github.ref, 'refs/tags/')
185-
with:
186-
files: |
187-
target/release/squawk-windows-x64.exe
188-
env:
189-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
190-
191-
build-mac:
23+
build:
19224
needs: pre_job
19325
if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/')
19426

19527
strategy:
19628
fail-fast: false
19729
matrix:
19830
include:
199-
- arch: x64
31+
- name: Linux x86_64
32+
os: ubuntu-22.04
33+
target: x86_64-unknown-linux-gnu
34+
artifact_name: squawk-linux-x64
35+
36+
- name: Linux arm64
37+
os: ubuntu-22.04
38+
target: aarch64-unknown-linux-gnu
39+
artifact_name: squawk-linux-arm64
40+
rustflags: "-C linker=aarch64-linux-gnu-gcc"
41+
42+
- name: Linux Alpine x86_64
43+
os: ubuntu-22.04
44+
target: x86_64-unknown-linux-musl
45+
artifact_name: squawk-linux-musl-x64
46+
rustflags: "-C linker=rust-lld"
47+
48+
- name: Windows x86_64
49+
os: windows-latest
50+
target: x86_64-pc-windows-msvc
51+
artifact_name: squawk-windows-x64.exe
52+
53+
- name: macOS x86_64
54+
os: macos-latest
20055
target: x86_64-apple-darwin
201-
- arch: arm64
56+
artifact_name: squawk-darwin-x64
57+
58+
- name: macOS arm64
59+
os: macos-latest
20260
target: aarch64-apple-darwin
61+
artifact_name: squawk-darwin-arm64
20362

204-
name: macOS ${{ matrix.arch }}
205-
runs-on: macos-latest
63+
name: ${{ matrix.name }}
64+
runs-on: ${{ matrix.os }}
20665

20766
steps:
20867
- name: Checkout
20968
uses: actions/checkout@v4
21069

70+
- name: Update apt repositories
71+
if: matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'arm-unknown-linux-gnueabihf'
72+
run: sudo apt-get update
73+
74+
- name: Install AArch64 target toolchain
75+
if: matrix.target == 'aarch64-unknown-linux-gnu'
76+
run: sudo apt-get install gcc-aarch64-linux-gnu
77+
78+
- name: Install x86_64-musl target toolchain
79+
if: matrix.target == 'x86_64-unknown-linux-musl'
80+
run: sudo apt-get install musl-tools
81+
21182
- name: Install Toolchain
21283
uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master
21384
with:
85+
toolchain: stable
21486
target: ${{ matrix.target }}
21587
profile: minimal
21688
override: true
21789

21890
- name: Cache
21991
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2
22092

221-
- name: Build for mac
222-
run: cargo build --release --target=${{ matrix.target }} && mv target/${{ matrix.target }}/release/squawk target/release/squawk-darwin-${{ matrix.arch }}
93+
- name: Build
94+
run: RUSTFLAGS="${{ matrix.rustflags }}" cargo build --target ${{ matrix.target }} --release
95+
96+
- name: Rename artifact
97+
run: mv target/${{ matrix.target }}/release/squawk* target/release/${{ matrix.artifact_name }}
22398

22499
- name: Artifact
225100
uses: actions/upload-artifact@v4
226101
with:
227-
name: release-squawk-darwin-${{ matrix.arch }}
228-
path: target/release/squawk-darwin-${{ matrix.arch }}
102+
name: release-${{ matrix.artifact_name }}
103+
path: target/release/${{ matrix.artifact_name }}
229104

230105
- name: Release
231106
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1
232107
if: startsWith(github.ref, 'refs/tags/')
233108
with:
234109
files: |
235-
target/release/squawk-darwin-${{ matrix.arch }}
110+
target/release/${{ matrix.artifact_name }}
236111
env:
237112
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
238113

239114
publish-npm:
240115
if: startsWith(github.ref, 'refs/tags/')
241-
needs:
242-
[
243-
build-linux-x64,
244-
build-linux-musl-x64,
245-
build-linux-arm64,
246-
build-mac,
247-
build-windows,
248-
]
116+
needs: [build]
249117
runs-on: ubuntu-22.04
250118
steps:
251119
- uses: actions/checkout@v4
@@ -259,7 +127,7 @@ jobs:
259127

260128
publish-docker:
261129
if: startsWith(github.ref, 'refs/tags/')
262-
needs: [build-linux-x64, build-linux-musl-x64, build-mac, build-windows]
130+
needs: [build]
263131
runs-on: ubuntu-22.04
264132
permissions:
265133
contents: read

0 commit comments

Comments
 (0)