Skip to content

Commit bd63ea2

Browse files
radimclaude
andcommitted
chore: add goreleaser config and version subcommand
Ships Phase 0.x distribution scaffolding: cross-platform release builds (darwin/linux × amd64/arm64, CGO-on for pg_query_go) via GoReleaser, and a `qshape version` subcommand with ldflag-injected version/commit/date. Homebrew publication is handled manually in the boringsql tap — see `make update-binary FORMULA=qshape TAG=vX.Y.Z` there. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9c524ec commit bd63ea2

4 files changed

Lines changed: 98 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/bin/
2+
/dist/
23
/qshape
34
*.test
45
*.out

.goreleaser.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
version: 2
2+
3+
project_name: qshape
4+
5+
before:
6+
hooks:
7+
- go mod tidy
8+
9+
# pg_query_go requires CGO, so cross-compilation needs a cross toolchain.
10+
# In CI we build each OS on its own runner (see .github/workflows/release.yml).
11+
builds:
12+
- id: qshape-darwin
13+
main: ./cmd/qshape
14+
binary: qshape
15+
env:
16+
- CGO_ENABLED=1
17+
goos: [darwin]
18+
goarch: [amd64, arm64]
19+
ldflags:
20+
- -s -w
21+
- -X main.version={{.Version}}
22+
- -X main.commit={{.ShortCommit}}
23+
- -X main.date={{.Date}}
24+
- id: qshape-linux
25+
main: ./cmd/qshape
26+
binary: qshape
27+
env:
28+
- CGO_ENABLED=1
29+
- 'CC={{- if eq .Arch "arm64" -}}aarch64-linux-gnu-gcc{{- else -}}gcc{{- end -}}'
30+
goos: [linux]
31+
goarch: [amd64, arm64]
32+
ldflags:
33+
- -s -w
34+
- -X main.version={{.Version}}
35+
- -X main.commit={{.ShortCommit}}
36+
- -X main.date={{.Date}}
37+
38+
archives:
39+
- id: qshape
40+
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
41+
formats: [tar.gz]
42+
files:
43+
- README.md
44+
- LICENSE
45+
46+
checksum:
47+
name_template: "checksums.txt"
48+
49+
snapshot:
50+
version_template: "{{ incpatch .Version }}-next"
51+
52+
changelog:
53+
sort: asc
54+
use: github
55+
filters:
56+
exclude:
57+
- "^chore:"
58+
- "^docs:"
59+
- "^test:"
60+
- Merge pull request
61+
- Merge branch
62+
63+
release:
64+
github:
65+
owner: boringsql
66+
name: qshape
67+
draft: false
68+
prerelease: auto
69+
70+
# Homebrew publication is handled manually in the boringsql/homebrew-boringsql
71+
# tap via `make update FORMULA=qshape TAG=vX.Y.Z` (source-formula convention,
72+
# matching dryrun / fixturize / regresql). GoReleaser only builds release
73+
# binaries here; the tap is not auto-pushed.

cmd/qshape/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func Run() error {
1818
captureCmd(),
1919
attributeCmd(),
2020
regresqlStubCmd(),
21+
versionCmd(),
2122
)
2223
return root.Execute()
2324
}

cmd/qshape/version.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
)
8+
9+
var (
10+
version = "dev"
11+
commit = "none"
12+
date = "unknown"
13+
)
14+
15+
func versionCmd() *cobra.Command {
16+
return &cobra.Command{
17+
Use: "version",
18+
Short: "Print qshape version",
19+
Run: func(cmd *cobra.Command, args []string) {
20+
fmt.Printf("qshape %s (commit %s, built %s)\n", version, commit, date)
21+
},
22+
}
23+
}

0 commit comments

Comments
 (0)