From a1bb142b6e15537f04c2d337195a09260e3010fb Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 26 Aug 2025 17:25:03 +1200 Subject: [PATCH 01/10] Build a build system for mock server --- .gitignore | 3 +- .goreleaser.yml | 37 ++++++++++++++++++++ Makefile | 2 +- dockerfiles/apiserver-mock/Dockerfile | 5 +++ Dockerfile => dockerfiles/grpc-go/Dockerfile | 0 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 .goreleaser.yml create mode 100644 dockerfiles/apiserver-mock/Dockerfile rename Dockerfile => dockerfiles/grpc-go/Dockerfile (100%) diff --git a/.gitignore b/.gitignore index 9e5d3c3..1d700ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea -/vendor +vendor +dist diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..44702d1 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,37 @@ +project_name: skpr-mock-cluster +version: 2 + +builds: + - id: skpr-apiserver-mock + main: ./cmd/apiserver-mock + binary: skpr-apiserver-mock + ldflags: + - -extldflags '-static' + env: + - CGO_ENABLED=0 + goos: [ linux, darwin ] + goarch: [ amd64, arm64 ] + +dockers: + - dockerfile: dockerfiles/apiserver-mock/Dockerfile + image_templates: + - "ghcr.io/skpr/api:{{ .Version }}-amd64" + - "ghcr.io/skpr/api:latest-amd64" + build_flag_templates: + - "--pull" + - "--platform=linux/amd64" + use: buildx + - dockerfile: dockerfiles/apiserver-mock/Dockerfile + image_templates: + - "ghcr.io/skpr/api:{{ .Version }}-arm64" + - "ghcr.io/skpr/api:latest-arm64" + build_flag_templates: + - "--pull" + - "--platform=linux/arm64" + use: buildx + +docker_manifests: + - name_template: "ghcr.io/skpr/api:{{ .Version }}" + image_templates: + - "ghcr.io/skpr/api:{{ .Version }}-amd64" + - "ghcr.io/skpr/api:{{ .Version }}-arm64" diff --git a/Makefile b/Makefile index 7e8ea64..a0c7b24 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ build: rm -fR $(DIR) mkdir -p $(DIR) # Building image. - docker build -t $(IMAGE) . + docker build -t $(IMAGE) dockerfiles/grpc-go # Building package. docker run -it -w $(PWD) -v $(PWD):$(PWD) $(IMAGE) /bin/bash -c 'protoc --go_out=./pb --go_opt=paths=source_relative --go-grpc_out=./pb --go-grpc_opt=paths=source_relative *.proto' diff --git a/dockerfiles/apiserver-mock/Dockerfile b/dockerfiles/apiserver-mock/Dockerfile new file mode 100644 index 0000000..c46ee45 --- /dev/null +++ b/dockerfiles/apiserver-mock/Dockerfile @@ -0,0 +1,5 @@ +FROM alpine:latest + +COPY skpr-apiserver-mock /usr/local/bin/ + +ENTRYPOINT ["/usr/local/bin/skpr-apiserver-mock"] diff --git a/Dockerfile b/dockerfiles/grpc-go/Dockerfile similarity index 100% rename from Dockerfile rename to dockerfiles/grpc-go/Dockerfile From 5335263e8891cf8bbdd30cf2781b93548bb23a2e Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 26 Aug 2025 17:26:36 +1200 Subject: [PATCH 02/10] Getting all the names in sync --- .goreleaser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 44702d1..68ed189 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,4 +1,4 @@ -project_name: skpr-mock-cluster +project_name: skpr-apiserver-mock version: 2 builds: From e8d4405628fe0bbabd4e9c53b6651113df87fa18 Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 26 Aug 2025 20:49:05 +1200 Subject: [PATCH 03/10] Adding a release task --- .github/workflows/release.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1b5c699 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Release + +on: + pull_request: + +permissions: + contents: write + packages: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: stable + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: "~> v2" + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 0d4ec3d797d6bfbb1b8de9cd6afda9da15cb3535 Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 26 Aug 2025 20:54:57 +1200 Subject: [PATCH 04/10] Around again --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b5c699..e4bb912 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser - version: "~> v2" - args: release --clean + version: nightly + args: release --nightly --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 021f97e7b7afa4e94c68f5607f8225c2a452f0fa Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 26 Aug 2025 21:04:59 +1200 Subject: [PATCH 05/10] Try a snapshot --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e4bb912..c589a51 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser - version: nightly - args: release --nightly --clean + version: "~> v2" + args: release --clean --snapshot env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 5ced3690850bfae4c6599d656389d73400630d42 Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 26 Aug 2025 21:31:50 +1200 Subject: [PATCH 06/10] Build on tag --- .github/workflows/release.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c589a51..df1473f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,9 @@ name: Release on: - pull_request: + push: + tags: + - 'v*' permissions: contents: write @@ -26,6 +28,6 @@ jobs: with: distribution: goreleaser version: "~> v2" - args: release --clean --snapshot + args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From fae152df9f4bc14d46ebdc1ccc70c85fe147038f Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 26 Aug 2025 21:39:06 +1200 Subject: [PATCH 07/10] Login in to GHCR --- .github/workflows/release.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index df1473f..ded4dd3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,6 +23,13 @@ jobs: with: go-version: stable + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 with: From 215260d826ee25a6ff7f35b4a20748fdfc21718a Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 26 Aug 2025 21:58:44 +1200 Subject: [PATCH 08/10] Improved build system further --- .github/workflows/release.yml | 4 ++-- .goreleaser.yml | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ded4dd3..e821c51 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,10 +18,10 @@ jobs: with: fetch-depth: 0 - - name: Set up Go + - name: Install Go uses: actions/setup-go@v5 with: - go-version: stable + go-version-file: 'go.mod' - name: Login to GHCR uses: docker/login-action@v3 diff --git a/.goreleaser.yml b/.goreleaser.yml index 68ed189..b74bab9 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -9,7 +9,7 @@ builds: - -extldflags '-static' env: - CGO_ENABLED=0 - goos: [ linux, darwin ] + goos: [ linux ] goarch: [ amd64, arm64 ] dockers: @@ -29,9 +29,14 @@ dockers: - "--pull" - "--platform=linux/arm64" use: buildx + goarch: arm64 docker_manifests: - name_template: "ghcr.io/skpr/api:{{ .Version }}" image_templates: - "ghcr.io/skpr/api:{{ .Version }}-amd64" - "ghcr.io/skpr/api:{{ .Version }}-arm64" + - name_template: "ghcr.io/skpr/api:latest" + image_templates: + - "ghcr.io/skpr/api:latest-amd64" + - "ghcr.io/skpr/api:latestd-arm64" From 0c6b2083a7038aca04a6a0791c81b9eb9857485a Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 26 Aug 2025 22:01:39 +1200 Subject: [PATCH 09/10] Typo --- .goreleaser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index b74bab9..2b83d30 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -39,4 +39,4 @@ docker_manifests: - name_template: "ghcr.io/skpr/api:latest" image_templates: - "ghcr.io/skpr/api:latest-amd64" - - "ghcr.io/skpr/api:latestd-arm64" + - "ghcr.io/skpr/api:latest-arm64" From 11f45c1a1eb144a99f3abd172407215a4a5bd2fd Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Thu, 28 Aug 2025 08:48:53 +1200 Subject: [PATCH 10/10] Improved workflow for builds --- .github/workflows/release.yml | 2 +- .goreleaser.yml | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e821c51..420be9a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,4 +37,4 @@ jobs: version: "~> v2" args: release --clean env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 2b83d30..0d2ec2d 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,4 +1,4 @@ -project_name: skpr-apiserver-mock +project_name: skpr-api version: 2 builds: @@ -15,7 +15,7 @@ builds: dockers: - dockerfile: dockerfiles/apiserver-mock/Dockerfile image_templates: - - "ghcr.io/skpr/api:{{ .Version }}-amd64" + - "ghcr.io/skpr/api:{{ .Major }}.{{ .Minor }}-amd64" - "ghcr.io/skpr/api:latest-amd64" build_flag_templates: - "--pull" @@ -23,7 +23,7 @@ dockers: use: buildx - dockerfile: dockerfiles/apiserver-mock/Dockerfile image_templates: - - "ghcr.io/skpr/api:{{ .Version }}-arm64" + - "ghcr.io/skpr/api:{{ .Major }}.{{ .Minor }}-arm64" - "ghcr.io/skpr/api:latest-arm64" build_flag_templates: - "--pull" @@ -32,11 +32,14 @@ dockers: goarch: arm64 docker_manifests: - - name_template: "ghcr.io/skpr/api:{{ .Version }}" + - name_template: "ghcr.io/skpr/api:{{ .Major }}.{{ .Minor }}" image_templates: - - "ghcr.io/skpr/api:{{ .Version }}-amd64" - - "ghcr.io/skpr/api:{{ .Version }}-arm64" + - "ghcr.io/skpr/api:{{ .Major }}.{{ .Minor }}-amd64" + - "ghcr.io/skpr/api:{{ .Major }}.{{ .Minor }}-arm64" - name_template: "ghcr.io/skpr/api:latest" image_templates: - "ghcr.io/skpr/api:latest-amd64" - "ghcr.io/skpr/api:latest-arm64" + +release: + draft: true