From db19498fedcebec119120260bf83c961839c0b1e Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Wed, 10 Jan 2024 23:28:12 +0000 Subject: [PATCH 1/3] Automate releases using GHA To publish a release, we currently have to run `make docker-run-release` locally after tagging a release, which is not a huge effort but a bit cumbersome, because we do it only a few times a year and that is long enough to lose my memory :) Starting this change, we use a GHA workflow to automatically build and publish binaries whenever a new semver tag is created, so that we do not need to run `make` anymore. --- .github/workflows/release.yaml | 37 ++++++++++++++++++++++++++++++++++ .goreleaser.yml | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..2072c8af --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,37 @@ +name: Release + +on: + push: + tags: + - '*' + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - + if: ${{ !startsWith(github.ref, 'refs/tags/v') }} + run: echo "flags=--snapshot" >> $GITHUB_ENV + - + name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - + name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20.12' + cache: true + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --clean ${{ env.flags }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..1112c322 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,35 @@ +project_name: helm-diff +builds: + - id: default + main: . + binary: bin/diff + env: + - CGO_ENABLED=0 + flags: + - -trimpath + ldflags: + - -X github.com/databus23/helm-diff/v3/cmd.Version={{ .Version }} + goos: + - freebsd + - darwin + - linux + - windows + goarch: + - amd64 + - arm64 + +archives: + - id: default + builds: + - default + format: tgz + name_template: '{{ .ProjectName }}-{{ if eq .Os "darwin" }}macos{{ else }}{{ .Os }}{{ end }}-{{ .Arch }}' + files: + - README.md + - plugin.yaml + - LICENSE +changelog: + use: github-native + +release: + prerelease: auto From 6ab9a0b7b277b254a436dc8ffda8dbc5cbc0754a Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Fri, 12 Jan 2024 01:33:50 +0000 Subject: [PATCH 2/3] Applies bonddim's suggestion. Thx! --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2072c8af..553a52c3 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -24,7 +24,7 @@ jobs: name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.20.12' + go-version-file: 'go.mod' cache: true - name: Run GoReleaser From 247facd31ab6b4282302907fd42558137f4f124f Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Fri, 12 Jan 2024 01:34:32 +0000 Subject: [PATCH 3/3] We do have to wrap files in the diff dir. See https://github.com/databus23/helm-diff/pull/480#discussion_r1449422106 --- .goreleaser.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.goreleaser.yml b/.goreleaser.yml index 1112c322..2582bede 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,3 +1,7 @@ +# To test this manually, run: +# go install github.com/goreleaser/goreleaser@latest +# goreleaser --snapshot --clean +# for f in dist/helm-diff*.tgz; do echo Testing $f...; tar tzvf $f; done project_name: helm-diff builds: - id: default @@ -24,6 +28,7 @@ archives: - default format: tgz name_template: '{{ .ProjectName }}-{{ if eq .Os "darwin" }}macos{{ else }}{{ .Os }}{{ end }}-{{ .Arch }}' + wrap_in_directory: diff files: - README.md - plugin.yaml