Skip to content

Commit

Permalink
Add release script (#1145)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom authored May 9, 2024
1 parent 9cf9401 commit 0509b1b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 32 deletions.
36 changes: 4 additions & 32 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,19 @@ The Exercism CLI uses [GoReleaser](https://goreleaser.com) to automate the relea
1. Bump the `Version` constant in `cmd/version.go`
1. Update the `CHANGELOG.md` file to include a section for the new version and its changes.
Hint: you can view changes using the compare view: https://github.com/exercism/cli/compare/$PREVIOUS_RELEASE...main.
1. Commit the updated version
1. Commit the updated files
1. Create a PR

_Note: It's useful to add the version to the commit message when you bump it: e.g. `Bump version to v2.3.4`._

## Cut a release

Once the version bump PR has been merged, run the following commands:
Once the version bump PR has been merged, run the following command to cut a release:

```bash
VERSION=$(sed -n -E 's/^const Version = "([0-9]+\.[0-9]+\.[0-9]+)"$/\1/p' cmd/version.go)
TAG_NAME="v${VERSION}"
GPG_FINGERPRINT="<GPG FINGERPRINT>"

# Test run
goreleaser --skip=publish --snapshot --clean

# Create a new tag on the main branch and push it
git tag -a "${TAG_NAME}" -m "Trying out GoReleaser"
git push origin "${TAG_NAME}"
```shell
GPG_FINGERPINT="<THE_GPG_FINGERPRINT>" ./bin/release.sh
```

Brew tap is now managed by `.goreleaser.yml` so no need to update it manually.
GoReleaser can generate and publish a homebrew-tap recipe into a repository
automatically. See [GoReleaser docs](https://goreleaser.com/customization/homebrew/)
for more details.

## Cut Release on GitHub

At this point, Goreleaser will have created a draft release at https://github.com/exercism/cli/releases/tag/vX.Y.Z.
Expand All @@ -55,20 +41,6 @@ To install, follow the interactive installation instructions at https://exercism

Lastly, test and publish the draft

## Update Homebrew

Next, we'll submit a PR to Homebrew to update the Exercism formula (which is how macOS users usually download the CLI):

```
cd /tmp && curl -O https://github.com/exercism/cli/archive/vX.Y.Z.tar.gz
cd $(brew --repository)
git checkout master
brew update
brew bump-formula-pr --strict exercism --url=https://github.com/exercism/cli/archive/vX.Y.Z.tar.gz --sha256=$(shasum -a 256 /tmp/vX.Y.Z.tar.gz)
```

For more information see [How To Open a Homebrew Pull Request](https://docs.brew.sh/How-To-Open-a-Homebrew-Pull-Request).

## Update the docs site

If there are any significant changes, we should describe them on
Expand Down
26 changes: 26 additions & 0 deletions bin/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -euo pipefail

if [[ -z "${GPG_FINGERPRINT}" ]]; then
echo "GPG_FINGERPRINT environment variable is not set"
exit 1
fi

echo "Syncing repo with latest main..."
git checkout main
git pull

VERSION=$(sed -n -E 's/^const Version = "([0-9]+\.[0-9]+\.[0-9]+)"$/\1/p' cmd/version.go)
TAG_NAME="v${VERSION}"

echo "Verify release can be built..."
goreleaser --skip=publish --snapshot --clean

echo "Pushing tag..."
git tag -a "${TAG_NAME}" -m "Release ${TAG_NAME}"
git push origin "${TAG_NAME}"

echo "Tag pushed"
echo "The release CI workflow will automatically create a draft release."
echo "Once created, edit the release notes and publish it."

0 comments on commit 0509b1b

Please sign in to comment.