Skip to content

Commit 6f4b29a

Browse files
committed
chore: add go release config and workflow
1 parent 19de487 commit 6f4b29a

5 files changed

Lines changed: 213 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release-linux:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: '1.23'
24+
25+
- name: Install cross-compilation dependencies
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get install -y gcc-aarch64-linux-gnu
29+
30+
- name: Run GoReleaser for Linux
31+
uses: goreleaser/goreleaser-action@v6
32+
with:
33+
distribution: goreleaser
34+
version: '~> v2'
35+
args: release --clean --config .goreleaser-linux.yaml
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
39+
release-darwin:
40+
runs-on: macos-latest
41+
needs: release-linux
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Set up Go
49+
uses: actions/setup-go@v5
50+
with:
51+
go-version: '1.23'
52+
53+
- name: Run GoReleaser for macOS
54+
uses: goreleaser/goreleaser-action@v6
55+
with:
56+
distribution: goreleaser
57+
version: '~> v2'
58+
args: release --clean --config .goreleaser-darwin.yaml
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
panda
33
!.gitignore
44
!.github
5+
!.goreleaser*

.goreleaser-darwin.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
2+
# GoReleaser config for macOS builds
3+
4+
version: 2
5+
6+
before:
7+
hooks:
8+
- go mod tidy
9+
- go mod verify
10+
11+
builds:
12+
- id: panda-darwin
13+
main: ./main.go
14+
binary: panda
15+
env:
16+
- CGO_ENABLED=1
17+
goos:
18+
- darwin
19+
goarch:
20+
- amd64
21+
- arm64
22+
flags:
23+
- -tags=fts5
24+
ldflags:
25+
- -s -w
26+
- -X main.version={{.Version}}
27+
- -X main.commit={{.Commit}}
28+
- -X main.date={{.Date}}
29+
30+
archives:
31+
- id: panda-archive
32+
format: tar.gz
33+
name_template: >-
34+
{{ .ProjectName }}_
35+
{{- .Version }}_
36+
{{- title .Os }}_
37+
{{- if eq .Arch "amd64" }}x86_64
38+
{{- else if eq .Arch "386" }}i386
39+
{{- else }}{{ .Arch }}{{ end }}
40+
files:
41+
- README.md
42+
- LICENSE*
43+
44+
checksum:
45+
name_template: 'checksums.txt'
46+
47+
snapshot:
48+
version_template: "{{ incpatch .Version }}-next"
49+
50+
changelog:
51+
sort: asc
52+
use: github
53+
filters:
54+
exclude:
55+
- '^docs:'
56+
- '^test:'
57+
- '^ci:'
58+
- '^chore:'
59+
- Merge pull request
60+
- Merge branch
61+
groups:
62+
- title: 'New Features'
63+
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
64+
order: 0
65+
- title: 'Bug Fixes'
66+
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
67+
order: 1
68+
- title: 'Other Changes'
69+
order: 999
70+
71+
release:
72+
github:
73+
owner: aavshr
74+
name: panda
75+
draft: false
76+
prerelease: auto
77+
mode: append
78+
name_template: "{{.ProjectName}} v{{.Version}}"

.goreleaser-linux.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
2+
version: 2
3+
4+
before:
5+
hooks:
6+
- go mod tidy
7+
- go mod verify
8+
9+
builds:
10+
- id: panda-linux
11+
main: ./main.go
12+
binary: panda
13+
env:
14+
- CGO_ENABLED=1
15+
goos:
16+
- linux
17+
goarch:
18+
- amd64
19+
- arm64
20+
flags:
21+
- -tags=fts5
22+
ldflags:
23+
- -s -w
24+
- -X main.version={{.Version}}
25+
- -X main.commit={{.Commit}}
26+
- -X main.date={{.Date}}
27+
overrides:
28+
- goos: linux
29+
goarch: arm64
30+
env:
31+
- CC=aarch64-linux-gnu-gcc
32+
33+
archives:
34+
- id: panda-archive
35+
format: tar.gz
36+
name_template: >-
37+
{{ .ProjectName }}_
38+
{{- .Version }}_
39+
{{- title .Os }}_
40+
{{- if eq .Arch "amd64" }}x86_64
41+
{{- else if eq .Arch "386" }}i386
42+
{{- else }}{{ .Arch }}{{ end }}
43+
files:
44+
- README.md
45+
- LICENSE*
46+
47+
checksum:
48+
name_template: 'checksums.txt'
49+
disable: true
50+
51+
changelog:
52+
disable: true
53+
54+
release:
55+
github:
56+
owner: aavshr
57+
name: panda
58+
draft: true
59+
prerelease: auto
60+
mode: append
61+
name_template: "{{.ProjectName}} v{{.Version}}"

main.go

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

33
import (
44
_ "embed"
5+
"fmt"
56
"log"
67
"os"
78

@@ -16,6 +17,13 @@ import (
1617
"golang.org/x/term"
1718
)
1819

20+
// build information injected by goreleaser
21+
var (
22+
version = "dev"
23+
commit = "none"
24+
date = "unknown"
25+
)
26+
1927
//go:embed internal/db/schema/init.sql
2028
var dbSchemaInit string
2129

@@ -76,6 +84,11 @@ func initMockStore() *store.Mock {
7684
}
7785

7886
func main() {
87+
if len(os.Args) > 1 && (os.Args[1] == "--version" || os.Args[1] == "-v") {
88+
fmt.Printf("panda %s\ncommit: %s\nbuilt at: %s\n", version, commit, date)
89+
os.Exit(0)
90+
}
91+
7992
isDev := strings.ToLower(os.Getenv("PANDA_ENV")) == "dev"
8093
dataDirPath := config.GetDataDir()
8194
databaseName := DefaultDatabaseName

0 commit comments

Comments
 (0)