From 74405117406d6bb2e60837dc5a677358430f7eb0 Mon Sep 17 00:00:00 2001 From: Justin Harms Date: Fri, 2 Jan 2026 14:28:03 -0600 Subject: [PATCH] Add GoReleaser configuration and update Makefile for streamlined builds - Introduced .goreleaser.yaml for automated release management. - Updated Makefile to utilize GoReleaser for building the jiggablend binary. - Added new workflows for release tagging and pull request checks in Gitea. - Updated dependencies in go.mod and go.sum, including new packages for versioning. - Enhanced .gitignore to exclude build artifacts in the dist directory. --- .gitea/workflows/release-tag.yaml | 24 +++++++++++++++ .gitea/workflows/test-pr.yaml | 15 ++++++++++ .gitignore | 1 + .goreleaser.yaml | 48 +++++++++++++++++++++++++++++ Makefile | 50 ++++++++++++------------------- cmd/jiggablend/cmd/root.go | 1 - cmd/jiggablend/cmd/version.go | 25 ++++++++++++++++ cmd/jiggablend/main.go | 2 +- go.mod | 4 +-- go.sum | 6 ++-- version/version.go | 16 ++++++++++ 11 files changed, 153 insertions(+), 39 deletions(-) create mode 100644 .gitea/workflows/release-tag.yaml create mode 100644 .gitea/workflows/test-pr.yaml create mode 100644 .goreleaser.yaml create mode 100644 cmd/jiggablend/cmd/version.go create mode 100644 version/version.go diff --git a/.gitea/workflows/release-tag.yaml b/.gitea/workflows/release-tag.yaml new file mode 100644 index 0000000..1f46fca --- /dev/null +++ b/.gitea/workflows/release-tag.yaml @@ -0,0 +1,24 @@ +name: Release Tag +on: + push: + tags: + - '*' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + with: + fetch-depth: 0 + - run: git fetch --force --tags + - uses: actions/setup-go@main + with: + go-version-file: 'go.mod' + - uses: goreleaser/goreleaser-action@master + with: + distribution: goreleaser + version: 'latest' + args: release + env: + GITEA_TOKEN: ${{secrets.RELEASE_TOKEN}} \ No newline at end of file diff --git a/.gitea/workflows/test-pr.yaml b/.gitea/workflows/test-pr.yaml new file mode 100644 index 0000000..33a868a --- /dev/null +++ b/.gitea/workflows/test-pr.yaml @@ -0,0 +1,15 @@ +name: PR Check +on: + - pull_request + +jobs: + check-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - uses: actions/setup-go@main + with: + go-version-file: 'go.mod' + - run: go mod tidy + - run: go build ./... + - run: go test -race -v -shuffle=on ./... \ No newline at end of file diff --git a/.gitignore b/.gitignore index 102880c..a30a403 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,7 @@ lerna-debug.log* *.o *.a *.so +/dist/ # Temporary files *.tmp diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..3c8db37 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,48 @@ +version: 2 + +before: + hooks: + - go mod tidy -v + - sh -c "cd web && npm install && npm run build" + +builds: + - id: default + main: ./cmd/jiggablend + binary: jiggablend + ldflags: + - -X jiggablend/version.Version={{.Version}} + - -X jiggablend/version.Date={{.Date}} + env: + - CGO_ENABLED=1 + goos: + - linux + goarch: + - amd64 + +checksum: + name_template: "checksums.txt" + +archives: + - id: default + name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}" + formats: tar.gz + format_overrides: + - goos: windows + formats: zip + files: + - README.md + - LICENSE + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + +release: + name_template: "{{ .ProjectName }}-{{ .Version }}" + +gitea_urls: + api: https://git.s1d3sw1ped.com/api/v1 + download: https://git.s1d3sw1ped.com diff --git a/Makefile b/Makefile index 19bfe8b..0f9b421 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,11 @@ -.PHONY: build build-web run run-manager run-runner cleanup cleanup-manager cleanup-runner kill-all clean-bin clean-web test help install +.PHONY: build build-web run run-manager run-runner cleanup cleanup-manager cleanup-runner clean-bin clean-web test help install # Build the jiggablend binary (includes embedded web UI) -build: clean-bin build-web - go build -o bin/jiggablend ./cmd/jiggablend - -# Build for Linux (cross-compile) -build-linux: clean-bin build-web - GOOS=linux GOARCH=amd64 go build -o bin/jiggablend ./cmd/jiggablend +build: + @echo "Building with GoReleaser..." + goreleaser build --clean --snapshot --single-target + @mkdir -p bin + @find dist -name jiggablend -type f -exec cp {} bin/jiggablend \; # Build web UI build-web: clean-web @@ -27,10 +26,6 @@ cleanup-runner: # Cleanup both manager and runner logs cleanup: cleanup-manager cleanup-runner -# Kill all jiggablend processes -kill-all: - @echo "Not implemented" - # Run manager and runner in parallel (for testing) run: cleanup build init-test @echo "Starting manager and runner in parallel..." @@ -74,37 +69,30 @@ clean-web: test: go test ./... -timeout 30s -# Install to /usr/local/bin -install: build - sudo cp bin/jiggablend /usr/local/bin/ - # Show help help: @echo "Jiggablend Build and Run Makefile" @echo "" @echo "Build targets:" - @echo " build - Build jiggablend binary with embedded web UI" - @echo " build-linux - Cross-compile for Linux amd64" - @echo " build-web - Build web UI only" + @echo " build - Build jiggablend binary with embedded web UI" + @echo " build-web - Build web UI only" @echo "" @echo "Run targets:" - @echo " run - Run manager and runner in parallel (for testing)" - @echo " run-manager - Run manager server" - @echo " run-runner - Run runner with test API key" - @echo " init-test - Initialize test configuration (run once)" + @echo " run - Run manager and runner in parallel (for testing)" + @echo " run-manager - Run manager server" + @echo " run-runner - Run runner with test API key" + @echo " init-test - Initialize test configuration (run once)" @echo "" @echo "Cleanup targets:" - @echo " cleanup - Clean all logs" - @echo " cleanup-manager - Clean manager logs" - @echo " cleanup-runner - Clean runner logs" - @echo " kill-all - Kill all running jiggablend processes" + @echo " cleanup - Clean all logs" + @echo " cleanup-manager - Clean manager logs" + @echo " cleanup-runner - Clean runner logs" @echo "" @echo "Other targets:" - @echo " clean-bin - Clean build artifacts" - @echo " clean-web - Clean web build artifacts" - @echo " test - Run Go tests" - @echo " install - Install to /usr/local/bin" - @echo " help - Show this help" + @echo " clean-bin - Clean build artifacts" + @echo " clean-web - Clean web build artifacts" + @echo " test - Run Go tests" + @echo " help - Show this help" @echo "" @echo "CLI Usage:" @echo " jiggablend manager serve - Start the manager server" diff --git a/cmd/jiggablend/cmd/root.go b/cmd/jiggablend/cmd/root.go index 21d14db..4f6947c 100644 --- a/cmd/jiggablend/cmd/root.go +++ b/cmd/jiggablend/cmd/root.go @@ -32,4 +32,3 @@ func exitWithError(msg string, args ...interface{}) { fmt.Fprintf(os.Stderr, "Error: "+msg+"\n", args...) os.Exit(1) } - diff --git a/cmd/jiggablend/cmd/version.go b/cmd/jiggablend/cmd/version.go new file mode 100644 index 0000000..83f147f --- /dev/null +++ b/cmd/jiggablend/cmd/version.go @@ -0,0 +1,25 @@ +package cmd + +import ( + "fmt" + + "jiggablend/version" + + "github.com/spf13/cobra" +) + +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Print the version information", + Long: `Print the version and build date of jiggablend.`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Printf("jiggablend version %s\n", version.Version) + if version.Date != "" { + fmt.Printf("Build date: %s\n", version.Date) + } + }, +} + +func init() { + rootCmd.AddCommand(versionCmd) +} diff --git a/cmd/jiggablend/main.go b/cmd/jiggablend/main.go index f5e7d13..d8ac241 100644 --- a/cmd/jiggablend/main.go +++ b/cmd/jiggablend/main.go @@ -4,6 +4,7 @@ import ( "os" "jiggablend/cmd/jiggablend/cmd" + _ "jiggablend/version" ) func main() { @@ -11,4 +12,3 @@ func main() { os.Exit(1) } } - diff --git a/go.mod b/go.mod index fe7a8fd..d049675 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,8 @@ go 1.25.4 require ( github.com/go-chi/chi/v5 v5.2.3 + github.com/go-chi/cors v1.2.2 + github.com/golang-migrate/migrate/v4 v4.19.0 github.com/google/uuid v1.6.0 github.com/gorilla/websocket v1.5.3 github.com/mattn/go-sqlite3 v1.14.32 @@ -17,9 +19,7 @@ require ( cloud.google.com/go/compute/metadata v0.5.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect - github.com/go-chi/cors v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect - github.com/golang-migrate/migrate/v4 v4.19.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect diff --git a/go.sum b/go.sum index 55e91ab..0818c53 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= -cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY= cloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= @@ -34,8 +32,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= -github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= diff --git a/version/version.go b/version/version.go new file mode 100644 index 0000000..99c307c --- /dev/null +++ b/version/version.go @@ -0,0 +1,16 @@ +// version/version.go +package version + +import "time" + +var Version string +var Date string + +func init() { + if Version == "" { + Version = "0.0.0-dev" + } + if Date == "" { + Date = time.Now().Format("2006-01-02 15:04:05") + } +}