Skip to content

Commit 2d11773

Browse files
authored
chore: convert to push-button release workflow (#471)
This updates the existing release workflow so that it is run by pushing a button in the GitHub UI rather than creating a tag locally and pushing that tag up to GitHub. The push-button workflow looks up the previous release and uses Conventional Commit tags to determine the correct next version for the new release. As before, it uses GoReleaser to build the CLI and upload the binaries to the GitHub release. I have confirmed on my fork that this works up through the GoReleaser step. Closes #364
1 parent 3293369 commit 2d11773

File tree

4 files changed

+82
-59
lines changed

4 files changed

+82
-59
lines changed

.github/workflows/release.yml

+18-14
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1-
name: release
1+
name: Generate Next Release
22

33
on:
4-
push:
5-
tags:
6-
- '*'
4+
workflow_dispatch:
75

86
jobs:
9-
goreleaser:
7+
release:
108
runs-on: ubuntu-latest
119
steps:
12-
-
13-
name: Checkout
10+
- name: Checkout
1411
uses: actions/checkout@v4
1512
with:
1613
fetch-depth: 0
17-
-
18-
name: Set up Go
14+
- name: Set up Go
1915
uses: actions/setup-go@v5
2016
with:
2117
go-version-file: go.mod
22-
-
23-
name: Run GoReleaser
24-
uses: goreleaser/goreleaser-action@v5
18+
- name: Release
19+
id: semantic-release
20+
uses: cycjimmy/semantic-release-action@v4
2521
with:
26-
version: latest
27-
args: release --rm-dist
22+
semantic_version: 24.0.0
23+
extra_plugins: |
24+
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
- name: Run GoReleaser
28+
uses: goreleaser/goreleaser-action@v6
29+
with:
30+
args: release --clean
31+
version: '~> v2'
2832
env:
2933
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3034
#

.goreleaser.yml

+27-31
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,47 @@
11
# This is an example goreleaser.yaml file with some sane defaults.
22
# Make sure to check the documentation at http://goreleaser.com
3+
version: 2
4+
35
before:
46
hooks:
57
# You may remove this if you don't use go modules.
68
- go mod download
79
# you may remove this if you don't need go generate
810
- go generate ./...
911
builds:
10-
- main: ./cmd/metal
11-
env:
12-
- CGO_ENABLED=0
13-
binary: metal
14-
ldflags:
15-
- -X github.com/equinix/metal-cli/cmd.Version={{.Version}}
16-
- -X github.com/equinix/metal-cli/cmd.Build=${.Commit}"
12+
- main: ./cmd/metal
13+
env:
14+
- CGO_ENABLED=0
15+
binary: metal
16+
ldflags:
17+
- -X github.com/equinix/metal-cli/cmd.Version={{.Version}}
18+
- -X github.com/equinix/metal-cli/cmd.Build=${.Commit}"
1719

18-
goos:
19-
- freebsd
20-
- linux
21-
- windows
22-
- darwin
23-
goarch:
24-
- amd64
25-
- arm
26-
- arm64
27-
goarm:
28-
- "6"
29-
- "7"
20+
goos:
21+
- freebsd
22+
- linux
23+
- windows
24+
- darwin
25+
goarch:
26+
- amd64
27+
- arm
28+
- arm64
29+
goarm:
30+
- "6"
31+
- "7"
3032

3133
archives:
32-
- format: binary
33-
name_template: "{{ .Binary }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
34+
- format: binary
35+
name_template: "{{ .Binary }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
3436
checksum:
3537
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"
3638
release:
37-
name_template: "{{.ProjectName}}-v{{.Version}}"
39+
mode: "keep-existing"
3840
snapshot:
3941
name_template: "{{ .Tag }}-next"
40-
changelog:
41-
sort: asc
42-
filters:
43-
exclude:
44-
- '^docs:'
45-
- '^test:'
4642

47-
brews:
48-
- homepage: "https://metal.equinix.com/developers/docs/libraries/cli/"
43+
brews:
44+
- homepage: "https://deploy.equinix.com/developers/docs/metal/libraries/cli/"
4945
description: "Official Equinix Metal CLI"
5046
license: "MIT"
5147
dependencies:
@@ -54,6 +50,6 @@ brews:
5450
test: |
5551
system "#{bin}/metal -v"
5652
commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}"
57-
tap:
53+
repository:
5854
owner: equinix
5955
name: homebrew-tap

.releaserc.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"branches": [
3+
"main"
4+
],
5+
"ci": false,
6+
"plugins": [
7+
[
8+
"@semantic-release/commit-analyzer",
9+
{
10+
"preset": "conventionalcommits"
11+
}
12+
],
13+
[
14+
"@semantic-release/release-notes-generator",
15+
{
16+
"preset": "conventionalcommits"
17+
}
18+
],
19+
[
20+
"@semantic-release/github",
21+
{
22+
"successComment": "This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:",
23+
"labels": false,
24+
"releasedLabels": false
25+
}
26+
]
27+
]
28+
}

RELEASE.md

+9-14
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,21 @@ These build and release instructions are intended for the maintainers and future
44

55
## Preparing a new version
66

7-
There are no preperation steps.
7+
There are no preparation steps.
88

9-
* the version is computed from git tags
10-
* The changelog is generated from git and lives outside of git
11-
12-
## Tagging
13-
14-
Pull the latest `master` branch and locally `git tag -s 0.0.9`.
15-
16-
When breaking changes are introduced bump the minor or major accordingly, restting the patch version.
9+
* the version is computed from [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) tags
10+
* There is no changelog; the GitHub release notes are generated based on [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) tags
1711

1812
## Releasing
1913

20-
Push the tag to GitHub and [GitHub Workflows](.github/workflows/release.yml) and [GoReleaser](.goreleaser.yml) will do the rest.
14+
Run the GitHub Actions [Release Workflow](.github/workflows/release.yml) on the `main` branch.
2115

22-
```sh
23-
git push origin --tags 0.0.9
24-
```
16+
The release workflow:
17+
- Uses [Semantic Release](.releaserc.json) to determine the next version number and create the GitHub release
18+
- Uses [GoReleaser](.goreleaser.yml) to build the CLI binaries and attach them to the GitHub release
19+
- Updates the Homebrew tap
2520

2621
This will build and release binaries for several different OS and Architecture combinations.
2722

28-
Any special instructions or notes should be added by editing the release notes that goreleaser publishes. These notes can be found at https://github.com/equinix/metal-cli/releases
23+
Any special instructions or notes should be added by editing the release notes that the workflow publishes. These notes can be found at https://github.com/equinix/metal-cli/releases
2924

0 commit comments

Comments
 (0)