From 2df6c2a770a33e751e8e0bc04f89c07a1fa5aee4 Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Wed, 7 Jun 2023 11:30:37 +0200 Subject: [PATCH 01/15] Update GHA workflows --- .github/workflows/release.yml | 6 +++--- .github/workflows/run_tests.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 12de1fee..3f15aa8e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: # Install golang - uses: actions/setup-go@v2 with: - go-version: '^1.16' + go-version: '^1.20' # Install external go modules before cloning - run: go install github.com/laher/goxc@latest @@ -26,9 +26,9 @@ jobs: - uses: actions/cache@v2 with: path: ~/go/pkg/mod - key: ubuntu-latest-1.16-go-${{ hashFiles('**/go.sum') }} + key: ubuntu-latest-1.20-go-${{ hashFiles('**/go.sum') }} restore-keys: | - ubuntu-latest-1.16-go- + ubuntu-latest-1.20-go- # build binaries for all supported environments - run: sudo apt update && sudo apt install -y make diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 5d381c75..4f759b72 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -6,7 +6,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - golang-version: [1.13, 1.14, 1.15, 1.16, 1.17] + golang-version: [1.20] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 From 64eb7661d9898b089dfce8f2dbb5e11c36682534 Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Wed, 7 Jun 2023 11:39:48 +0200 Subject: [PATCH 02/15] Replace no longer available checksums action --- .github/workflows/release.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3f15aa8e..30126811 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: # Install golang - uses: actions/setup-go@v2 with: - go-version: '^1.20' + go-version: "^1.20" # Install external go modules before cloning - run: go install github.com/laher/goxc@latest @@ -29,7 +29,7 @@ jobs: key: ubuntu-latest-1.20-go-${{ hashFiles('**/go.sum') }} restore-keys: | ubuntu-latest-1.20-go- - + # build binaries for all supported environments - run: sudo apt update && sudo apt install -y make - run: make build-all @@ -38,11 +38,12 @@ jobs: - name: Get the version id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} - - name: Create checksums - run: | - readonly BUILD_DIR="build/${{ steps.get_version.outputs.VERSION }}" - find "$BUILD_DIR" -type f -exec sha256sum {} + | awk -v build_dir="$BUILD_DIR" '{sub("^"build_dir"/", ""); print $1, $2}' > SHA256SUMS - find "$BUILD_DIR" -type f -exec sha512sum {} + | awk -v build_dir="$BUILD_DIR" '{sub("^"build_dir"/", ""); print $1, $2}' > SHA512SUMS + - uses: jmgilman/actions-generate-checksum@v1 + id: checksums + with: + patterns: "build/${{ steps.get_version.outputs.VERSION }}/*" + method: sha512 + output: checksums.txt # Create the release - uses: "marvinpinto/action-automatic-releases@latest" @@ -51,5 +52,4 @@ jobs: prerelease: false files: | build/${{ steps.get_version.outputs.VERSION }}/* - SHA256SUMS - SHA512SUMS + checksums.txt From ab9cea9d9a6854a1b55d409834e6674dc9a22a30 Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Tue, 20 Jun 2023 16:11:27 +0300 Subject: [PATCH 03/15] Replace deprecated ::set-output in release GHA workflow --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 30126811..e092edab 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,7 @@ jobs: # Create the binary checksums - name: Get the version id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} + run: echo VERSION=${GITHUB_REF#refs/tags/v} >> $GITHUB_OUTPUT - uses: jmgilman/actions-generate-checksum@v1 id: checksums with: From 8b54e7381b25c69b2102de7cfb1f0c0dd6426996 Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Tue, 10 Oct 2023 15:28:17 +0200 Subject: [PATCH 04/15] Update x-compile workflow --- .github/workflows/release.yml | 3 --- Makefile | 44 ++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e092edab..8a2553b5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,9 +16,6 @@ jobs: with: go-version: "^1.20" - # Install external go modules before cloning - - run: go install github.com/laher/goxc@latest - # Checkout code - uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index 47606911..c0b0d4f2 100644 --- a/Makefile +++ b/Makefile @@ -1,37 +1,43 @@ VERSION=1.17.4 PATH_BUILD=build/ FILE_COMMAND=terragrunt-atlantis-config -FILE_ARCH=darwin_amd64 -S3_BUCKET_NAME=cloudfront-origin-homebrew-tap-transcend-io -PROFILE=transcend-prod +FILE_ARCH=$(shell go env GOOS)_$(shell go env GOARCH) # Determine the arch/os combos we're building for -XC_ARCH=amd64 arm +XC_ARCH=amd64 arm64 XC_OS=linux darwin windows .PHONY: clean clean: rm -rf ./build - rm -rf '$(HOME)/bin/$(FILE_COMMAND)' + rm -rf "$(HOME)/.local/bin/$(FILE_COMMAND)" .PHONY: build build: clean CGO_ENABLED=0 \ - goxc \ - -bc="darwin,amd64" \ - -pv=$(VERSION) \ - -d=$(PATH_BUILD) \ - -build-ldflags "-X main.VERSION=$(VERSION)" + go build \ + -trimpath \ + -mod=readonly \ + -modcacherw \ + -ldflags "-X main.VERSION=$(VERSION)" \ + -o $(PATH_BUILD)$(FILE_COMMAND)/$(VERSION)/$(FILE_COMMAND)_$(VERSION)_$(FILE_ARCH) .PHONY: build-all build-all: clean - CGO_ENABLED=0 \ - goxc \ - -os="$(XC_OS)" \ - -arch="$(XC_ARCH)" \ - -pv=$(VERSION) \ - -d=$(PATH_BUILD) \ - -build-ldflags "-X main.VERSION=$(VERSION)" + for arch in $(XC_ARCH); do \ + for os in $(XC_OS); do \ + echo "Building for '$$os/$$arch'" ; \ + CGO_ENABLED=0 \ + GOARCH=$$arch \ + GOOS=$$os \ + go build \ + -trimpath \ + -mod=readonly \ + -modcacherw \ + -ldflags "-X main.VERSION=$(VERSION)" \ + -o $(PATH_BUILD)$(FILE_COMMAND)/$(VERSION)/$(FILE_COMMAND)_$(VERSION)_$${os}_$${arch} ; \ + done \ + done .PHONY: gotestsum gotestsum: @@ -56,5 +62,5 @@ sign: build-all .PHONY: install install: - install -d -m 755 '$(HOME)/bin/' - install $(PATH_BUILD)$(FILE_COMMAND)/$(VERSION)/$(FILE_COMMAND)_$(VERSION)_$(FILE_ARCH) '$(HOME)/bin/$(FILE_COMMAND)' + install -d -m 755 '$(HOME)/.local/bin/' + install $(PATH_BUILD)$(FILE_COMMAND)/$(VERSION)/$(FILE_COMMAND)_$(VERSION)_$(FILE_ARCH) '$(HOME)/.local/bin/$(FILE_COMMAND)' From e4499460212c44bcdfbf5916f9d20f855c3a3794 Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Tue, 10 Oct 2023 15:45:22 +0200 Subject: [PATCH 05/15] Update GHA action versions --- .github/workflows/container-build.yml | 8 ++++---- .github/workflows/contributors.yml | 12 ++++++------ .github/workflows/release.yml | 8 ++++---- .github/workflows/run_tests.yml | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/container-build.yml b/.github/workflows/container-build.yml index a2567f1e..29494c4e 100644 --- a/.github/workflows/container-build.yml +++ b/.github/workflows/container-build.yml @@ -26,11 +26,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the latest SHA for this branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 if: github.event_name != 'workflow_dispatch' - name: Checkout the specified tag - uses: actions/checkout@v2 + uses: actions/checkout@v4 if: github.event_name == 'workflow_dispatch' with: ref: ${{ github.event.inputs.tag }} @@ -46,7 +46,7 @@ jobs: - name: Build and cache first build stage # update the first stage cache only when pushing to or tagging main if: github.event_name == 'push' - uses: docker/build-push-action@v1 + uses: docker/build-push-action@v5 env: # use BuildKit to speed up builds and improve caching DOCKER_BUILDKIT: 1 @@ -61,7 +61,7 @@ jobs: cache_froms: ${{ env.GHCR_HOSTNAME }}/${{ github.repository }}:build - name: Build the container image - uses: docker/build-push-action@v1 + uses: docker/build-push-action@v5 env: # use BuildKit to speed up builds and improve caching DOCKER_BUILDKIT: 1 diff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.yml index 0e1d8a24..a7de13f6 100644 --- a/.github/workflows/contributors.yml +++ b/.github/workflows/contributors.yml @@ -7,8 +7,8 @@ jobs: contributors: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: wow-actions/contributors-list@v1 + - uses: actions/checkout@v4 + - uses: wow-actions/contributors-list@a9cb338523e20921d1a535d29f00dc8458fa8fe2 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} svgPath: CONTRIBUTORS.svg @@ -26,10 +26,10 @@ jobs: - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 with: - commit-message: '[Chore] Update Contributors SVG' - title: '[Chore] Update Contributors SVG' + commit-message: "[Chore] Update Contributors SVG" + title: "[Chore] Update Contributors SVG" delete-branch: true assignees: dmattia - reviewers: dmattia \ No newline at end of file + reviewers: dmattia diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a2553b5..e7b2eeee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,10 +17,10 @@ jobs: go-version: "^1.20" # Checkout code - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 # Install golang deps, using a cache - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: ~/go/pkg/mod key: ubuntu-latest-1.20-go-${{ hashFiles('**/go.sum') }} @@ -35,7 +35,7 @@ jobs: - name: Get the version id: get_version run: echo VERSION=${GITHUB_REF#refs/tags/v} >> $GITHUB_OUTPUT - - uses: jmgilman/actions-generate-checksum@v1 + - uses: jmgilman/actions-generate-checksum@24a35957fba81c6cbaefeb1e3d59ee56e3db5077 id: checksums with: patterns: "build/${{ steps.get_version.outputs.VERSION }}/*" @@ -43,7 +43,7 @@ jobs: output: checksums.txt # Create the release - - uses: "marvinpinto/action-automatic-releases@latest" + - uses: "marvinpinto/action-automatic-releases@d68defdd11f9dcc7f52f35c1b7c236ee7513bcc1" with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: false diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 4f759b72..bdf5c1a1 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -9,12 +9,12 @@ jobs: golang-version: [1.20] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup golang v${{ matrix.golang-version }} - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: go-version: "^${{ matrix.golang-version }}" - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: ~/go/pkg/mod key: ${{ matrix.os }}-${{ matrix.golang-version }}-go-${{ hashFiles('**/go.sum') }} From ae740ae264223ba511786b6603cd50b129968fe0 Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Tue, 10 Oct 2023 16:03:08 +0200 Subject: [PATCH 06/15] Fix release build path --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c0b0d4f2..b97a3c42 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ build: clean -mod=readonly \ -modcacherw \ -ldflags "-X main.VERSION=$(VERSION)" \ - -o $(PATH_BUILD)$(FILE_COMMAND)/$(VERSION)/$(FILE_COMMAND)_$(VERSION)_$(FILE_ARCH) + -o $(PATH_BUILD)$(VERSION)/$(FILE_COMMAND)_$(VERSION)_$(FILE_ARCH) .PHONY: build-all build-all: clean @@ -35,7 +35,7 @@ build-all: clean -mod=readonly \ -modcacherw \ -ldflags "-X main.VERSION=$(VERSION)" \ - -o $(PATH_BUILD)$(FILE_COMMAND)/$(VERSION)/$(FILE_COMMAND)_$(VERSION)_$${os}_$${arch} ; \ + -o $(PATH_BUILD)$(VERSION)/$(FILE_COMMAND)_$(VERSION)_$${os}_$${arch} ; \ done \ done @@ -57,10 +57,10 @@ version: .PHONY: sign sign: build-all - rm -f $(PATH_BUILD)${VERSION}/SHA256SUMS - shasum -a256 $(PATH_BUILD)${VERSION}/* > $(PATH_BUILD)${VERSION}/SHA256SUMS + rm -f $(PATH_BUILD)$(VERSION)/SHA256SUMS + shasum -a256 $(PATH_BUILD)$(VERSION)/* > $(PATH_BUILD)$(VERSION)/SHA256SUMS .PHONY: install install: install -d -m 755 '$(HOME)/.local/bin/' - install $(PATH_BUILD)$(FILE_COMMAND)/$(VERSION)/$(FILE_COMMAND)_$(VERSION)_$(FILE_ARCH) '$(HOME)/.local/bin/$(FILE_COMMAND)' + install $(PATH_BUILD)$(VERSION)/$(FILE_COMMAND)_$(VERSION)_$(FILE_ARCH) '$(HOME)/.local/bin/$(FILE_COMMAND)' From b9e95c77066b90fea79dadd1d53b1a7126ecbe92 Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Tue, 10 Oct 2023 16:21:43 +0200 Subject: [PATCH 07/15] Include extensions for windows binary --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b97a3c42..15566b5f 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,7 @@ build-all: clean for arch in $(XC_ARCH); do \ for os in $(XC_OS); do \ echo "Building for '$$os/$$arch'" ; \ + ext="" ; [ "$$os" = "windows" ] && ext=".exe" ; \ CGO_ENABLED=0 \ GOARCH=$$arch \ GOOS=$$os \ @@ -35,7 +36,7 @@ build-all: clean -mod=readonly \ -modcacherw \ -ldflags "-X main.VERSION=$(VERSION)" \ - -o $(PATH_BUILD)$(VERSION)/$(FILE_COMMAND)_$(VERSION)_$${os}_$${arch} ; \ + -o $(PATH_BUILD)$(VERSION)/$(FILE_COMMAND)_$(VERSION)_$${os}_$${arch}$${ext} ; \ done \ done From ae296c2a366823b879b5c2af3fd9f4a4e896b773 Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Tue, 30 Jan 2024 12:56:34 +0100 Subject: [PATCH 08/15] Update go version in CI and Dockerfile --- .github/workflows/release.yml | 6 +++--- .github/workflows/run_tests.yml | 2 +- Dockerfile | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e7b2eeee..095e3865 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: # Install golang - uses: actions/setup-go@v2 with: - go-version: "^1.20" + go-version: "^1.21" # Checkout code - uses: actions/checkout@v4 @@ -23,9 +23,9 @@ jobs: - uses: actions/cache@v3 with: path: ~/go/pkg/mod - key: ubuntu-latest-1.20-go-${{ hashFiles('**/go.sum') }} + key: ubuntu-latest-1.21-go-${{ hashFiles('**/go.sum') }} restore-keys: | - ubuntu-latest-1.20-go- + ubuntu-latest-1.21-go- # build binaries for all supported environments - run: sudo apt update && sudo apt install -y make diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index bdf5c1a1..b6f0b642 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -6,7 +6,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - golang-version: [1.20] + golang-version: [1.21] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 diff --git a/Dockerfile b/Dockerfile index b60e4ed4..53949445 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang AS build +FROM golang:1.21 AS build ENV GO111MODULE=on WORKDIR /app From b0350153987cb69158084e8f770a322557ff07e6 Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Tue, 30 Jan 2024 13:04:10 +0100 Subject: [PATCH 09/15] Update setup-go and cache GHA versions --- .github/workflows/release.yml | 4 ++-- .github/workflows/run_tests.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 095e3865..317c8385 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: steps: # Install golang - - uses: actions/setup-go@v2 + - uses: actions/setup-go@v5 with: go-version: "^1.21" @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v4 # Install golang deps, using a cache - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ~/go/pkg/mod key: ubuntu-latest-1.21-go-${{ hashFiles('**/go.sum') }} diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index b6f0b642..9d4c5a1e 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -11,10 +11,10 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup golang v${{ matrix.golang-version }} - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: "^${{ matrix.golang-version }}" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ~/go/pkg/mod key: ${{ matrix.os }}-${{ matrix.golang-version }}-go-${{ hashFiles('**/go.sum') }} From 7df56a617a1505000130133efc6c4627b04af8eb Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Tue, 30 Jan 2024 13:30:08 +0100 Subject: [PATCH 10/15] Update container image build steps --- .github/workflows/container-build.yml | 42 +++++++++------------------ 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/.github/workflows/container-build.yml b/.github/workflows/container-build.yml index 29494c4e..a1cd42d3 100644 --- a/.github/workflows/container-build.yml +++ b/.github/workflows/container-build.yml @@ -43,38 +43,24 @@ jobs: git checkout origin/master -- Dockerfile fi - - name: Build and cache first build stage - # update the first stage cache only when pushing to or tagging main - if: github.event_name == 'push' - uses: docker/build-push-action@v5 - env: - # use BuildKit to speed up builds and improve caching - DOCKER_BUILDKIT: 1 + - name: Setup Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 with: - username: ${{ github.repository_owner }} - password: ${{ secrets.CR_PAT }} - registry: ${{ env.GHCR_HOSTNAME }} - repository: ${{ github.repository }} - target: build - tags: build - build_args: BUILDKIT_INLINE_CACHE=1 - cache_froms: ${{ env.GHCR_HOSTNAME }}/${{ github.repository }}:build + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build the container image uses: docker/build-push-action@v5 - env: - # use BuildKit to speed up builds and improve caching - DOCKER_BUILDKIT: 1 with: - username: ${{ github.repository_owner }} - password: ${{ secrets.CR_PAT }} - registry: ${{ env.GHCR_HOSTNAME }} - repository: ${{ github.repository }} - # auto create the tag if we're in a push/pull_request - tag_with_ref: ${{ github.event_name != 'workflow_dispatch' }} + push: ${{ github.event_name != 'pull_request' }} + builder: ${{ steps.buildx.outputs.name }} + platforms: linux/amd64,linux/arm64 # this will add the proper tag if we're in workflow_dispatch tags: ${{ github.event.inputs.tag }} - build_args: BUILDKIT_INLINE_CACHE=1 - cache_froms: > - ${{ env.GHCR_HOSTNAME }}/${{ github.repository }}:build, - ${{ env.GHCR_HOSTNAME }}/${{ github.repository }}:latest + cache-from: type=gha + cache-to: type=gha,mode=max From 737faa99d2d4791fc2c0e0b40bba061b4768b8c6 Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Tue, 30 Jan 2024 13:50:11 +0100 Subject: [PATCH 11/15] Update Dockerfile for x-building --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 53949445..e76400a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM golang:1.21 AS build +ARG GO_VERSION=1.21 +FROM golang:${GO_VERSION} AS build -ENV GO111MODULE=on WORKDIR /app # copy source @@ -11,7 +11,8 @@ RUN go mod download # build the executable COPY cmd ./cmd -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build +ENV CGO_ENABLED=0 +RUN go build # create super thin container with the binary only FROM scratch From 91a3d5c67d1b06e89c8360facb577b80fe38bafe Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Wed, 31 Jan 2024 13:27:14 +0100 Subject: [PATCH 12/15] Update contributors GHA versions --- .github/workflows/contributors.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.yml index a7de13f6..a83d89ca 100644 --- a/.github/workflows/contributors.yml +++ b/.github/workflows/contributors.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: wow-actions/contributors-list@a9cb338523e20921d1a535d29f00dc8458fa8fe2 + - uses: wow-actions/contributors-list@v1 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} svgPath: CONTRIBUTORS.svg @@ -26,7 +26,7 @@ jobs: - name: Create Pull Request - uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 + uses: peter-evans/create-pull-request@v6 with: commit-message: "[Chore] Update Contributors SVG" title: "[Chore] Update Contributors SVG" From 0f6f807c83835f65f44e858121e9f25f23e3520a Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Wed, 31 Jan 2024 13:30:50 +0100 Subject: [PATCH 13/15] Report coverage, go version is passed as string --- .github/workflows/run_tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 9d4c5a1e..ee127cd6 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -6,11 +6,11 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - golang-version: [1.21] + golang-version: ["1.21"] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - name: Setup golang v${{ matrix.golang-version }} + - name: Setup golang uses: actions/setup-go@v5 with: go-version: "^${{ matrix.golang-version }}" @@ -21,4 +21,4 @@ jobs: restore-keys: | ${{ matrix.os }}-${{ matrix.golang-version }}-go- - run: mkdir cmd/test_artifacts - - run: go test -v ./... + - run: go test -v -cover ./... From 4d3ca738255e6aae0494ba47158d6c868c5bff5b Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Wed, 31 Jan 2024 13:32:25 +0100 Subject: [PATCH 14/15] Update go version in Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 15566b5f..02ab9bfd 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=1.17.4 +VERSION=1.21.6 PATH_BUILD=build/ FILE_COMMAND=terragrunt-atlantis-config FILE_ARCH=$(shell go env GOOS)_$(shell go env GOARCH) From 516a564e9cc4e85f98ba02bed93b09627c3881ae Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Thu, 1 Feb 2024 08:17:19 +0100 Subject: [PATCH 15/15] Improve container build --- .github/workflows/container-build.yml | 30 ++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/container-build.yml b/.github/workflows/container-build.yml index a1cd42d3..bd6b07c9 100644 --- a/.github/workflows/container-build.yml +++ b/.github/workflows/container-build.yml @@ -17,6 +17,9 @@ on: description: Build a container image for this git tag required: true +permissions: + packages: write # ghcr access + env: # GitHub Container Registry hostname GHCR_HOSTNAME: ghcr.io @@ -54,13 +57,34 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Prepare + id: prep + run: | + VERSION="${{ github.event.inputs.tag }}" + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION="${GITHUB_REF/refs\/tags\//}" + fi + if [[ -z "$VERSION" ]]; then + VERSION="ref-${GITHUB_SHA::8}" + fi + echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT + + - name: Generate images meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.GHCR_HOSTNAME }}/${{ github.repository }} + tags: | + type=raw,value=${{ steps.prep.outputs.VERSION }} + - name: Build the container image uses: docker/build-push-action@v5 with: - push: ${{ github.event_name != 'pull_request' }} + push: ${{ github.event.inputs.tag != '' || startsWith(github.event.push.ref, 'refs/tags/') }} builder: ${{ steps.buildx.outputs.name }} platforms: linux/amd64,linux/arm64 - # this will add the proper tag if we're in workflow_dispatch - tags: ${{ github.event.inputs.tag }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max