From 90761469c63e775c637d758f8f1eb6989b039848 Mon Sep 17 00:00:00 2001 From: Varun Gandhi Date: Thu, 6 Oct 2022 19:07:44 +0800 Subject: [PATCH] cli: Streamline release workflow for v0.2.2 (#104) --- CHANGELOG.md | 12 +++++++++ Development.md | 12 +++++++-- cmd/version.txt | 2 +- dev/publish-release.sh | 61 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 CHANGELOG.md create mode 100755 dev/publish-release.sh diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..30e0753c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# ChangeLog + +## v0.2.2 + +### Additions + +- The new `scip print` subcommand can be used to view a SCIP index without access to protoc. (https://github.com/sourcegraph/scip/pull/91) +- The new `scip lint` subcommand can be used to identify correctness and redundancy issues with a SCIP index. (https://github.com/sourcegraph/scip/pull/92) + +### Fixes + +- `scip --version` now works as expected instead of reporting 0.1.0. (https://github.com/sourcegraph/scip/pull/97) diff --git a/Development.md b/Development.md index 6608b2cf..6f88ca46 100644 --- a/Development.md +++ b/Development.md @@ -87,7 +87,15 @@ PACKAGE=MY_PACKAGE_NAME SRC_ACCESS_TOKEN=MY_TOKEN SRC_ENDPOINT=https://sourcegra ## Release a new version -[Create a new release](https://github.com/sourcegraph/scip/releases/new) -in the web UI (or using the `gh` CLI), along with any release notes. +First, add release notes to the [CHANGELOG](CHANGELOG.md). +Next, update the version in `cmd/version.txt`. + +After landing a commit with those two changes, run the release script: +(requires the [GitHub CLI](https://cli.github.com/)) + +```bash +NEW_VERSION="M.N.P" ./dev/publish-release.sh +``` + Once the release is created, the artifacts will be built and uploaded automatically by the [release action](/.github/workflows/release.yml). diff --git a/cmd/version.txt b/cmd/version.txt index 7dff5b89..f4778493 100644 --- a/cmd/version.txt +++ b/cmd/version.txt @@ -1 +1 @@ -0.2.1 \ No newline at end of file +0.2.2 \ No newline at end of file diff --git a/dev/publish-release.sh b/dev/publish-release.sh new file mode 100755 index 00000000..9812084f --- /dev/null +++ b/dev/publish-release.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +set -euo pipefail + +{ +if [ -z "${NEW_VERSION:-}" ]; then + echo "error: Missing value for environment variable NEW_VERSION" + echo "hint: Invoke this script as NEW_VERSION=M.N.P ./tools/scripts/publish-scip-ruby.sh" + exit 1 +fi + +if ! grep -q "## v$NEW_VERSION" CHANGELOG.md; then + echo "error: Missing CHANGELOG entry for v$NEW_VERSION" + echo "note: CHANGELOG entries are required for publishing releases" + exit 1 +fi + +if ! grep -q "$NEW_VERSION" cmd/version.txt; then + echo "error: SCIP version in cmd/version.txt doesn't match NEW_VERSION=$NEW_VERSION" + exit 1 +fi + +if ! git diff --quiet; then + echo "error: Found unstaged changes; aborting." + exit 1 +fi + +if ! git diff --quiet --cached; then + echo "error: Found staged-but-uncommitted changes; aborting." + exit 1 +fi + +if ! git remote -v | grep "origin" | grep -q "https://github.com/sourcegraph/scip.git"; then + echo "error: remote 'origin' doesn't point to sourcegraph/scip" + exit 1 +fi + +if ! git rev-parse --abbrev-ref HEAD | grep -q "main"; then + echo "error: Releases should be published from main but HEAD is on a different branch" >&2 + exit 1 +fi +} >&2 + +TAG="v$NEW_VERSION" +git tag "$TAG" +git push origin "$TAG" + +{ + echo "See the [CHANGELOG](https://github.com/sourcegraph/scip/blob/main/CHANGELOG.md) to see what's new in scip v$NEW_VERSION." + echo '' + echo 'Download the CLI for your current platform using:' + echo '' + echo '```bash' + echo 'env \' + echo " TAG=\"v$NEW_VERSION\" \\" + echo ' OS="$(uname -s | tr '\''[:upper:]'\'' '\''[:lower:]'\'')" \' + echo ' ARCH="$(uname -m | sed -e '\''s/x86_64/amd64/'\'')" \' + echo ' bash -c '\''curl -L "https://github.com/sourcegraph/scip/releases/download/$TAG/scip-$OS-$ARCH.tar.gz"'\'' \' + echo '| tar xzf - scip' + echo '```' +} | gh release create --title "scip-ruby v$NEW_VERSION" --notes-file -