|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -euo pipefail |
| 4 | + |
| 5 | +{ |
| 6 | +if [ -z "${NEW_VERSION:-}" ]; then |
| 7 | + echo "error: Missing value for environment variable NEW_VERSION" |
| 8 | + echo "hint: Invoke this script as NEW_VERSION=M.N.P ./tools/scripts/publish-scip-ruby.sh" |
| 9 | + exit 1 |
| 10 | +fi |
| 11 | + |
| 12 | +if ! grep -q "## v$NEW_VERSION" CHANGELOG.md; then |
| 13 | + echo "error: Missing CHANGELOG entry for v$NEW_VERSION" |
| 14 | + echo "note: CHANGELOG entries are required for publishing releases" |
| 15 | + exit 1 |
| 16 | +fi |
| 17 | + |
| 18 | +if ! grep -q "$NEW_VERSION" cmd/version.txt; then |
| 19 | + echo "error: SCIP version in cmd/version.txt doesn't match NEW_VERSION=$NEW_VERSION" |
| 20 | + exit 1 |
| 21 | +fi |
| 22 | + |
| 23 | +if ! git diff --quiet; then |
| 24 | + echo "error: Found unstaged changes; aborting." |
| 25 | + exit 1 |
| 26 | +fi |
| 27 | + |
| 28 | +if ! git diff --quiet --cached; then |
| 29 | + echo "error: Found staged-but-uncommitted changes; aborting." |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | + |
| 33 | +if ! git remote -v | grep "origin" | grep -q "https://github.com/sourcegraph/scip.git"; then |
| 34 | + echo "error: remote 'origin' doesn't point to sourcegraph/scip" |
| 35 | + exit 1 |
| 36 | +fi |
| 37 | + |
| 38 | +if ! git rev-parse --abbrev-ref HEAD | grep -q "main"; then |
| 39 | + echo "error: Releases should be published from main but HEAD is on a different branch" >&2 |
| 40 | + exit 1 |
| 41 | +fi |
| 42 | +} >&2 |
| 43 | + |
| 44 | +TAG="v$NEW_VERSION" |
| 45 | +git tag "$TAG" |
| 46 | +git push origin "$TAG" |
| 47 | + |
| 48 | +{ |
| 49 | + echo "See the [CHANGELOG](https://github.com/sourcegraph/scip/blob/main/CHANGELOG.md) to see what's new in scip v$NEW_VERSION." |
| 50 | + echo '' |
| 51 | + echo 'Download the CLI for your current platform using:' |
| 52 | + echo '' |
| 53 | + echo '```bash' |
| 54 | + echo 'env \' |
| 55 | + echo " TAG=\"v$NEW_VERSION\" \\" |
| 56 | + echo ' OS="$(uname -s | tr '\''[:upper:]'\'' '\''[:lower:]'\'')" \' |
| 57 | + echo ' ARCH="$(uname -m | sed -e '\''s/x86_64/amd64/'\'')" \' |
| 58 | + echo ' bash -c '\''curl -L "https://github.com/sourcegraph/scip/releases/download/$TAG/scip-$OS-$ARCH.tar.gz"'\'' \' |
| 59 | + echo '| tar xzf - scip' |
| 60 | + echo '```' |
| 61 | +} | gh release create --title "scip-ruby v$NEW_VERSION" --notes-file - |
0 commit comments