9
9
branches :
10
10
- ' main'
11
11
12
+ concurrency :
13
+ group : ${{ github.ref }}-stable
14
+ cancel-in-progress : true
15
+
16
+ env :
17
+ REGISTRY_IMAGE : clux/muslrust
18
+
12
19
jobs :
13
- docker :
20
+ build :
14
21
name : ' Stable Build'
15
22
runs-on : ' ubuntu-latest'
23
+ strategy :
24
+ fail-fast : false
25
+ matrix :
26
+ platform : [linux/amd64, linux/arm64]
27
+ include :
28
+ - platform : linux/amd64
29
+ dockerfile : Dockerfile.x86_64
30
+ arch : amd64
31
+ target_dir : x86_64-unknown-linux-musl
32
+ - platform : linux/arm64
33
+ dockerfile : Dockerfile.arm64
34
+ arch : arm64
35
+ target_dir : aarch64-unknown-linux-musl
16
36
steps :
17
37
- uses : ' actions/checkout@v2'
18
38
- uses : extractions/setup-just@v1
19
39
40
+ - name : Login to DockerHub
41
+ uses : docker/login-action@v1
42
+ with :
43
+ username : clux
44
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
45
+
20
46
- name : Check if we need a new stable
21
47
id : stablecheck
22
48
shell : bash
@@ -27,59 +53,145 @@ jobs:
27
53
echo '::set-output name=BUILD::YES'
28
54
else
29
55
echo "Stable tag found; skipping all build steps"
30
- # Setting dummy tag evars to prevent steps below from failing
31
- echo "TAG1=clux/muslrust:no1" >> $GITHUB_ENV
32
- echo "TAG2=clux/muslrust:no2" >> $GITHUB_ENV
33
- echo "TAG3=clux/muslrust:no3" >> $GITHUB_ENV
34
56
fi
35
57
58
+ - name : Prepare
59
+ run : |
60
+ platform=${{ matrix.platform }}
61
+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
62
+
63
+ - name : Docker meta
64
+ id : meta
65
+ uses : docker/metadata-action@v5
66
+ with :
67
+ images : ${{ env.REGISTRY_IMAGE }}
68
+
69
+ - name : Set up QEMU
70
+ uses : docker/setup-qemu-action@v3
71
+
72
+ - name : Set up Docker Buildx
73
+ uses : docker/setup-buildx-action@v3
74
+
36
75
- name : Build stable image
76
+ id : build
37
77
uses : docker/build-push-action@v3
38
78
with :
39
79
context : .
80
+ platforms : ${{ matrix.platform }}
81
+ labels : ${{ steps.meta.outputs.labels }}
82
+ file : ${{ matrix.dockerfile }}
83
+ push : false
40
84
load : true
85
+ tags : rustmusl-temp
41
86
build-args : |
42
87
CHANNEL=stable
43
- tags : clux/muslrust:temp
44
88
if : ${{ steps.stablecheck.outputs.BUILD }}
45
89
46
- - name : Compute tags
90
+ - name : Run tests
91
+ if : ${{ steps.stablecheck.outputs.BUILD }}
47
92
shell : bash
48
93
run : |
49
- docker run clux/muslrust:temp rustc --version
50
- RUST_VER="$(docker run clux/muslrust:temp rustc --version | grep -oE "[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]")"
94
+ docker buildx build --platform ${{ matrix.platform }} --output type=docker -t test-runner - < Dockerfile.test-runner
95
+ TARGET_DIR=${{ matrix.target_dir }} PLATFORM=${{ matrix.platform }} just test
96
+
97
+ # The date/channel/version are expected to be the same on both architectures and are needed for the merge step.
98
+ # We store them here since it makes the merge step a bit easier - it doesn't need to figure out which of the
99
+ # architectures it can run (to extract the rust version). The problem is that it appears we can't run images
100
+ # that were built by docker buildx (the build-push-action step) locally. They get pushed to dockerhub but are
101
+ # only identifiable by their digest and it appears docker does not let us select an image that way.
102
+ # Not the most elegant, but it works.
103
+ - name : Store tag info
104
+ if : ${{ steps.stablecheck.outputs.BUILD }}
105
+ shell : bash
106
+ run : |
107
+ mkdir -p /tmp/tags
51
108
RUST_DATE="$(date +"%Y-%m-%d")"
52
109
RUST_CHANNEL=stable
53
- echo "TAG1=clux/muslrust:${RUST_CHANNEL}" >> $GITHUB_ENV
54
- echo "TAG2=clux/muslrust:${RUST_VER}-${RUST_CHANNEL}" >> $GITHUB_ENV
55
- echo "TAG3=clux/muslrust:${RUST_VER}" >> $GITHUB_ENV
56
- if : ${{ steps.stablecheck.outputs.BUILD }}
110
+ RUST_VER="$(docker run --platform ${{ matrix.platform }} rustmusl-temp rustc --version | grep -oE "[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]")"
111
+
112
+ echo $RUST_DATE > /tmp/tags/rust-date
113
+ echo $RUST_CHANNEL > /tmp/tags/rust-channel
114
+ echo $RUST_VER > /tmp/tags/rust-ver
57
115
58
- - name : Echo tags
116
+ - name : Tag and push
117
+ if : ${{ steps.stablecheck.outputs.BUILD }}
59
118
shell : bash
60
119
run : |
61
- echo $TAG1
62
- echo $TAG2
63
- echo $TAG3
120
+ RUST_DATE=$(cat /tmp/tags/rust-date)
121
+ RUST_CHANNEL=$(cat /tmp/tags/rust-channel)
122
+ RUST_VER=$(cat /tmp/tags/rust-ver)
64
123
65
- - name : Run tests
124
+ TAG_NAME="${{ matrix.arch }}-${RUST_VER}-${RUST_CHANNEL}-${RUST_DATE}"
125
+
126
+ docker tag rustmusl-temp ${{ env.REGISTRY_IMAGE }}:$TAG_NAME
127
+ docker push ${{ env.REGISTRY_IMAGE }}:$TAG_NAME
128
+
129
+ - name : Upload tags
130
+ if : ${{ steps.stablecheck.outputs.BUILD }}
131
+ uses : actions/upload-artifact@v4
132
+ with :
133
+ name : tags
134
+ path : /tmp/tags
135
+ if-no-files-found : error
136
+ retention-days : 1
137
+ overwrite : true
138
+
139
+ merge :
140
+ name : ' Stable merge'
141
+ runs-on : ubuntu-latest
142
+ needs :
143
+ - build
144
+ steps :
145
+ - uses : ' actions/checkout@v2'
146
+ - name : Check if we need a new stable
147
+ id : stablecheck
66
148
shell : bash
149
+ run : |
150
+ pip3 install --user toml
151
+ if python3 check_stable.py; then
152
+ echo "Stable tag missing; running all build steps"
153
+ echo '::set-output name=BUILD::YES'
154
+ else
155
+ echo "Stable tag found; skipping all build steps"
156
+ fi
157
+
158
+ - name : Download tags
67
159
if : ${{ steps.stablecheck.outputs.BUILD }}
68
- run : just test
160
+ uses : actions/download-artifact@v4
161
+ with :
162
+ path : /tmp/tags
163
+ name : tags
69
164
70
- - name : Login to DockerHub
71
- if : github.event_name != 'pull_request'
72
- uses : docker/login-action@v1
165
+ - name : Set up Docker Buildx
166
+ uses : docker/setup-buildx-action@v3
167
+
168
+ - name : Docker meta
169
+ id : meta
170
+ uses : docker/metadata-action@v5
171
+ with :
172
+ images : ${{ env.REGISTRY_IMAGE }}
173
+
174
+ - name : Login to Docker Hub
175
+ uses : docker/login-action@v3
176
+ if : false
73
177
with :
74
178
username : clux
75
179
password : ${{ secrets.DOCKERHUB_TOKEN }}
76
180
77
- - name : Push image under computed tags
78
- uses : docker/build-push-action@v3
181
+ - name : Create manifest list and push multi-platform images
79
182
if : ${{ steps.stablecheck.outputs.BUILD }}
80
- with :
81
- context : .
82
- build-args : |
83
- CHANNEL=stable
84
- push : ${{ steps.stablecheck.outputs.BUILD == 'YES' && github.event_name != 'pull_request' }}
85
- tags : ${{ env.TAG1 }},${{ env.TAG2 }},${{ env.TAG3 }}
183
+ run : |
184
+ RUST_DATE=$(cat /tmp/tags/rust-date)
185
+ RUST_CHANNEL=$(cat /tmp/tags/rust-channel)
186
+ RUST_VER=$(cat /tmp/tags/rust-ver)
187
+
188
+ for tag in ${RUST_CHANNEL} ${RUST_CHANNEL}-${RUST_DATE} ${RUST_VER}-${RUST_CHANNEL}-${RUST_DATE}; do
189
+ docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:$tag \
190
+ ${{ env.REGISTRY_IMAGE }}:amd64-${RUST_VER}-${RUST_CHANNEL}-${RUST_DATE} \
191
+ ${{ env.REGISTRY_IMAGE }}:arm64-${RUST_VER}-${RUST_CHANNEL}-${RUST_DATE}
192
+ done
193
+
194
+ - name : Inspect image
195
+ if : ${{ steps.stablecheck.outputs.BUILD }}
196
+ run : |
197
+ docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:latest
0 commit comments