Skip to content

Commit

Permalink
fix: Fix version number printed by scip-go
Browse files Browse the repository at this point in the history
  • Loading branch information
varungandhi-src committed Oct 26, 2023
1 parent bfd3924 commit 9525932
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 7 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 `cmd/version.txt`

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

```bash
NEW_VERSION="M.N.P" ./dev/publish-release.sh
```
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"
6 changes: 4 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,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

Expand Down Expand Up @@ -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,
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 9525932

Please sign in to comment.