diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..c2c9aecad --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/.goreleaser.yml b/.goreleaser.yml index ee029e45c..8a5dccbd2 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -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 @@ -37,7 +52,10 @@ changelog: - '^test:' archives: - - name_template: >- + - id: release-archives + builds: + - release-build + name_template: >- {{- .ProjectName }}- {{- .Version }}- {{- .Os }}- @@ -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. diff --git a/.release/header.md b/.release/header.md new file mode 100644 index 000000000..55027b78c --- /dev/null +++ b/.release/header.md @@ -0,0 +1,3 @@ +To install, follow the interactive installation instructions at https://exercism.io/cli-walkthrough + +--- diff --git a/RELEASE.md b/RELEASE.md index 35c26bfba..566db9f83 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -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 @@ -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 @@ -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