Skip to content

Commit

Permalink
fix: Fix version number printed by scip-go (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
varungandhi-src authored Oct 26, 2023
1 parent 596fdb5 commit cfb0ebd
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
/scip-go

scratch/
.idea/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# ChangeLog
14 changes: 9 additions & 5 deletions Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `internal/index/version.txt`

2. On the `main` branch, run the following:

```bash
NEW_VERSION="M.N.P" ./dev/publish-release.sh
```
2 changes: 1 addition & 1 deletion cmd/scip-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
var app = kingpin.New(
"scip-go",
"scip-go is an SCIP indexer for Go.",
).Version(index.SCIP_GO_VERSION)
).Version(index.ScipGoVersion)

var (
outFile string
Expand Down
42 changes: 42 additions & 0 deletions dev/publish-release.sh
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 5 additions & 2 deletions internal/index/scip.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package index

import (
_ "embed"
"fmt"
"go/ast"
"sort"
Expand All @@ -23,7 +24,9 @@ import (
"google.golang.org/protobuf/proto"
)

const SCIP_GO_VERSION = "0.1.4"
//go:embed version.txt
var versionFile string
var ScipGoVersion string = strings.TrimSpace(versionFile)

type documentLookup = map[string]*document.Document

Expand Down Expand Up @@ -90,7 +93,7 @@ func Index(writer func(proto.Message), opts config.IndexOpts) error {
Version: 0,
ToolInfo: &scip.ToolInfo{
Name: "scip-go",
Version: "0.1",
Version: ScipGoVersion,
Arguments: []string{},
},
ProjectRoot: "file://" + opts.ModuleRoot,
Expand Down
1 change: 1 addition & 0 deletions internal/index/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.7

0 comments on commit cfb0ebd

Please sign in to comment.