mirror of
https://github.com/wearepixel/pulsewise-collector.git
synced 2026-11-14 14:01:50 +00:00
feat: version/update subcommands, VERSION file, deploy version bumping
- Add VERSION file as canonical version source - build.sh reads VERSION file automatically, injects via -ldflags - deploy.sh prompts for major/minor/patch bump, injects version via ldflags into all 4 builds, and writes release/latest JSON file - Add 'pulsewise-collector version' — prints version and checks for update - Add 'pulsewise-collector update' — fetches and applies the latest release - Default version changed to "dev" for local builds without ldflags
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
VERSION="${VERSION:-0.1.0}"
|
VERSION="${VERSION:-$(cat VERSION)}"
|
||||||
|
|
||||||
go build -ldflags "-X main.version=${VERSION}" -o pulsewise-collector .
|
go build -ldflags "-X main.version=${VERSION}" -o pulsewise-collector .
|
||||||
echo "Built: pulsewise-collector (v${VERSION})"
|
echo "Built: pulsewise-collector (v${VERSION})"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// version is set at build time via -ldflags "-X main.version=x.y.z"
|
// version is set at build time via -ldflags "-X main.version=x.y.z"
|
||||||
var version = "0.1.0"
|
var version = "dev"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultURL = "https://pulsewise.app/api/collect"
|
defaultURL = "https://pulsewise.app/api/collect"
|
||||||
@@ -144,6 +144,17 @@ type ProcessInfo struct {
|
|||||||
var prevNet *networkSnapshot
|
var prevNet *networkSnapshot
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if len(os.Args) > 1 {
|
||||||
|
switch os.Args[1] {
|
||||||
|
case "version":
|
||||||
|
runVersionCommand()
|
||||||
|
return
|
||||||
|
case "update":
|
||||||
|
runUpdateCommand()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
noAutoUpdate := flag.Bool("no-auto-update", false, "disable automatic updates")
|
noAutoUpdate := flag.Bool("no-auto-update", false, "disable automatic updates")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@@ -174,6 +185,54 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
// Subcommands
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
func runVersionCommand() {
|
||||||
|
fmt.Printf("pulsewise-collector v%s\n\n", version)
|
||||||
|
|
||||||
|
fmt.Print("Checking for updates... ")
|
||||||
|
latest, err := fetchLatestVersion()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("(update check failed: %v)\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if latest == version {
|
||||||
|
fmt.Println("You are on the latest version.")
|
||||||
|
} else {
|
||||||
|
fmt.Printf("v%s is available.\n", latest)
|
||||||
|
fmt.Println("Run 'pulsewise-collector update' to upgrade.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func runUpdateCommand() {
|
||||||
|
fmt.Printf("pulsewise-collector v%s\n\n", version)
|
||||||
|
|
||||||
|
fmt.Print("Checking for updates... ")
|
||||||
|
latest, err := fetchLatestVersion()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "update check failed: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if latest == version {
|
||||||
|
fmt.Printf("Already on the latest version (v%s).\n", version)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("v%s is available.\n\n", latest)
|
||||||
|
fmt.Print("Downloading... ")
|
||||||
|
|
||||||
|
if err := downloadAndReplace(); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "\nUpdate failed: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Done.\nSuccessfully updated to v%s.\n", latest)
|
||||||
|
}
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
// ─────────────────────────────────────────────────────────────
|
||||||
// Auto-update
|
// Auto-update
|
||||||
// ─────────────────────────────────────────────────────────────
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user