Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: convert to push-button release workflow #471

Merged
merged 5 commits into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
name: release
name: Generate Next Release

on:
push:
tags:
- '*'
workflow_dispatch:

jobs:
goreleaser:
release:
runs-on: ubuntu-latest
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
- name: Release
id: semantic-release
uses: cycjimmy/semantic-release-action@v4
with:
version: latest
args: release --rm-dist
semantic_version: 24.0.0
extra_plugins: |
[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
args: release --clean
version: '~> v2'
env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
58 changes: 27 additions & 31 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,47 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
version: 2

before:
hooks:
# You may remove this if you don't use go modules.
- go mod download
# you may remove this if you don't need go generate
- go generate ./...
builds:
- main: ./cmd/metal
env:
- CGO_ENABLED=0
binary: metal
ldflags:
- -X github.com/equinix/metal-cli/cmd.Version={{.Version}}
- -X github.com/equinix/metal-cli/cmd.Build=${.Commit}"
- main: ./cmd/metal
env:
- CGO_ENABLED=0
binary: metal
ldflags:
- -X github.com/equinix/metal-cli/cmd.Version={{.Version}}
- -X github.com/equinix/metal-cli/cmd.Build=${.Commit}"

goos:
- freebsd
- linux
- windows
- darwin
goarch:
- amd64
- arm
- arm64
goarm:
- "6"
- "7"
goos:
- freebsd
- linux
- windows
- darwin
goarch:
- amd64
- arm
- arm64
goarm:
- "6"
- "7"

archives:
- format: binary
name_template: "{{ .Binary }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
- format: binary
name_template: "{{ .Binary }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"
release:
name_template: "{{.ProjectName}}-v{{.Version}}"
mode: "keep-existing"
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

brews:
- homepage: "https://metal.equinix.com/developers/docs/libraries/cli/"
brews:
- homepage: "https://deploy.equinix.com/developers/docs/metal/libraries/cli/"
description: "Official Equinix Metal CLI"
license: "MIT"
dependencies:
@@ -54,6 +50,6 @@ brews:
test: |
system "#{bin}/metal -v"
commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}"
tap:
repository:
owner: equinix
name: homebrew-tap
28 changes: 28 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"branches": [
"main"
],
"ci": false,
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/github",
{
"successComment": "This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:",
"labels": false,
"releasedLabels": false
}
]
]
}
23 changes: 9 additions & 14 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -4,26 +4,21 @@ These build and release instructions are intended for the maintainers and future

## Preparing a new version

There are no preperation steps.
There are no preparation steps.

* the version is computed from git tags
* The changelog is generated from git and lives outside of git

## Tagging

Pull the latest `master` branch and locally `git tag -s 0.0.9`.

When breaking changes are introduced bump the minor or major accordingly, restting the patch version.
* the version is computed from [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) tags
* There is no changelog; the GitHub release notes are generated based on [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) tags

## Releasing

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

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

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

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
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