99 branches :
1010 - ' main'
1111
12+ concurrency :
13+ group : ${{ github.ref }}-stable
14+ cancel-in-progress : true
15+
16+ env :
17+ REGISTRY_IMAGE : clux/muslrust
18+
1219jobs :
13- docker :
20+ build :
1421 name : ' Stable Build'
1522 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
1636 steps :
1737 - uses : ' actions/checkout@v2'
1838 - uses : extractions/setup-just@v1
1939
40+ - name : Login to DockerHub
41+ uses : docker/login-action@v1
42+ with :
43+ username : clux
44+ password : ${{ secrets.DOCKERHUB_TOKEN }}
45+
2046 - name : Check if we need a new stable
2147 id : stablecheck
2248 shell : bash
@@ -27,59 +53,145 @@ jobs:
2753 echo '::set-output name=BUILD::YES'
2854 else
2955 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
3456 fi
3557
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+
3675 - name : Build stable image
76+ id : build
3777 uses : docker/build-push-action@v3
3878 with :
3979 context : .
80+ platforms : ${{ matrix.platform }}
81+ labels : ${{ steps.meta.outputs.labels }}
82+ file : ${{ matrix.dockerfile }}
83+ push : false
4084 load : true
85+ tags : rustmusl-temp
4186 build-args : |
4287 CHANNEL=stable
43- tags : clux/muslrust:temp
4488 if : ${{ steps.stablecheck.outputs.BUILD }}
4589
46- - name : Compute tags
90+ - name : Run tests
91+ if : ${{ steps.stablecheck.outputs.BUILD }}
4792 shell : bash
4893 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
51108 RUST_DATE="$(date +"%Y-%m-%d")"
52109 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
57115
58- - name : Echo tags
116+ - name : Tag and push
117+ if : ${{ steps.stablecheck.outputs.BUILD }}
59118 shell : bash
60119 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)
64123
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
66148 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
67159 if : ${{ steps.stablecheck.outputs.BUILD }}
68- run : just test
160+ uses : actions/download-artifact@v4
161+ with :
162+ path : /tmp/tags
163+ name : tags
69164
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
73177 with :
74178 username : clux
75179 password : ${{ secrets.DOCKERHUB_TOKEN }}
76180
77- - name : Push image under computed tags
78- uses : docker/build-push-action@v3
181+ - name : Create manifest list and push multi-platform images
79182 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