Skip to content

Commit

Permalink
github/workflow/release.yml: Add automated release pipeline (#1106)
Browse files Browse the repository at this point in the history
  • Loading branch information
nywilken authored Sep 6, 2023
1 parent ecd826d commit 0fcf8c2
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 45 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: release

on:
push:
tags:
- 'v*.*.*' # semver release tags
- 'v*.*.*-*' # pre-release tags for testing

permissions:
contents: write # needed by goreleaser/goreleaser-action for publishing release artifacts

jobs:
goreleaser:
runs-on: ubuntu-22.04
steps:

- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '1.19'

- name: Import GPG Key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@72b6676b71ab476b77e676928516f6982eef7a41 # v5.3.0
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}

- name: Cut Release
uses: goreleaser/goreleaser-action@3fa32b8bb5620a2c1afe798654bbad59f9da4906 # v4.4.0
with:
version: latest
args: release --clean --release-header .release/header.md --timeout 120m # default time is 30m
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
101 changes: 72 additions & 29 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,48 @@
# You can find the GoReleaser documentation at http://goreleaser.com
project_name: exercism

env:
- CGO_ENABLED=0
builds:
- env:
- CGO_ENABLED=0
main: ./exercism/main.go
goos:
- darwin
- linux
- windows
- freebsd
- openbsd
goarch:
- amd64
- 386
- arm
- arm64
- ppc64
goarm:
- 5
- 6
ignore:
- goos: openbsd
goarch: arm
- goos: freebsd
goarch: arm

checksum:
name_template: '{{ .ProjectName }}_checksums.txt'
- id: release-build
main: ./exercism/main.go
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath # removes file system paths from compiled executable
ldflags:
- '-s -w' # strip debug symbols and DWARF debugging info
goos:
- darwin
- linux
- windows
- freebsd
- openbsd
goarch:
- amd64
- 386
- arm
- arm64
- ppc64
goarm:
- 5
- 6
ignore:
- goos: openbsd
goarch: arm
- goos: freebsd
goarch: arm
- id: installer-build
main: ./exercism/main.go
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath # removes file system paths from compiled executable
ldflags:
- '-s -w' # strip debug symbols and DWARF debugging info
goos:
- windows
goarch:
- amd64
- 386

changelog:
sort: asc
Expand All @@ -37,7 +52,10 @@ changelog:
- '^test:'

archives:
- name_template: >-
- id: release-archives
builds:
- release-build
name_template: >-
{{- .ProjectName }}-
{{- .Version }}-
{{- .Os }}-
Expand All @@ -49,12 +67,37 @@ archives:
- goos: windows
format: zip
files:
- shell/**/*
- shell/**
- LICENSE
- README.md
- id: installer-archives
builds:
- installer-build
name_template: >-
{{- .ProjectName }}-
{{- .Version }}-
{{- .Os }}-
{{- if eq .Arch "amd64" }}64bit
{{- else if eq .Arch "386" }}32bit
{{- else }}{{- .Arch }}{{ end }}
{{- if .Arm }}v{{- .Arm }}{{ end }}
format_overrides:
- goos: windows
format: zip
files:
- shell/**
- LICENSE
- README.md

checksum:
name_template: '{{ .ProjectName }}_checksums.txt'
ids:
- release-archives
- installer-archives

signs:
- artifacts: checksum
- artifacts: checksum
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]

release:
# Repo in which the release will be created.
Expand Down
3 changes: 3 additions & 0 deletions .release/header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
To install, follow the interactive installation instructions at https://exercism.io/cli-walkthrough

---
21 changes: 5 additions & 16 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Cutting a CLI Release

The Exercism CLI uses [GoReleaser](https://goreleaser.com) to automate the
release process.
The Exercism CLI uses [GoReleaser](https://goreleaser.com) to automate the release process.

## Requirements

Expand All @@ -11,13 +10,12 @@ release process.

## Confirm / Update the Changelog

Make sure all the recent changes are reflected in the "next release" section of the CHANGELOG.md file. All the changes in the "next release" section should be moved to a new section that describes the version number, and gives it a date.
Make sure all the recent changes are reflected in the "next release" section of the CHANGELOG.md file.
All the changes in the "next release" section should be moved to a new section that describes the version number, and gives it a date.

You can view changes using the /compare/ view:
https://github.com/exercism/cli/compare/$PREVIOUS_RELEASE...main

GoReleaser supports the [auto generation of a changelog](https://goreleaser.com/customization/#customize-the-changelog) we will want to customize to meet our standards (not including refactors, test updates, etc). We should also consider using [the release notes feature](https://goreleaser.com/customization/#custom-release-notes).

## Bump the version

1. Create a branch for the new version
Expand All @@ -43,28 +41,19 @@ goreleaser --skip-publish --snapshot --clean
git tag -a "${TAG_NAME}" -m "Trying out GoReleaser"
git push origin "${TAG_NAME}"

# Build and release
goreleaser --clean

# Upload copies of the Windows files for use by the Exercism Windows installer
cp "dist/exercism-${VERSION}-windows-i386.zip" dist/exercism-windows-32bit.zip
cp "dist/exercism-${VERSION}-windows-x86_64.zip" dist/exercism-windows-64bit.zip
gh release upload "${TAG_NAME}" dist/exercism-windows-32bit.zip
gh release upload "${TAG_NAME}" dist/exercism-windows-64bit.zip

# [TODO] Push to homebrew
```

## Cut Release on GitHub

At this point, Goreleaser will have created a draft PR at https://github.com/exercism/cli/releases/tag/vX.Y.Z.
At this point, Goreleaser will have created a draft release at https://github.com/exercism/cli/releases/tag/vX.Y.Z.
On that page, update the release description to:

```
To install, follow the interactive installation instructions at https://exercism.io/cli-walkthrough
---
[describe changes in this release]
[modify the generated release-notes to describe changes in this release]
```

Lastly, test and publish the draft
Expand Down

0 comments on commit 0fcf8c2

Please sign in to comment.