From 22fb21e596d090817c4fcee7829bbf5d98440432 Mon Sep 17 00:00:00 2001 From: Charles Treatman Date: Thu, 23 May 2024 10:17:44 -0500 Subject: [PATCH 1/5] feat: determine release version automatically from commit tags --- .github/workflows/release.yml | 26 ++++++++++------- .goreleaser.yml | 54 ++++++++++++++++------------------- .releaserc.json | 28 ++++++++++++++++++ 3 files changed, 67 insertions(+), 41 deletions(-) create mode 100644 .releaserc.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b1fecfbe..0b1f653c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,26 +1,30 @@ -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 + - name: Release + id: semantic-release + uses: cycjimmy/semantic-release-action@v4 + with: + semantic_version: 19.0.5 + extra_plugins: | + conventional-changelog-conventionalcommits@4.6.3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v5 with: version: latest diff --git a/.goreleaser.yml b/.goreleaser.yml index c9d7afee..bf727863 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -7,45 +7,39 @@ before: # 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: diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 00000000..f70756f6 --- /dev/null +++ b/.releaserc.json @@ -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 + } + ] + ] +} From 8be822d4415ff5e1c6567b8c17a9ebb58078f667 Mon Sep 17 00:00:00 2001 From: Charles Treatman Date: Thu, 13 Jun 2024 13:25:22 -0500 Subject: [PATCH 2/5] chore: update release docs --- RELEASE.md | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 6a7c2410..213ef3d5 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -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 From 5389f7595accdcdc56f48b271bafd4eb4cb21d46 Mon Sep 17 00:00:00 2001 From: Charles Treatman Date: Thu, 13 Jun 2024 13:25:41 -0500 Subject: [PATCH 3/5] chore(ci): update goreleaser-action to v6 --- .github/workflows/release.yml | 4 ++-- .goreleaser.yml | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0b1f653c..c59329ca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,10 +25,10 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v5 + uses: goreleaser/goreleaser-action@v6 with: version: latest - args: release --rm-dist + args: release --clean env: # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # diff --git a/.goreleaser.yml b/.goreleaser.yml index bf727863..c482f995 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,5 +1,7 @@ # 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. @@ -48,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 From b1b4f409d09564f91e0b63c346a27e4e8749a99b Mon Sep 17 00:00:00 2001 From: Charles Treatman Date: Mon, 8 Jul 2024 09:47:12 -0500 Subject: [PATCH 4/5] protect against future goreleaser major version upgrades --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c59329ca..3e4ccf72 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,8 +27,8 @@ jobs: - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 with: - version: latest args: release --clean + version: '~> v2' env: # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # From 8015b919c880a068cebfcc4914de70540b540659 Mon Sep 17 00:00:00 2001 From: Charles Treatman Date: Mon, 8 Jul 2024 14:32:14 -0500 Subject: [PATCH 5/5] fix: bump tool versions --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3e4ccf72..e2903b53 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,9 +19,9 @@ jobs: id: semantic-release uses: cycjimmy/semantic-release-action@v4 with: - semantic_version: 19.0.5 + semantic_version: 24.0.0 extra_plugins: | - conventional-changelog-conventionalcommits@4.6.3 + conventional-changelog-conventionalcommits@8.0.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Run GoReleaser