From cf70b18140adad0b900619b4ff8206744ac2bf79 Mon Sep 17 00:00:00 2001 From: Diego Braga Date: Mon, 23 Dec 2024 16:01:31 +0100 Subject: [PATCH 01/13] fix: amd64 image not generated --- .github/workflows/release-pullrequest.yaml | 82 +++++--------- .github/workflows/release-tag.yaml | 125 ++++++++++++--------- 2 files changed, 100 insertions(+), 107 deletions(-) diff --git a/.github/workflows/release-pullrequest.yaml b/.github/workflows/release-pullrequest.yaml index c225dcf..d81a76e 100644 --- a/.github/workflows/release-pullrequest.yaml +++ b/.github/workflows/release-pullrequest.yaml @@ -1,78 +1,48 @@ -name: release-pullrequest +name: release-tag on: - pull_request: - branches: - - main + push: + tags: [ '[0-9]+.[0-9]+.[0-9]+' ] env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + GHCR_REPO: ghcr.io/${{ github.repository }} jobs: - build-and-push: - name: Build and Push + build: + runs-on: ubuntu-latest 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 }} - - permissions: - contents: read - packages: write - + platform: + - linux/amd64 + - linux/arm64 steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Prepare + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.GHCR_REPO }} - - name: Log in to the Container registry + - name: Login to GHCR uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - with: - # Create a new builder instance - install: true - driver-opts: | - image=moby/buildkit:latest - buildkitd-flags: --debug - - name: Build and push - uses: docker/build-push-action@v5 + - name: Build and push by digest + id: build + uses: docker/build-push-action@v6 with: - context: . platforms: ${{ matrix.platform }} push: false - tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: 'stable' - - name: Gather dependencies - run: go mod download - - name: Run coverage - run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file + outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true \ No newline at end of file diff --git a/.github/workflows/release-tag.yaml b/.github/workflows/release-tag.yaml index 6270b33..478718c 100644 --- a/.github/workflows/release-tag.yaml +++ b/.github/workflows/release-tag.yaml @@ -5,77 +5,100 @@ on: tags: [ '[0-9]+.[0-9]+.[0-9]+' ] env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + GHCR_REPO: ghcr.io/${{ github.repository }} jobs: - build-and-push: - name: Build and Push + build: + runs-on: ubuntu-latest 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 }} - - permissions: - contents: read - packages: write - + platform: + - linux/amd64 + - linux/arm64 steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Prepare + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.GHCR_REPO }} - - name: Log in to the Container registry + - name: Login to GHCR uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - with: - # Create a new builder instance - install: true - driver-opts: | - image=moby/buildkit:latest - buildkitd-flags: --debug - - name: Build and push - uses: docker/build-push-action@v5 + - name: Build and push by digest + id: build + uses: docker/build-push-action@v6 with: - context: . platforms: ${{ matrix.platform }} - push: true - tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - - - name: Inspect image + outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true + + - name: Export digest run: | - docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }} + 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 - test: + merge: runs-on: ubuntu-latest + needs: + - build steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + - name: Download digests + uses: actions/download-artifact@v4 with: - go-version: 'stable' - - name: Gather dependencies - run: go mod download - - name: Run coverage - run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 + path: /tmp/digests + pattern: digests-* + merge-multiple: true + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + 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: - token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file + images: ${{ env.GHCR_REPO }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - 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 }} \ No newline at end of file From 7aaf518b538fb70e31627911b60af1c5c9ea288f Mon Sep 17 00:00:00 2001 From: Diego Braga Date: Mon, 23 Dec 2024 16:04:44 +0100 Subject: [PATCH 02/13] fix: amd64 image not generated --- .github/workflows/release-pullrequest.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-pullrequest.yaml b/.github/workflows/release-pullrequest.yaml index d81a76e..e52543a 100644 --- a/.github/workflows/release-pullrequest.yaml +++ b/.github/workflows/release-pullrequest.yaml @@ -1,8 +1,9 @@ name: release-tag on: - push: - tags: [ '[0-9]+.[0-9]+.[0-9]+' ] + pull_request: + branches: + - main env: GHCR_REPO: ghcr.io/${{ github.repository }} From 401064a4e495d3633b709088be2ced28c801e353 Mon Sep 17 00:00:00 2001 From: Diego Braga Date: Mon, 23 Dec 2024 16:09:45 +0100 Subject: [PATCH 03/13] fix: amd64 image not generated --- .github/workflows/release-pullrequest.yaml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-pullrequest.yaml b/.github/workflows/release-pullrequest.yaml index e52543a..44d9454 100644 --- a/.github/workflows/release-pullrequest.yaml +++ b/.github/workflows/release-pullrequest.yaml @@ -10,13 +10,17 @@ env: jobs: build: - runs-on: ubuntu-latest + name: Build and Push strategy: - fail-fast: false matrix: - platform: - - linux/amd64 - - linux/arm64 + 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 }} + steps: - name: Prepare run: | @@ -46,4 +50,5 @@ jobs: platforms: ${{ matrix.platform }} push: false labels: ${{ steps.meta.outputs.labels }} + tags: ${{ steps.meta.outputs.tags }} outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true \ No newline at end of file From 72cee7a8e7742099c2fee815e22ab66c8ecd1b23 Mon Sep 17 00:00:00 2001 From: Diego Braga Date: Mon, 23 Dec 2024 16:13:33 +0100 Subject: [PATCH 04/13] fix: amd64 image not generated --- .github/workflows/release-pullrequest.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-pullrequest.yaml b/.github/workflows/release-pullrequest.yaml index 44d9454..244af2e 100644 --- a/.github/workflows/release-pullrequest.yaml +++ b/.github/workflows/release-pullrequest.yaml @@ -43,12 +43,11 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build and push by digest + - name: Build and NOT push id: build - uses: docker/build-push-action@v6 + uses: docker/build-push-action@v5 with: platforms: ${{ matrix.platform }} push: false labels: ${{ steps.meta.outputs.labels }} - tags: ${{ steps.meta.outputs.tags }} - outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true \ No newline at end of file + tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file From bed1d610134e23ac055360c40fb1e5f3547523c6 Mon Sep 17 00:00:00 2001 From: Diego Braga Date: Mon, 23 Dec 2024 16:22:13 +0100 Subject: [PATCH 05/13] fix: amd64 image not generated --- .github/workflows/release-tag.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-tag.yaml b/.github/workflows/release-tag.yaml index 478718c..c93dc7e 100644 --- a/.github/workflows/release-tag.yaml +++ b/.github/workflows/release-tag.yaml @@ -43,8 +43,9 @@ jobs: uses: docker/build-push-action@v6 with: platforms: ${{ matrix.platform }} + push: true labels: ${{ steps.meta.outputs.labels }} - outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true + tags: ${{ steps.meta.outputs.tags }} - name: Export digest run: | From 82cb32324469c3b53b37cb99ebd840971744c248 Mon Sep 17 00:00:00 2001 From: Diego Braga Date: Mon, 23 Dec 2024 16:36:51 +0100 Subject: [PATCH 06/13] fix: amd64 image not generated --- .github/workflows/release-tag.yaml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-tag.yaml b/.github/workflows/release-tag.yaml index c93dc7e..1b445ab 100644 --- a/.github/workflows/release-tag.yaml +++ b/.github/workflows/release-tag.yaml @@ -9,13 +9,17 @@ env: jobs: build: - runs-on: ubuntu-latest + name: Build and Push strategy: - fail-fast: false matrix: - platform: - - linux/amd64 - - linux/arm64 + 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 }} + steps: - name: Prepare run: | @@ -40,7 +44,7 @@ jobs: - name: Build and push by digest id: build - uses: docker/build-push-action@v6 + uses: docker/build-push-action@v5 with: platforms: ${{ matrix.platform }} push: true From 01f5e202d82daa7dc01e1c8500cfa2c70d993f89 Mon Sep 17 00:00:00 2001 From: Diego Braga Date: Mon, 23 Dec 2024 16:55:00 +0100 Subject: [PATCH 07/13] fix: amd64 image not generated --- .github/workflows/release-tag.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-tag.yaml b/.github/workflows/release-tag.yaml index b409148..c3dc73d 100644 --- a/.github/workflows/release-tag.yaml +++ b/.github/workflows/release-tag.yaml @@ -37,7 +37,7 @@ jobs: uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ github.actor }} + username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx @@ -51,6 +51,7 @@ jobs: push: true labels: ${{ steps.meta.outputs.labels }} tags: ${{ steps.meta.outputs.tags }} + outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true - name: Export digest run: | @@ -82,7 +83,7 @@ jobs: uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ github.actor }} + username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx From 635e47b8617ca4eb6bb0665b425743204cce9882 Mon Sep 17 00:00:00 2001 From: Diego Braga Date: Mon, 23 Dec 2024 17:05:20 +0100 Subject: [PATCH 08/13] fix: amd64 image not generated --- .github/workflows/release-pullrequest.yaml | 7 ++++--- .github/workflows/release-tag.yaml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-pullrequest.yaml b/.github/workflows/release-pullrequest.yaml index 244af2e..92dfb66 100644 --- a/.github/workflows/release-pullrequest.yaml +++ b/.github/workflows/release-pullrequest.yaml @@ -37,7 +37,7 @@ jobs: uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ github.actor }} + username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx @@ -45,9 +45,10 @@ jobs: - name: Build and NOT push id: build - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: platforms: ${{ matrix.platform }} push: false labels: ${{ steps.meta.outputs.labels }} - tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file + tags: ${{ steps.meta.outputs.tags }} + outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true \ No newline at end of file diff --git a/.github/workflows/release-tag.yaml b/.github/workflows/release-tag.yaml index c3dc73d..c1e52c3 100644 --- a/.github/workflows/release-tag.yaml +++ b/.github/workflows/release-tag.yaml @@ -45,7 +45,7 @@ jobs: - name: Build and push by digest id: build - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: platforms: ${{ matrix.platform }} push: true From 7be1cca40578bcfa9eb23219b76db2b2244fdd51 Mon Sep 17 00:00:00 2001 From: Diego Braga Date: Mon, 23 Dec 2024 17:09:30 +0100 Subject: [PATCH 09/13] fix: amd64 image not generated --- .github/workflows/release-pullrequest.yaml | 1 - .github/workflows/release-tag.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/release-pullrequest.yaml b/.github/workflows/release-pullrequest.yaml index 92dfb66..8e8047b 100644 --- a/.github/workflows/release-pullrequest.yaml +++ b/.github/workflows/release-pullrequest.yaml @@ -50,5 +50,4 @@ jobs: platforms: ${{ matrix.platform }} push: false labels: ${{ steps.meta.outputs.labels }} - tags: ${{ steps.meta.outputs.tags }} outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true \ No newline at end of file diff --git a/.github/workflows/release-tag.yaml b/.github/workflows/release-tag.yaml index c1e52c3..f465abc 100644 --- a/.github/workflows/release-tag.yaml +++ b/.github/workflows/release-tag.yaml @@ -50,7 +50,6 @@ jobs: platforms: ${{ matrix.platform }} push: true labels: ${{ steps.meta.outputs.labels }} - tags: ${{ steps.meta.outputs.tags }} outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true - name: Export digest From 644abd9d92f1a64dabb4659a60ab057d303c3d8d Mon Sep 17 00:00:00 2001 From: Diego Braga Date: Mon, 23 Dec 2024 17:13:54 +0100 Subject: [PATCH 10/13] fix: amd64 image not generated --- .github/workflows/release-pullrequest.yaml | 2 +- .github/workflows/release-tag.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-pullrequest.yaml b/.github/workflows/release-pullrequest.yaml index 8e8047b..2268d0e 100644 --- a/.github/workflows/release-pullrequest.yaml +++ b/.github/workflows/release-pullrequest.yaml @@ -45,7 +45,7 @@ jobs: - name: Build and NOT push id: build - uses: docker/build-push-action@v6 + uses: docker/build-push-action@v5 with: platforms: ${{ matrix.platform }} push: false diff --git a/.github/workflows/release-tag.yaml b/.github/workflows/release-tag.yaml index f465abc..d61b2e3 100644 --- a/.github/workflows/release-tag.yaml +++ b/.github/workflows/release-tag.yaml @@ -45,7 +45,7 @@ jobs: - name: Build and push by digest id: build - uses: docker/build-push-action@v6 + uses: docker/build-push-action@v5 with: platforms: ${{ matrix.platform }} push: true From 589d1f9cdac10da1852b5d8335fb9a455b49d396 Mon Sep 17 00:00:00 2001 From: Diego Braga Date: Mon, 23 Dec 2024 17:18:53 +0100 Subject: [PATCH 11/13] fix: amd64 image not generated --- .github/workflows/release-pullrequest.yaml | 4 ++++ .github/workflows/release-tag.yaml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/release-pullrequest.yaml b/.github/workflows/release-pullrequest.yaml index 2268d0e..c80e5ed 100644 --- a/.github/workflows/release-pullrequest.yaml +++ b/.github/workflows/release-pullrequest.yaml @@ -21,6 +21,10 @@ jobs: platform: linux/amd64 runs-on: ${{ matrix.runner }} + permissions: + contents: read + packages: write + steps: - name: Prepare run: | diff --git a/.github/workflows/release-tag.yaml b/.github/workflows/release-tag.yaml index d61b2e3..2b36829 100644 --- a/.github/workflows/release-tag.yaml +++ b/.github/workflows/release-tag.yaml @@ -21,6 +21,10 @@ jobs: platform: linux/amd64 runs-on: ${{ matrix.runner }} + permissions: + contents: read + packages: write + steps: - name: Prepare run: | From 55a0edcb8b1a75e81b95a020a824e9e81cbb7ca0 Mon Sep 17 00:00:00 2001 From: Diego Braga Date: Mon, 23 Dec 2024 17:22:00 +0100 Subject: [PATCH 12/13] fix: amd64 image not generated --- .github/workflows/release-pullrequest.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release-pullrequest.yaml b/.github/workflows/release-pullrequest.yaml index c80e5ed..8199f01 100644 --- a/.github/workflows/release-pullrequest.yaml +++ b/.github/workflows/release-pullrequest.yaml @@ -53,5 +53,4 @@ jobs: with: platforms: ${{ matrix.platform }} push: false - labels: ${{ steps.meta.outputs.labels }} - outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From a5cb8ba51b76b4e2b4fd97cf9875623ffb19c0ee Mon Sep 17 00:00:00 2001 From: Diego Braga Date: Mon, 23 Dec 2024 17:42:31 +0100 Subject: [PATCH 13/13] fix: amd64 image not generated --- .github/workflows/release-tag.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-tag.yaml b/.github/workflows/release-tag.yaml index 2b36829..acdcaaa 100644 --- a/.github/workflows/release-tag.yaml +++ b/.github/workflows/release-tag.yaml @@ -74,6 +74,9 @@ jobs: runs-on: ubuntu-latest needs: - build + permissions: + contents: read + packages: write steps: - name: Download digests uses: actions/download-artifact@v4 @@ -97,11 +100,6 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ env.GHCR_REPO }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - name: Create manifest list and push working-directory: /tmp/digests