From 538937d5198e3f11ce28812882ee1c915e7f2683 Mon Sep 17 00:00:00 2001 From: Dani Santos Date: Thu, 30 Mar 2023 09:50:14 -0400 Subject: [PATCH] go releaser action (#539) * new action * mention button in the instructions --- .github/workflows/release.yml | 49 +++++++++++++++++++++++++++++++++++ .goreleaser.yml | 18 +++++++++++++ docs/release.md | 19 ++++---------- 3 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..16ac7a1b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: release + +on: + push: + tags: [ v*.*.* ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + + steps: + - + name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - + name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - + name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + check-latest: true + cache: true + + - + name: Release + uses: goreleaser/goreleaser-action@b508e2e3ef3b19d4e4146d4f8fb3ba9db644a757 + with: + distribution: goreleaser + version: v1.10.3 + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 3f5df7f3..863dac5d 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -5,6 +5,15 @@ release: name: kubeaudit draft: true name_template: "{{.ProjectName}}-v{{.Version}}" +dockers: +- dockerfile: goreleaser.Dockerfile + goos: linux + goarch: amd64 + goarm: '' + image_templates: + - "ghcr.io/shopify/kubeaudit:latest" + - "ghcr.io/shopify/kubeaudit:{{ .Tag }}" + - "ghcr.io/shopify/kubeaudit:v{{ .Major }}.{{ .Minor }}" builds: - goos: - linux @@ -17,6 +26,15 @@ builds: binary: kubeaudit ldflags: - -s -w -X github.com/Shopify/kubeaudit/cmd.Version={{.Version}} -X github.com/Shopify/kubeaudit/cmd.Commit={{.Commit}} -X github.com/Shopify/kubeaudit/cmd.BuildDate={{.Date}} + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + - ^Merge + archives: - format: tar.gz name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{.Arm }}{{ end }}' diff --git a/docs/release.md b/docs/release.md index 6bdb0605..323f6f20 100644 --- a/docs/release.md +++ b/docs/release.md @@ -24,26 +24,17 @@ git tag -a v0.11.6 -m "v0.11.6" git push origin v0.11.6 ``` -5. You will need a Github token in order for Goreleaser to be able to create a release in Github. If you already have one, skip to the next step. -[Create a Github token](https://github.com/settings/tokens/new) with the `repo` scope. - -6. Run Goreleaser - -``` -GITHUB_TOKEN= goreleaser --rm-dist -``` - -7. Publish the release in Github - -Goreleaser is set to draft mode which means it will create a draft release in Github, allowing you to double check the release and make changes to the Changelog. Find the [draft release](https://github.com/Shopify/kubeaudit/releases) and make sure there are no commits to main since the release. +5. Once you push the tag, the release Github action will be triggered and generate a draft release in Github, allowing you to double check it and make changes to the Changelog. Find the [draft release](https://github.com/Shopify/kubeaudit/releases) and make sure there are no commits to main since the release. > If there are commits to main since the release, this may mean you didn't make the tag on main or your main is out of date. -Click `Edit` on the right of the draft release and tidy up the Changelog if necessary. We like to add thank you's to external contributors, for example: +6. Click `Edit` on the right of the draft release and tidy up the Changelog if necessary. We like to add thank you's to external contributors, for example: ``` 202e355 Fixed code quality issues using DeepSource (#315) - Thank you @withshubh for the contribution! ``` -Click on `Publish release` at the bottom. +Optionally, you can click on "Generate release notes", which adds Markdown for all the merged pull requests from the diff and contributors of the release. + +7. Click on `Publish release` at the bottom.