Skip to content

Commit b54a6b6

Browse files
authored
Auto-publish Arm64 images when emscripten-releases-tags.json is updated (#1231)
Add job to conditionally build arm64 images when emscripten-releases-tags.json updated
1 parent e2627e2 commit b54a6b6

File tree

2 files changed

+59
-5
lines changed

2 files changed

+59
-5
lines changed

.circleci/config.yml

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ executors:
2727
resource_class: macos.m1.medium.gen1
2828
linux_arm64:
2929
machine:
30-
image: ubuntu-2004:202101-01
30+
image: ubuntu-2004:2023.07.1
3131
resource_class: arm.medium
3232

3333
commands:
@@ -173,7 +173,7 @@ jobs:
173173
$env:SYSTEM_FLAG="--system"
174174
test/test_path_preservation.ps1
175175
176-
build-docker-image:
176+
build-docker-image-x64:
177177
executor: bionic
178178
steps:
179179
- checkout
@@ -189,7 +189,7 @@ jobs:
189189
name: test
190190
command: make -C ./docker version=tot test
191191

192-
publish-docker-image:
192+
publish-docker-image-x64:
193193
executor: bionic
194194
steps:
195195
- checkout
@@ -209,6 +209,53 @@ jobs:
209209
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
210210
make -C ./docker version=${CIRCLE_TAG} alias=latest push
211211
212+
publish-docker-image-arm64:
213+
executor: linux_arm64
214+
steps:
215+
- checkout
216+
- run:
217+
name: check if emscripten-releases-tags.json has changed
218+
command: |
219+
CHANGED_FILES=$(git diff --name-only <<pipeline.git.base_revision>>..<<pipeline.git.revision>>)
220+
if [[ ! $CHANGED_FILES =~ "emscripten-releases-tags.json" ]]; then
221+
echo "emscripten-releases-tags.json has not changed, skipping build and publish"
222+
circleci-agent step halt
223+
fi
224+
- run:
225+
name: extract latest emscripten arm64 linux version
226+
command: |
227+
ARM64_VERSION=$(grep -oP '(?<="latest-arm64-linux": ")[^"]*' emscripten-releases-tags.json)
228+
ARM64_IMAGE_TAG=${ARM64_VERSION}-arm64
229+
echo "export ARM64_VERSION=$ARM64_VERSION" >> $BASH_ENV
230+
echo "export ARM64_IMAGE_TAG=$ARM64_IMAGE_TAG" >> $BASH_ENV
231+
echo "ARM64_VERSION=$ARM64_VERSION"
232+
echo "ARM64_IMAGE_TAG=$ARM64_IMAGE_TAG"
233+
- run:
234+
name: check if docker image already exists
235+
command: |
236+
if [ -z "$ARM64_VERSION" ]; then
237+
echo "ARM64_VERSION is empty, skipping publish"
238+
circleci-agent step halt
239+
exit 0
240+
fi
241+
DOCKER_IMAGE_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" https://hub.docker.com/v2/repositories/emscripten/emsdk/tags/$ARM64_IMAGE_TAG)
242+
if [ "$DOCKER_IMAGE_EXISTS" = "200" ]; then
243+
echo "Docker image: $ARM64_VERSION"
244+
echo "Docker image already exists, skipping build and publish"
245+
circleci-agent step halt
246+
fi
247+
- run:
248+
name: build
249+
command: make -C ./docker version=${ARM64_VERSION} build
250+
- run:
251+
name: test
252+
command: make -C ./docker version=${ARM64_VERSION} test
253+
- run:
254+
name: push image
255+
command: |
256+
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
257+
make -C ./docker version=${ARM64_VERSION} alias=${ARM64_IMAGE_TAG} only_alias=true push
258+
212259
test-bazel-linux:
213260
executor: bionic
214261
steps:
@@ -284,13 +331,17 @@ workflows:
284331
- test-windows
285332
build-docker-image:
286333
jobs:
287-
- build-docker-image
288-
- publish-docker-image:
334+
- build-docker-image-x64
335+
- publish-docker-image-x64:
289336
filters:
290337
branches:
291338
ignore: /.*/
292339
tags:
293340
only: /.*/
341+
- publish-docker-image-arm64:
342+
filters:
343+
branches:
344+
only: main
294345
test-bazel-linux:
295346
jobs:
296347
- test-bazel-linux

docker/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# i.e.: 1.39.18
55
version =
66
alias =
7+
only_alias =
78

89
image_name ?= emscripten/emsdk
910

@@ -21,7 +22,9 @@ test: test_dockerimage.sh .TEST
2122
docker run --rm -u `id -u`:`id -g` -w /emsdk/docker --net=host --entrypoint /bin/bash ${image_name}:${version} $<
2223

2324
push: .TEST
25+
ifndef only_alias
2426
docker push ${image_name}:${version}
27+
endif
2528
ifdef alias
2629
docker tag ${image_name}:${version} ${image_name}:${alias}
2730
docker push ${image_name}:${alias}

0 commit comments

Comments
 (0)