diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..ad917cf2 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,32 @@ +name: Release + +on: + push: + tags: + - '*' + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Check versions + run: | + version=$(grep "^version:" plugin.yaml | cut -d '"' -f 2) + if [ "${GITHUB_REF_NAME}" != "v${version}" ]; then + echo '::error::Version mismatch' + exit 1 + fi + - uses: actions/setup-go@v4 + with: + go-version-file: 'go.mod' + - uses: goreleaser/goreleaser-action@v4 + with: + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 8e93598b..c4b72bc0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ release/ .envrc .idea docker-run-release-cache/ +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 00000000..0ade6808 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,51 @@ +--- +# Make sure to check the documentation at https://goreleaser.com +before: + hooks: + # Keep mod files clean + - go mod tidy -v + +builds: + - main: main.go + binary: bin/diff + env: + - CGO_ENABLED=0 + flags: -trimpath + ldflags: -s -w -X {{ .ModulePath }}/cmd.Version={{ .Version }} + targets: + # helm supported targets + # https://github.com/helm/helm/blob/main/Makefile#L4C1-L4C1 + - darwin_amd64 + - darwin_arm64 + - linux_386 + - linux_amd64 + - linux_arm + - linux_arm64 + - linux_ppc64le + - linux_s390x + - windows_amd64 + # additional targets + - freebsd_amd64 + +archives: + - format: tgz + name_template: '{{ .ProjectName }}-{{ tolower .Os }}-{{ .Arch }}' + wrap_in_directory: diff + files: + - README.md + - LICENSE + - plugin.yaml + +checksum: + name_template: 'checksums.txt' + +snapshot: + name_template: '{{ incpatch .Version }}-{{ .ShortCommit }}' + +changelog: + sort: asc + filters: + exclude: + - '^chore:' + - '^docs:' + - '^test:' diff --git a/Makefile b/Makefile index bf4cf3cf..14be08f3 100644 --- a/Makefile +++ b/Makefile @@ -87,7 +87,7 @@ dist: tar -C build/ -zcvf $(CURDIR)/release/helm-diff-windows-amd64.tgz diff/ .PHONY: release -release: lint dist +release: lint scripts/release.sh v$(VERSION) # Test for the plugin installation with `helm plugin install -v THIS_BRANCH` works diff --git a/scripts/release.sh b/scripts/release.sh index 9ca0716b..2627c9fa 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -8,4 +8,3 @@ fi git tag $1 git push origin $1 -gh release create $1 --draft --generate-notes --title "$1" release/*.tgz