From b0b503261454b967985c3990c2bd00dcb6ef49d9 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 19 Jul 2022 16:12:24 +0200 Subject: [PATCH 1/2] Add multi-arch support to build.sh --- .github/workflows/build.yml | 20 ++++++++++++++++++++ build.sh | 16 +++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..0cc1644 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,20 @@ +name: CI +on: + release: + types: [released, prereleased] + workflow_dispatch: # allow manually running from the Actions tab + +jobs: + build: + runs-on: ubuntu-latest + env: + BUILDX_PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7 + steps: + - uses: actions/checkout@v2 + - uses: docker/setup-qemu-action@v1 + - uses: docker/setup-buildx-action@v1 + - uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - run: bash build.sh diff --git a/build.sh b/build.sh index 4ef712d..e7b4a79 100755 --- a/build.sh +++ b/build.sh @@ -3,10 +3,12 @@ set -e -o pipefail ./cp-static.sh tag=$(git describe --tags) -echo "Building $tag" +platforms=${BUILDX_PLATFORMS:-linux/amd64} +alias buildx_build="docker buildx build --platform=${platforms}" +echo "Building ${tag} for platforms ${platforms}" -docker build --pull py3-baseimage -t "stevearc/pypicloud:latest" -t "stevearc/pypicloud:$tag" -docker build --pull py3-alpine -t "stevearc/pypicloud:latest-alpine" -t "stevearc/pypicloud:$tag-alpine" +buildx_build --pull py3-baseimage -t "stevearc/pypicloud:latest" +buildx_build --pull py3-alpine -t "stevearc/pypicloud:latest-alpine" if [ "$1" == '--publish' ]; then if [ -n "$(git status --porcelain)" ]; then @@ -19,11 +21,11 @@ if [ "$1" == '--publish' ]; then ./test.sh latest ./test.sh latest-alpine echo "Tests passed" - docker push "stevearc/pypicloud:latest" - docker push "stevearc/pypicloud:latest-alpine" + buildx_build --push py3-baseimage -t "stevearc/pypicloud:latest" + buildx_build --push py3-alpine -t "stevearc/pypicloud:latest-alpine" if git describe --tags --exact-match; then - docker push "stevearc/pypicloud:$tag" - docker push "stevearc/pypicloud:$tag-alpine" + buildx_build --push py3-baseimage -t "stevearc/pypicloud:$tag" + buildx_build --push py3-alpine -t "stevearc/pypicloud:$tag-alpine" else echo "Not pushing $tag because it is not an exact version" fi From 23ba891942eefaa17e7fb9f273d9a07453933591 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Wed, 20 Jul 2022 16:55:43 +0200 Subject: [PATCH 2/2] PR Suggestion --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0cc1644..73cbf8a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,4 +17,4 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - run: bash build.sh + - run: bash build.sh --publish