Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Commit

Permalink
go releaser action (#539)
Browse files Browse the repository at this point in the history
* new action
* mention button in the instructions
  • Loading branch information
dani-santos-code authored Mar 30, 2023
1 parent 0a820d1 commit 538937d
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 14 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
18 changes: 18 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}'
Expand Down
19 changes: 5 additions & 14 deletions docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<YOUR 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.

0 comments on commit 538937d

Please sign in to comment.