diff --git a/.github/workflows/release-pullrequest.yaml b/.github/workflows/release-pullrequest.yaml index dc17291..428bf0e 100644 --- a/.github/workflows/release-pullrequest.yaml +++ b/.github/workflows/release-pullrequest.yaml @@ -7,29 +7,19 @@ on: env: GHCR_REPO: ghcr.io/${{ github.repository }} + LOCAL_KIND: false jobs: build: - name: Build and Push - strategy: - matrix: - runner: [buildjet-2vcpu-ubuntu-2204-arm, buildjet-2vcpu-ubuntu-2204] - include: - - runner: buildjet-2vcpu-ubuntu-2204-arm - platform: linux/arm64 - - runner: buildjet-2vcpu-ubuntu-2204 - platform: linux/amd64 - runs-on: ${{ matrix.runner }} + runs-on: ubuntu-latest permissions: contents: read packages: write steps: - - name: Prepare - run: | - platform=${{ matrix.platform }} - echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + - name: Checkout + uses: actions/checkout@v4 - name: Docker meta id: meta @@ -37,23 +27,26 @@ jobs: with: images: ${{ env.GHCR_REPO }} - - name: Login to GHCR - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build and NOT push - id: build + - name: Build (no push) uses: docker/build-push-action@v5 with: - platforms: ${{ matrix.platform }} push: false + load: ${{ env.LOCAL_KIND == 'true' }} + no-cache: ${{ env.LOCAL_KIND == 'true' }} + platforms: ${{ env.LOCAL_KIND == 'true' && 'linux/amd64' || 'linux/amd64,linux/arm64' }} + tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + CACHEBUST=${{ github.sha }} + COMMIT_HASH=${{ github.sha }} + cache-from: ${{ env.LOCAL_KIND == 'true' && '' || 'type=gha' }} + cache-to: ${{ env.LOCAL_KIND == 'true' && '' || 'type=gha,mode=max' }} test: runs-on: ubuntu-latest diff --git a/.github/workflows/release-tag.yaml b/.github/workflows/release-tag.yaml index 5163ee7..07ed365 100644 --- a/.github/workflows/release-tag.yaml +++ b/.github/workflows/release-tag.yaml @@ -6,30 +6,20 @@ on: env: GHCR_REPO: ghcr.io/${{ github.repository }} + DOCKER_PUSH: true + LOCAL_KIND: false jobs: - build: - name: Build and Push - strategy: - fail-fast: false - matrix: - runner: [buildjet-2vcpu-ubuntu-2204-arm, buildjet-2vcpu-ubuntu-2204] - include: - - runner: buildjet-2vcpu-ubuntu-2204-arm - platform: linux/arm64 - - runner: buildjet-2vcpu-ubuntu-2204 - platform: linux/amd64 - runs-on: ${{ matrix.runner }} - + build-and-push: + runs-on: ubuntu-latest + permissions: contents: read packages: write steps: - - name: Prepare - run: | - platform=${{ matrix.platform }} - echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + - name: Checkout + uses: actions/checkout@v4 - name: Docker meta id: meta @@ -38,78 +28,33 @@ jobs: images: ${{ env.GHCR_REPO }} - name: Login to GHCR + if: env.DOCKER_PUSH == 'true' uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build and push by digest - id: build + - name: Build and push uses: docker/build-push-action@v5 with: - platforms: ${{ matrix.platform }} - push: true + push: ${{ env.DOCKER_PUSH == 'true' }} + load: ${{ env.LOCAL_KIND == 'true' }} + no-cache: ${{ env.LOCAL_KIND == 'true' }} + platforms: ${{ env.LOCAL_KIND == 'true' && 'linux/amd64' || 'linux/amd64,linux/arm64' }} + tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true - - - name: Export digest - run: | - mkdir -p /tmp/digests - digest="${{ steps.build.outputs.digest }}" - touch "/tmp/digests/${digest#sha256:}" - - - name: Upload digest - uses: actions/upload-artifact@v4 - with: - name: digests-${{ env.PLATFORM_PAIR }} - path: /tmp/digests/* - if-no-files-found: error - retention-days: 1 - - merge: - runs-on: ubuntu-latest - needs: - - build - permissions: - contents: read - packages: write - steps: - - name: Download digests - uses: actions/download-artifact@v4 - with: - path: /tmp/digests - pattern: digests-* - merge-multiple: true - - - name: Login to GHCR - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.GHCR_REPO }} - - - name: Create manifest list and push - working-directory: /tmp/digests - run: | - docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.GHCR_REPO }}@sha256:%s ' *) - - - name: Inspect image - run: | - docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }} + build-args: | + CACHEBUST=${{ github.sha }} + COMMIT_HASH=${{ github.sha }} + cache-from: ${{ env.LOCAL_KIND == 'true' && '' || 'type=gha' }} + cache-to: ${{ env.LOCAL_KIND == 'true' && '' || 'type=gha,mode=max' }} test: runs-on: ubuntu-latest