Skip to content

Commit be02486

Browse files
authored
Merge pull request #89 from tstromberg/main
Add --version + "make release" workflow
2 parents 4890609 + 3ae7cb6 commit be02486

File tree

6 files changed

+115
-11
lines changed

6 files changed

+115
-11
lines changed

Makefile

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ 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

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

1518
test:
1619
go test -race ./...
@@ -133,6 +136,10 @@ app-bundle: out build-darwin install-appify
133136
/usr/libexec/PlistBuddy -c "Set :CFBundleDevelopmentRegion en" "out/$(BUNDLE_NAME).app/Contents/Info.plist"
134137
@/usr/libexec/PlistBuddy -c "Add :NSUserNotificationAlertStyle string alert" "out/$(BUNDLE_NAME).app/Contents/Info.plist" 2>/dev/null || \
135138
/usr/libexec/PlistBuddy -c "Set :NSUserNotificationAlertStyle alert" "out/$(BUNDLE_NAME).app/Contents/Info.plist"
139+
@/usr/libexec/PlistBuddy -c "Add :CFBundleShortVersionString string $(BUILD_VERSION)" "out/$(BUNDLE_NAME).app/Contents/Info.plist" 2>/dev/null || \
140+
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $(BUILD_VERSION)" "out/$(BUNDLE_NAME).app/Contents/Info.plist"
141+
@/usr/libexec/PlistBuddy -c "Add :CFBundleVersion string $(BUILD_VERSION)" "out/$(BUNDLE_NAME).app/Contents/Info.plist" 2>/dev/null || \
142+
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $(BUILD_VERSION)" "out/$(BUNDLE_NAME).app/Contents/Info.plist"
136143

137144
# Remove extended attributes and code sign the app bundle
138145
@echo "Preparing app bundle for signing..."
@@ -257,3 +264,42 @@ fix:
257264
exit $$exit_code
258265

259266
# END: lint-install .
267+
268+
# Release workflow - creates a new version tag
269+
# Usage: make release VERSION=v1.0.0
270+
release:
271+
@if [ -z "$(VERSION)" ]; then \
272+
echo "Error: VERSION is required. Usage: make release VERSION=v1.0.0"; \
273+
exit 1; \
274+
fi
275+
@echo "Creating release $(VERSION)..."
276+
@if ! echo "$(VERSION)" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+'; then \
277+
echo "Error: VERSION must be in format vX.Y.Z or vX.Y.Z-suffix (e.g., v1.0.0, v1.0.0-alpha)"; \
278+
exit 1; \
279+
fi
280+
@if git rev-parse "$(VERSION)" >/dev/null 2>&1; then \
281+
echo "Error: Tag $(VERSION) already exists"; \
282+
exit 1; \
283+
fi
284+
@echo "Running tests..."
285+
@$(MAKE) test
286+
@echo "Running linters..."
287+
@$(MAKE) lint
288+
@echo "Creating VERSION file..."
289+
@echo "$(VERSION)" > cmd/goose/VERSION
290+
@git add cmd/goose/VERSION
291+
@if [ -n "$$(git diff --cached --name-only)" ]; then \
292+
git commit -m "Release $(VERSION)"; \
293+
fi
294+
@echo "Checking for uncommitted changes..."
295+
@if [ -n "$$(git status --porcelain)" ]; then \
296+
echo "Error: Working directory has uncommitted changes"; \
297+
git status --short; \
298+
exit 1; \
299+
fi
300+
@echo "Creating and pushing tag $(VERSION)..."
301+
@git tag -a "$(VERSION)" -m "Release $(VERSION)"
302+
@git push origin main
303+
@git push origin "$(VERSION)"
304+
@echo "✓ Release $(VERSION) created and pushed successfully"
305+
@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/icons_darwin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var iconWarning []byte
2424
//go:embed icons/cockroach.png
2525
var iconCockroach []byte
2626

27-
func getIcon(iconType IconType, counts PRCounts) []byte {
27+
func getIcon(iconType IconType, _ PRCounts) []byte {
2828
switch iconType {
2929
case IconGoose, IconBoth:
3030
return iconGoose

cmd/goose/main.go

Lines changed: 29 additions & 1 deletion
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
@@ -117,19 +137,27 @@ func main() {
117137
var targetUser string
118138
var noCache bool
119139
var debugMode bool
140+
var showVersion bool
120141
var updateInterval time.Duration
121142
var browserOpenDelay time.Duration
122143
var maxBrowserOpensMinute int
123144
var maxBrowserOpensDay int
124145
flag.StringVar(&targetUser, "user", "", "GitHub user to query PRs for (defaults to authenticated user)")
125146
flag.BoolVar(&noCache, "no-cache", false, "Bypass cache for debugging")
126147
flag.BoolVar(&debugMode, "debug", false, "Enable debug logging")
148+
flag.BoolVar(&showVersion, "version", false, "Show version information and exit")
127149
flag.DurationVar(&updateInterval, "interval", defaultUpdateInterval, "Update interval (e.g. 30s, 1m, 5m)")
128150
flag.DurationVar(&browserOpenDelay, "browser-delay", 1*time.Minute, "Minimum delay before opening PRs in browser after startup")
129151
flag.IntVar(&maxBrowserOpensMinute, "browser-max-per-minute", 2, "Maximum browser windows to open per minute")
130152
flag.IntVar(&maxBrowserOpensDay, "browser-max-per-day", defaultMaxBrowserOpensDay, "Maximum browser windows to open per day")
131153
flag.Parse()
132154

155+
// Handle version flag
156+
if showVersion {
157+
fmt.Printf("goose version %s\ncommit: %s\nbuilt: %s\n", getVersion(), commit, date)
158+
os.Exit(0)
159+
}
160+
133161
// Validate target user if provided
134162
if targetUser != "" {
135163
if err := validateGitHubUsername(targetUser); err != nil {
@@ -168,7 +196,7 @@ func main() {
168196
Level: logLevel,
169197
}
170198
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, opts)))
171-
slog.Info("Starting Goose", "version", version, "commit", commit, "date", date)
199+
slog.Info("Starting Goose", "version", getVersion(), "commit", commit, "date", date)
172200
slog.Info("Configuration", "update_interval", updateInterval, "max_retries", maxRetries, "max_delay", maxRetryDelay)
173201
slog.Info("Browser auto-open configuration",
174202
"startup_delay", browserOpenDelay,

cmd/goose/x11tray/tray_other.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//go:build !linux && !freebsd && !openbsd && !netbsd && !dragonfly && !solaris && !illumos && !aix
22

3+
// Package x11tray provides system tray proxy support for Unix-like systems.
4+
// On non-Unix platforms (macOS, Windows), the systray library handles tray functionality natively.
35
package x11tray
46

57
import (
@@ -16,18 +18,18 @@ func HealthCheck() error {
1618
type ProxyProcess struct{}
1719

1820
// Stop is a no-op on non-Unix platforms.
19-
func (p *ProxyProcess) Stop() error {
21+
func (*ProxyProcess) Stop() error {
2022
return nil
2123
}
2224

23-
// TryProxy is not needed on non-Unix platforms and always returns nil.
24-
func TryProxy(ctx context.Context) (*ProxyProcess, error) {
25-
return nil, nil
25+
// TryProxy is not needed on non-Unix platforms.
26+
func TryProxy(_ context.Context) (*ProxyProcess, error) {
27+
return &ProxyProcess{}, nil
2628
}
2729

2830
// EnsureTray always succeeds on non-Unix platforms.
29-
func EnsureTray(ctx context.Context) (*ProxyProcess, error) {
30-
return nil, nil
31+
func EnsureTray(_ context.Context) (*ProxyProcess, error) {
32+
return &ProxyProcess{}, nil
3133
}
3234

3335
// ShowContextMenu is a no-op on non-Unix platforms.

goose.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
class Goose < Formula
2+
desc "Menubar app for GitHub pull request tracking and notifications"
3+
homepage "https://github.com/codeGROOVE-dev/goose"
4+
url "https://github.com/ready-to-review/goose.git",
5+
tag: "v3.7.1",
6+
revision: "920467c86e2123db4d47503de341bfb5aca79b42"
7+
license "GPL-3.0-only"
8+
head "https://github.com/ready-to-review/goose.git", branch: "main"
9+
10+
depends_on "go" => :build
11+
depends_on "gh"
12+
13+
def install
14+
ldflags = %W[
15+
-X main.version=#{version}
16+
-X main.commit=#{Utils.git_short_head}
17+
-X main.date=#{time.iso8601}
18+
]
19+
20+
system "go", "build", *std_go_args(ldflags:, output: bin/"goose"), "./cmd/goose"
21+
end
22+
23+
test do
24+
output = shell_output("#{bin}/goose --version")
25+
assert_match version.to_s, output
26+
end
27+
end

0 commit comments

Comments
 (0)