Skip to content

Commit 9f19abf

Browse files
Thomas StrombergThomas Stromberg
authored andcommitted
Release v0.9.1-test
1 parent 5fdf001 commit 9f19abf

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ BUNDLE_VERSION = 1
55
BUNDLE_ID = dev.codegroove.r2r
66

77
# Version information for builds
8-
GIT_VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
8+
# Try VERSION file first (for release tarballs), then fall back to git
9+
VERSION_FILE := $(shell cat cmd/goose/VERSION 2>/dev/null)
10+
GIT_VERSION := $(shell git describe --tags --always --dirty 2>/dev/null)
11+
BUILD_VERSION := $(or $(VERSION_FILE),$(GIT_VERSION),dev)
912
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
1013
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
11-
LDFLAGS := -X main.version=$(GIT_VERSION) -X main.commit=$(GIT_COMMIT) -X main.date=$(BUILD_DATE)
14+
LDFLAGS := -X main.version=$(BUILD_VERSION) -X main.commit=$(GIT_COMMIT) -X main.date=$(BUILD_DATE)
1215

1316
.PHONY: all build clean deps run app-bundle install install-darwin install-unix install-windows test release
1417

@@ -278,6 +281,12 @@ release:
278281
@$(MAKE) test
279282
@echo "Running linters..."
280283
@$(MAKE) lint
284+
@echo "Creating VERSION file..."
285+
@echo "$(VERSION)" > cmd/goose/VERSION
286+
@git add cmd/goose/VERSION
287+
@if [ -n "$$(git diff --cached --name-only)" ]; then \
288+
git commit -m "Release $(VERSION)"; \
289+
fi
281290
@echo "Checking for uncommitted changes..."
282291
@if [ -n "$$(git status --porcelain)" ]; then \
283292
echo "Error: Working directory has uncommitted changes"; \
@@ -286,6 +295,7 @@ release:
286295
fi
287296
@echo "Creating and pushing tag $(VERSION)..."
288297
@git tag -a "$(VERSION)" -m "Release $(VERSION)"
298+
@git push origin main
289299
@git push origin "$(VERSION)"
290300
@echo "✓ Release $(VERSION) created and pushed successfully"
291301
@echo " View release at: https://github.com/codeGROOVE-dev/goose/releases/tag/$(VERSION)"

cmd/goose/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v0.9.1-test

cmd/goose/main.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package main
66

77
import (
88
"context"
9+
_ "embed"
910
"flag"
1011
"fmt"
1112
"log/slog"
@@ -24,13 +25,32 @@ import (
2425
"github.com/google/go-github/v57/github"
2526
)
2627

28+
// VERSION file embedded at compile time (created by make release)
29+
//
30+
//go:embed VERSION
31+
var versionFile string
32+
2733
// Version information - set during build with -ldflags.
34+
// If not set via ldflags, getVersion() will read from embedded VERSION file.
2835
var (
2936
version = "dev"
3037
commit = "unknown"
3138
date = "unknown"
3239
)
3340

41+
// getVersion returns the version string, preferring ldflags but falling back to VERSION file.
42+
func getVersion() string {
43+
// If version was set via ldflags and isn't the default, use it
44+
if version != "" && version != "dev" {
45+
return version
46+
}
47+
// Fall back to embedded VERSION file
48+
if v := strings.TrimSpace(versionFile); v != "" {
49+
return v
50+
}
51+
return "dev"
52+
}
53+
3454
const (
3555
cacheTTL = 10 * 24 * time.Hour // 10 days - rely mostly on PR UpdatedAt
3656
runningTestsCacheTTL = 2 * time.Minute // Short TTL for PRs with incomplete tests to catch completions quickly
@@ -134,7 +154,7 @@ func main() {
134154

135155
// Handle version flag
136156
if showVersion {
137-
fmt.Printf("goose version %s\ncommit: %s\nbuilt: %s\n", version, commit, date)
157+
fmt.Printf("goose version %s\ncommit: %s\nbuilt: %s\n", getVersion(), commit, date)
138158
os.Exit(0)
139159
}
140160

@@ -176,7 +196,7 @@ func main() {
176196
Level: logLevel,
177197
}
178198
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, opts)))
179-
slog.Info("Starting Goose", "version", version, "commit", commit, "date", date)
199+
slog.Info("Starting Goose", "version", getVersion(), "commit", commit, "date", date)
180200
slog.Info("Configuration", "update_interval", updateInterval, "max_retries", maxRetries, "max_delay", maxRetryDelay)
181201
slog.Info("Browser auto-open configuration",
182202
"startup_delay", browserOpenDelay,

0 commit comments

Comments
 (0)