1
1
on :
2
- push :
3
- branches :
4
- # for bors r+
5
- - staging
6
- # for bors try
7
- - trying
2
+ pull_request :
8
3
workflow_dispatch :
9
4
inputs :
10
5
no_cache :
11
6
description : Disable Docker cache, yes/no
12
- default : ' no '
7
+ default : " no "
13
8
required : false
14
9
toolchain :
15
10
description : Rust toolchain to install
16
- default : ' stable'
11
+ default : " stable"
17
12
required : false
18
13
arch :
19
14
description : Architectures to build for
20
- default : ' '
15
+ default : " "
21
16
required : false
22
17
schedule :
23
- - cron : ' 0 0 1 */2 *'
18
+ - cron : " 0 0 1 */2 *"
24
19
25
20
name : Build
26
21
48
43
const archMatrix = yaml.load(process.env.ARCH_MATRIX)
49
44
const targetMatrix = yaml.load(process.env.TARGET_MATRIX)
50
45
51
- if (context.eventName == 'schedule') {
52
- // Always run on schedule
53
- core.setOutput('arch', JSON.stringify(archMatrix))
54
- core.setOutput('target', JSON.stringify(targetMatrix))
55
- } else if (context.eventName == 'workflow_dispatch') {
46
+ if (context.eventName == 'workflow_dispatch') {
56
47
let outputArchMatrix = []
57
48
let outputTargetMatrix = []
58
49
const dockerArch = context.payload.inputs.arch.split(',')
@@ -75,84 +66,10 @@ jobs:
75
66
core.setOutput('arch', JSON.stringify(outputArchMatrix))
76
67
core.setOutput('target', JSON.stringify(outputTargetMatrix))
77
68
core.setOutput('fail-fast', 'false')
78
- } else if (context.eventName == 'push') {
79
- const commitMessage = process.env.COMMIT_MESSAGE.trim()
80
- if (commitMessage.length > 0) {
81
- let outputArchMatrix = []
82
- let outputTargetMatrix = []
83
-
84
- let borsArgs
85
- if (commitMessage.startsWith('Try #')) {
86
- borsArgs = commitMessage.replace(/Try #[0-9]+:/i, '').trim()
87
- } else {
88
- // Merge example commit message:
89
- // Merge #64
90
- //
91
- // 64: Refine bors command r=messense a=messense
92
- //
93
- // bors: amd64 --target aarch64
94
- //
95
- // Co-authored-by: messense <messense@icloud.com>
96
- //
97
- borsArgs = commitMessage
98
- .split('\n')
99
- .filter(item => item.trim().startsWith('bors:'))
100
- .join('\n')
101
- .trim()
102
- }
103
- const targetIndex = borsArgs.indexOf('--target')
104
- let dockerArch = []
105
- let targets = []
106
-
107
- if (targetIndex === -1) {
108
- dockerArch = borsArgs.trim().split(' ').filter(x => x.length > 0)
109
- targets = []
110
- } else {
111
- dockerArch = borsArgs.substring(0, targetIndex).trim().split(' ').filter(x => x.length > 0)
112
- targets = borsArgs.substring(targetIndex + '--target'.length).trim().split(' ')
113
- }
114
- if (dockerArch.length === 0) {
115
- // Defaults to all arches
116
- outputArchMatrix = archMatrix
117
- } else {
118
- for (const arch of dockerArch) {
119
- outputArchMatrix.push(...archMatrix.filter(item => item.arch == arch))
120
- }
121
- }
122
- if (targets.length === 0) {
123
- // Defaults to all targets
124
- outputTargetMatrix = targetMatrix
125
- } else {
126
- for (const target of targets) {
127
- outputTargetMatrix.push(...targetMatrix.filter(item => item.TARGET.startsWith(target)))
128
- }
129
- }
130
-
131
- core.setOutput('arch', JSON.stringify(outputArchMatrix))
132
- core.setOutput('target', JSON.stringify(outputTargetMatrix))
133
- } else {
134
- core.setOutput('arch', JSON.stringify(archMatrix))
135
- core.setOutput('target', JSON.stringify(targetMatrix))
136
- core.setOutput('run-build', 'false')
137
- }
138
-
139
- const matches = commitMessage.match(/(Try|Merge) #([0-9]+):/)
140
- if (matches) {
141
- const prNumber = matches[2]
142
- const { data: { labels: labels } } = await github.rest.pulls.get({
143
- owner: context.repo.owner,
144
- repo: context.repo.repo,
145
- pull_number: prNumber
146
- })
147
- const labelNames = labels.map(label => label.name)
148
- if (labelNames.includes('CI-no-fail-fast')) {
149
- core.setOutput('fail-fast', 'false')
150
- }
151
- }
152
69
} else {
153
70
core.setOutput('arch', JSON.stringify(archMatrix))
154
71
core.setOutput('target', JSON.stringify(targetMatrix))
155
- core.setOutput('run-build ', 'false')
72
+ core.setOutput('fail-fast ', 'false')
156
73
}
157
74
- name : Show build matrix
158
75
run : |
@@ -170,11 +87,11 @@ jobs:
170
87
}}
171
88
ARCH_MATRIX : |
172
89
- arch: amd64
173
- runner: [ ubuntu-latest]
90
+ runner: ubuntu-latest
174
91
- arch: arm64
175
- runner: [self-hosted, ARM64]
92
+ runner: ubuntu-24.04-arm
176
93
- arch: armv7
177
- runner: [self-hosted, ARM64]
94
+ runner: ubuntu-24.04-arm
178
95
docker_arch: arm/v7
179
96
TARGET_MATRIX : |
180
97
- IMAGE_TAG: aarch64-musl
@@ -213,26 +130,31 @@ jobs:
213
130
TARGET: powerpc64le-unknown-linux-musl
214
131
RUST_MUSL_MAKE_CONFIG: config.mak
215
132
TOOLCHAIN: stable
216
- - IMAGE_TAG: mips-musl
217
- TARGET: mips-unknown-linux-musl
218
- RUST_MUSL_MAKE_CONFIG: config.mak
219
- TOOLCHAIN: nightly
220
- - IMAGE_TAG: mips64-muslabi64
221
- TARGET: mips64-unknown-linux-muslabi64
222
- RUST_MUSL_MAKE_CONFIG: config.mak
223
- TOOLCHAIN: nightly
224
- - IMAGE_TAG: mips64el-muslabi64
225
- TARGET: mips64el-unknown-linux-muslabi64
226
- RUST_MUSL_MAKE_CONFIG: config.mak
227
- TOOLCHAIN: nightly
228
- - IMAGE_TAG: mipsel-musl
229
- TARGET: mipsel-unknown-linux-musl
230
- RUST_MUSL_MAKE_CONFIG: config.mak
231
- TOOLCHAIN: nightly
133
+ # - IMAGE_TAG: mips-musl
134
+ # TARGET: mips-unknown-linux-musl
135
+ # RUST_MUSL_MAKE_CONFIG: config.mak
136
+ # TOOLCHAIN: stable
137
+ # - IMAGE_TAG: mips64-muslabi64
138
+ # TARGET: mips64-unknown-linux-muslabi64
139
+ # RUST_MUSL_MAKE_CONFIG: config.mak
140
+ # TOOLCHAIN: stable
141
+ # - IMAGE_TAG: mips64el-muslabi64
142
+ # TARGET: mips64el-unknown-linux-muslabi64
143
+ # RUST_MUSL_MAKE_CONFIG: config.mak
144
+ # TOOLCHAIN: stable
145
+ # - IMAGE_TAG: mipsel-musl
146
+ # TARGET: mipsel-unknown-linux-musl
147
+ # RUST_MUSL_MAKE_CONFIG: config.mak
148
+ # TOOLCHAIN: stable
232
149
- IMAGE_TAG: s390x-musl
233
150
TARGET: s390x-unknown-linux-musl
234
151
RUST_MUSL_MAKE_CONFIG: config.mak
235
152
TOOLCHAIN: nightly
153
+ - IMAGE_TAG: riscv64gc-musl
154
+ TARGET: riscv64gc-unknown-linux-musl
155
+ MUSL_TARGET: riscv64-unknown-linux-musl
156
+ RUST_MUSL_MAKE_CONFIG: config.mak
157
+ TOOLCHAIN: stable
236
158
- IMAGE_TAG: x86_64-musl
237
159
TARGET: x86_64-unknown-linux-musl
238
160
RUST_MUSL_MAKE_CONFIG: config.mak
@@ -251,11 +173,6 @@ jobs:
251
173
env : ${{ matrix.env }}
252
174
steps :
253
175
- uses : actions/checkout@v4
254
- - name : Setup QEMU
255
- uses : dbhi/qus/action@main
256
- if : ${{ contains(matrix.os.runner, 'ubuntu-latest') }}
257
- - name : Setup Docker Buildx
258
- uses : docker/setup-buildx-action@v3
259
176
- name : Login to DockerHub
260
177
if : ${{ github.repository_owner == 'rust-cross' }}
261
178
uses : docker/login-action@v3
@@ -268,12 +185,17 @@ jobs:
268
185
registry : ghcr.io
269
186
username : ${{ github.repository_owner }}
270
187
password : ${{ secrets.GITHUB_TOKEN }}
188
+ - name : Setup QEMU
189
+ uses : docker/setup-qemu-action@v3
190
+ - name : Setup Docker Buildx
191
+ uses : docker/setup-buildx-action@v3
271
192
- name : docker build
272
193
uses : docker/build-push-action@v6
273
194
with :
274
195
platforms : linux/${{ matrix.os.docker_arch || matrix.os.arch }}
275
196
build-args : |
276
197
TARGET=${{ matrix.env.TARGET }}
198
+ MUSL_TARGET=${{ matrix.env.MUSL_TARGET || matrix.env.TARGET }}
277
199
RUST_MUSL_MAKE_CONFIG=${{ matrix.env.RUST_MUSL_MAKE_CONFIG }}
278
200
TOOLCHAIN=${{ matrix.env.TOOLCHAIN }}
279
201
tags : ghcr.io/${{ github.repository_owner }}/rust-musl-cross:${{ matrix.env.IMAGE_TAG }}-${{ matrix.os.arch }}
@@ -283,12 +205,13 @@ jobs:
283
205
cache-from : type=registry,ref=ghcr.io/${{ github.repository_owner }}/rust-musl-cross:buildcache-${{ matrix.env.IMAGE_TAG }}-${{ matrix.os.arch }}
284
206
cache-to : type=registry,ref=ghcr.io/${{ github.repository_owner }}/rust-musl-cross:buildcache-${{ matrix.env.IMAGE_TAG }}-${{ matrix.os.arch }},mode=max
285
207
- name : Test Docker cargo build
286
- if : ${{ matrix.os.arch == 'amd64' && !startsWith(matrix.env.TARGET, 'armv5te') && !startsWith(matrix.env.TARGET, 's390x') }}
208
+ if : ${{ matrix.os.arch == 'amd64' && !startsWith(matrix.env.TARGET, 'armv5te') && !startsWith(matrix.env.TARGET, 's390x') && !startsWith(matrix.env.TARGET, 'riscv64') }}
287
209
run : |
288
210
docker run --rm \
289
211
-v "$(pwd)/tests":/home/rust/src \
290
212
ghcr.io/${{ github.repository_owner }}/rust-musl-cross:$IMAGE_TAG-${{ matrix.os.arch }} bash -c "cargo build"
291
213
- name : Build and push multiarch image
214
+ if : ${{ github.event_name != 'pull_request' }}
292
215
env :
293
216
DOCKER_CLI_EXPERIMENTAL : enabled
294
217
run : |
@@ -330,12 +253,12 @@ jobs:
330
253
sed -n '1d;p' ghcr-manifest.yaml >> ghcr-manifest-target.yaml
331
254
./manifest-tool push from-spec ghcr-manifest-target.yaml
332
255
- name : Sync images to Docker Hub
333
- if : ${{ github.repository_owner == 'rust-cross' }}
256
+ if : ${{ github.repository_owner == 'rust-cross' && github.event_name != 'pull_request' }}
334
257
env :
335
258
DOCKER_CLI_EXPERIMENTAL : enabled
336
259
run : |
337
260
set -e
338
-
261
+
339
262
echo "image: ${{ secrets.DOCKER_USERNAME }}/rust-musl-cross:$IMAGE_TAG
340
263
manifests:" > dockerhub-manifest.yaml
341
264
0 commit comments