diff --git a/.gitignore b/.gitignore index 48e76ae..f5b8935 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ /scip-go scratch/ +.idea/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..93eb5e0 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1 @@ +# ChangeLog diff --git a/Development.md b/Development.md index 06edbb2..558dcba 100644 --- a/Development.md +++ b/Development.md @@ -2,9 +2,13 @@ ## Cutting releases -Push a tag to the `main` branch of the form `vM.N.P`. +1. Land a PR with the following changes: -``` -git checkout main -NEW_VERSION="vM.N.P" bash -c "git tag $NEW_VERSION && git push $NEW_VERSION" -``` + - A ChangeLog entry with `## vM.N.P` + - Updated version in `cmd/version.txt` + +2. On the `main` branch, run the following: + + ```bash + NEW_VERSION="M.N.P" ./dev/publish-release.sh + ``` diff --git a/dev/publish-release.sh b/dev/publish-release.sh new file mode 100755 index 0000000..394e88b --- /dev/null +++ b/dev/publish-release.sh @@ -0,0 +1,42 @@ +#!/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 ./dev/publish-release.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 + +VERSION_FILE_PATH="internal/index/version.txt" +if ! grep -q "$NEW_VERSION" "$VERSION_FILE_PATH"; then + echo "error: scip-go version in $VERSION_FILE_PATH 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 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" diff --git a/internal/index/scip.go b/internal/index/scip.go index f8ae4f2..578c46c 100644 --- a/internal/index/scip.go +++ b/internal/index/scip.go @@ -1,6 +1,7 @@ package index import ( + _ "embed" "fmt" "go/ast" "sort" @@ -23,7 +24,8 @@ import ( "google.golang.org/protobuf/proto" ) -const SCIP_GO_VERSION = "0.1.4" +//go:embed version.txt +var SCIP_GO_VERSION string type documentLookup = map[string]*document.Document @@ -90,7 +92,7 @@ func Index(writer func(proto.Message), opts config.IndexOpts) error { Version: 0, ToolInfo: &scip.ToolInfo{ Name: "scip-go", - Version: "0.1", + Version: SCIP_GO_VERSION, Arguments: []string{}, }, ProjectRoot: "file://" + opts.ModuleRoot, diff --git a/internal/index/version.txt b/internal/index/version.txt new file mode 100644 index 0000000..1180819 --- /dev/null +++ b/internal/index/version.txt @@ -0,0 +1 @@ +0.1.7