From 3ecb0d3d939b127fa47460ea07008bc6621e4fa5 Mon Sep 17 00:00:00 2001 From: Gerald Pinder Date: Sun, 11 Aug 2024 12:06:31 -0400 Subject: [PATCH] chore: Fix tag CI to build prebuild separately from main build --- .github/workflows/tag.yml | 73 ++++++++++++++++++++++++++++++++++++++- Earthfile | 12 +++---- 2 files changed, 78 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 320de9bd..8f7503ed 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -9,11 +9,82 @@ env: FORCE_COLOR: 1 jobs: + arm64-prebuild: + timeout-minutes: 60 + runs-on: ubuntu-latest + + steps: + - uses: earthly/actions-setup@v1 + + - name: Earthly login + env: + EARTHLY_SAT_TOKEN: ${{ secrets.EARTHLY_SAT_TOKEN }} + if: env.EARTHLY_SAT_TOKEN != null + run: | + earthly account login --token ${{ secrets.EARTHLY_SAT_TOKEN }} >> /dev/null + earthly org s blue-build + earthly sat s arm + + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + if: github.token != null + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + + - name: Run build + id: build + run: | + earthly --ci --push -P +prebuild + + amd64-prebuild: + timeout-minutes: 60 + runs-on: ubuntu-latest + + steps: + - uses: earthly/actions-setup@v1 + + - name: Earthly login + env: + EARTHLY_SAT_TOKEN: ${{ secrets.EARTHLY_SAT_TOKEN }} + if: env.EARTHLY_SAT_TOKEN != null + run: | + earthly account login --token ${{ secrets.EARTHLY_SAT_TOKEN }} >> /dev/null + earthly org s blue-build + earthly sat s amd + + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + if: github.token != null + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + + - name: Run build + id: build + run: | + earthly --ci --push -P +prebuild + tag: permissions: packages: write timeout-minutes: 60 runs-on: ubuntu-latest + needs: + - arm64-prebuild + - amd64-prebuild steps: # Setup repo and add caching @@ -42,4 +113,4 @@ jobs: LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) CARGO_PACKAGE_VERSION="v$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "blue-build") .version')" LATEST=$(test "$CARGO_PACKAGE_VERSION" = "$LATEST_TAG" && echo true || echo false) - earthly --push --ci -P +all --TAGGED="true" --LATEST="$LATEST" + earthly --push --ci -P +build --TAGGED="true" --LATEST="$LATEST" diff --git a/Earthfile b/Earthfile index 82656094..dbe82da0 100644 --- a/Earthfile +++ b/Earthfile @@ -78,7 +78,7 @@ build-scripts: ARG BASE_IMAGE="alpine" FROM $BASE_IMAGE - COPY (+digest/base-image-digest --BASE_IMAGE=$BASE_IMAGE) /base-image-digest + COPY --platform=native (+digest/base-image-digest --BASE_IMAGE=$BASE_IMAGE) /base-image-digest LABEL org.opencontainers.image.base.name="$BASE_IMAGE" LABEL org.opencontainers.image.base.digest="$(cat /base-image-digest)" @@ -94,7 +94,7 @@ blue-build-cli-prebuild: ARG BASE_IMAGE="registry.fedoraproject.org/fedora-toolbox" FROM DOCKERFILE -f Dockerfile.fedora . - COPY (+digest/base-image-digest --BASE_IMAGE=$BASE_IMAGE) /base-image-digest + COPY --platform=native (+digest/base-image-digest --BASE_IMAGE=$BASE_IMAGE) /base-image-digest LABEL org.opencontainers.image.base.name="$BASE_IMAGE" LABEL org.opencontainers.image.base.digest="$(cat /base-image-digest)" @@ -124,7 +124,7 @@ blue-build-cli-alpine-prebuild: ARG BASE_IMAGE="alpine" FROM DOCKERFILE -f Dockerfile.alpine . - COPY (+digest/base-image-digest --BASE_IMAGE=$BASE_IMAGE) /base-image-digest + COPY --platform=native (+digest/base-image-digest --BASE_IMAGE=$BASE_IMAGE) /base-image-digest LABEL org.opencontainers.image.base.name="$BASE_IMAGE" LABEL org.opencontainers.image.base.digest="$(cat /base-image-digest)" @@ -155,7 +155,7 @@ installer: ARG BASE_IMAGE="alpine" FROM $BASE_IMAGE - COPY (+digest/base-image-digest --BASE_IMAGE=$BASE_IMAGE) /base-image-digest + COPY --platform=native (+digest/base-image-digest --BASE_IMAGE=$BASE_IMAGE) /base-image-digest LABEL org.opencontainers.image.base.name="$BASE_IMAGE" LABEL org.opencontainers.image.base.digest="$(cat /base-image-digest)" @@ -205,9 +205,9 @@ INSTALL: ARG --required OUT_DIR IF [ "$TAGGED" = "true" ] - COPY (+install/bluebuild --BUILD_TARGET="$BUILD_TARGET") $OUT_DIR + COPY --platform=native (+install/bluebuild --BUILD_TARGET="$BUILD_TARGET") $OUT_DIR ELSE - COPY (+install-all-features/bluebuild --BUILD_TARGET="$BUILD_TARGET") $OUT_DIR + COPY --platform=native (+install-all-features/bluebuild --BUILD_TARGET="$BUILD_TARGET") $OUT_DIR END SAVE_IMAGE: