From 6a0f014fa1cf21fbb3c6cdade8f8fe4b5d8b0b4c Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Sat, 6 Jul 2024 01:37:47 +0300 Subject: [PATCH 1/5] added manifest based multi arch build --- .github/workflows/cicd.yml | 4 +-- .goreleaser.yml | 60 +++++++++++++++++++++++++++++++++++--- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index b57d977dc..95a8731af 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -14,7 +14,7 @@ env: GO_VER: "1.21.8" CGO_ENABLED: 0 MKDOCS_INS_VER: 9.5.9-insiders-4.52.2-hellt - GORELEASER_VER: v1.19.2 + GORELEASER_VER: v2.0.1 PY_VER: "3.10" jobs: @@ -448,7 +448,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v5 + uses: goreleaser/goreleaser-action@v6 with: version: ${{ env.GORELEASER_VER }} args: release --rm-dist --debug diff --git a/.goreleaser.yml b/.goreleaser.yml index 0107f967e..b1c33fc89 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,7 +1,7 @@ # Copyright 2020 Nokia # Licensed under the BSD 3-Clause License. # SPDX-License-Identifier: BSD-3-Clause - +version: 2 project_name: containerlab builds: - id: clab-bin @@ -21,31 +21,83 @@ builds: # hooks: # post: # - upx "{{ .Path }}" + dockers: - goos: linux goarch: amd64 image_templates: - # if version starts with v0.0.0 this is a beta build, for which we don't apply the `latest` tag and apply `beta` tag instead - - '{{ $pfx := slice .Version 0 6}}{{- if eq $pfx "v0.0.0"}}ghcr.io/srl-labs/clab:beta{{else}}ghcr.io/srl-labs/clab:latest{{- end }}' - - 'ghcr.io/srl-labs/clab:{{ replace .Version "v" ""}}' + # if version contains 0.0.0 this is a beta build, for which we don't apply the `latest` tag and apply `beta` tag instead + - &amd_latest_image >- + {{- if contains .Version "0.0.0"}} + ghcr.io/srl-labs/clab:beta-amd64 + {{- else}} + {{- if not .IsSnapshot}} + ghcr.io/srl-labs/clab:latest-amd64 + {{- end}} + {{- end }} + - &amd_versioned_image 'ghcr.io/srl-labs/clab:{{ replace .Version "v" "" }}-amd64' + build_flag_templates: + - "--platform=linux/amd64" + use: buildx dockerfile: goreleaser.dockerfile + - goos: linux + goarch: arm64 + image_templates: + # if version contains 0.0.0 this is a beta build, for which we don't apply the `latest` tag and apply `beta` tag instead + - &arm_latest_image >- + {{- if contains .Version "0.0.0"}} + ghcr.io/srl-labs/clab:beta-arm64 + {{- else}} + {{- if not .IsSnapshot}} + ghcr.io/srl-labs/clab:latest-arm64 + {{- end}} + {{- end }} + - &arm_versioned_image 'ghcr.io/srl-labs/clab:{{ replace .Version "v" ""}}-arm64' + build_flag_templates: + - "--platform=linux/arm64" + dockerfile: goreleaser.dockerfile + use: buildx + +docker_manifests: + - name_template: 'ghcr.io/srl-labs/clab:{{ replace .Version "v" "" }}' + image_templates: + - *amd_versioned_image + - *arm_versioned_image + # this manifest creates a `latest` or `beta` tag based on the version of the release + - name_template: >- + {{- if contains .Version "0.0.0"}} + ghcr.io/srl-labs/clab:beta + {{- else}} + {{- if not .IsSnapshot}} + ghcr.io/srl-labs/clab:latest + {{- end}} + {{- end }} + image_templates: + - *amd_latest_image + - *arm_latest_image + archives: - name_template: '{{ .ProjectName }}_{{ replace .Version "v" "" }}_{{ .Os }}_{{ .Arch }}' files: - lab-examples/**/* - templates/**/* + checksum: name_template: checksums.txt + snapshot: name_template: "{{ .Tag }}-next" + publishers: - name: fury.io deb/rpm packages ids: - containerlab-nfpms # this id belongs to nfpm section and is used to only upload artifacts from nfpm dir: "{{ dir .ArtifactPath }}" cmd: curl -F package=@{{ .ArtifactName }} https://{{ .Env.FURY_TOKEN }}@push.fury.io/netdevops/ + release: prerelease: auto + changelog: use: github-native From 4ade7833a3b3a48909ae1c592ade7e06cf3d70b4 Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Sat, 6 Jul 2024 01:43:22 +0300 Subject: [PATCH 2/5] fix wf name --- .github/workflows/kind-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/kind-tests.yml b/.github/workflows/kind-tests.yml index 6b5478d48..cd3aba443 100644 --- a/.github/workflows/kind-tests.yml +++ b/.github/workflows/kind-tests.yml @@ -1,4 +1,4 @@ -name: vxlan-test +name: kind-test "on": workflow_call: From 4924bcf6a850bc37f6cad1c1723f5c7568d63408 Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Sat, 6 Jul 2024 01:50:33 +0300 Subject: [PATCH 3/5] fix goreleaser flags --- .github/workflows/cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 95a8731af..0fc2176cf 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -451,7 +451,7 @@ jobs: uses: goreleaser/goreleaser-action@v6 with: version: ${{ env.GORELEASER_VER }} - args: release --rm-dist --debug + args: release --clean --verbose env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} FURY_TOKEN: ${{ secrets.FURYPUSHTOKEN }} From 263b426860e38a8e668a2f29802b5c000d1f40b2 Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Sat, 6 Jul 2024 02:22:13 +0300 Subject: [PATCH 4/5] can't find why multiline template introduces a space =(( --- .goreleaser.yml | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index b1c33fc89..47b69c34c 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -27,14 +27,7 @@ dockers: goarch: amd64 image_templates: # if version contains 0.0.0 this is a beta build, for which we don't apply the `latest` tag and apply `beta` tag instead - - &amd_latest_image >- - {{- if contains .Version "0.0.0"}} - ghcr.io/srl-labs/clab:beta-amd64 - {{- else}} - {{- if not .IsSnapshot}} - ghcr.io/srl-labs/clab:latest-amd64 - {{- end}} - {{- end }} + - &amd_latest_image '{{- if contains .Version "0.0.0"}}ghcr.io/srl-labs/clab:beta-amd64{{- else}}{{- if not .IsSnapshot}}ghcr.io/srl-labs/clab:latest-amd64{{- end}}{{- end }}' - &amd_versioned_image 'ghcr.io/srl-labs/clab:{{ replace .Version "v" "" }}-amd64' build_flag_templates: - "--platform=linux/amd64" @@ -44,14 +37,7 @@ dockers: goarch: arm64 image_templates: # if version contains 0.0.0 this is a beta build, for which we don't apply the `latest` tag and apply `beta` tag instead - - &arm_latest_image >- - {{- if contains .Version "0.0.0"}} - ghcr.io/srl-labs/clab:beta-arm64 - {{- else}} - {{- if not .IsSnapshot}} - ghcr.io/srl-labs/clab:latest-arm64 - {{- end}} - {{- end }} + - &arm_latest_image '{{- if contains .Version "0.0.0"}}ghcr.io/srl-labs/clab:beta-arm64{{- else}}{{- if not .IsSnapshot}}ghcr.io/srl-labs/clab:latest-arm64{{- end}}{{- end }}' - &arm_versioned_image 'ghcr.io/srl-labs/clab:{{ replace .Version "v" ""}}-arm64' build_flag_templates: - "--platform=linux/arm64" @@ -64,14 +50,7 @@ docker_manifests: - *amd_versioned_image - *arm_versioned_image # this manifest creates a `latest` or `beta` tag based on the version of the release - - name_template: >- - {{- if contains .Version "0.0.0"}} - ghcr.io/srl-labs/clab:beta - {{- else}} - {{- if not .IsSnapshot}} - ghcr.io/srl-labs/clab:latest - {{- end}} - {{- end }} + - name_template: '{{- if contains .Version "0.0.0"}}ghcr.io/srl-labs/clab:beta{{- else}}{{- if not .IsSnapshot}}ghcr.io/srl-labs/clab:latest{{- end}}{{- end }}' image_templates: - *amd_latest_image - *arm_latest_image From bc8a8951a95b8136c91c60fcc2654fcecce532bb Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Sat, 6 Jul 2024 02:35:52 +0300 Subject: [PATCH 5/5] setup buildx --- .github/workflows/cicd.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 0fc2176cf..f9411a3b3 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -447,6 +447,9 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 with: