Skip to content

Commit 1879abd

Browse files
chore: update output filename to oak_gen, add goreleaser
1 parent 3088fa0 commit 1879abd

13 files changed

Lines changed: 149 additions & 268 deletions

File tree

.github/workflows/release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
# run only against tags
6+
tags:
7+
- "*"
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
goreleaser:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- run: git fetch --force --tags
20+
- uses: actions/setup-go@v5
21+
with:
22+
go-version: stable
23+
# More assembly might be required: Docker logins, GPG, etc. It all depends
24+
# on your needs.
25+
- uses: goreleaser/goreleaser-action@v6
26+
with:
27+
# either 'goreleaser' (default) or 'goreleaser-pro'
28+
distribution: goreleaser
29+
# 'latest', 'nightly', or a semver
30+
version: "~> v2"
31+
args: release --clean
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/dist

.goreleaser.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
before:
2+
hooks:
3+
- go mod tidy
4+
5+
builds:
6+
- id: oak
7+
main: ./cmd/oak
8+
binary: oak
9+
env:
10+
- CGO_ENABLED=0
11+
goos:
12+
- linux
13+
- windows
14+
- darwin
15+
goarch:
16+
- amd64
17+
- arm64
18+
- "386"
19+
goarm:
20+
- "7"
21+
ignore:
22+
- goos: windows
23+
goarch: "386"
24+
ldflags:
25+
- -s -w -X main.version={{.Version}}
26+
27+
archives:
28+
- id: oak
29+
format: tar.gz
30+
# this name template makes the OS and Arch compatible with the results of `uname`.
31+
name_template: >-
32+
{{ .ProjectName }}_
33+
{{- title .Os }}_
34+
{{- if eq .Arch "amd64" }}x86_64
35+
{{- else if eq .Arch "386" }}i386
36+
{{- else }}{{ .Arch }}{{ end }}
37+
{{- if .Arm }}v{{ .Arm }}{{ end }}
38+
# use zip for windows archives
39+
format_overrides:
40+
- goos: windows
41+
format: zip
42+
files:
43+
- README.md
44+
- LICENSE
45+
46+
checksum:
47+
name_template: 'checksums.txt'
48+
49+
snapshot:
50+
name_template: "{{ incpatch .Version }}-next"
51+
52+
changelog:
53+
sort: asc
54+
filters:
55+
exclude:
56+
- "^docs:"
57+
- "^test:"
58+
- "merge conflict"
59+
- Merge pull request
60+
- Merge remote-tracking branch
61+
- Merge branch
62+
- go mod tidy
63+
groups:
64+
- title: Dependency updates
65+
regexp: '^.*?(.+)\(deps\)!?:.+$'
66+
order: 300
67+
- title: "New Features"
68+
regexp: '^.*?feat(\(.+\))??!?:.+$'
69+
order: 100
70+
- title: "Security updates"
71+
regexp: '^.*?sec(\(.+\))??!?:.+$'
72+
order: 150
73+
- title: "Bug fixes"
74+
regexp: '^.*?fix(\(.+\))??!?:.+$'
75+
order: 200
76+
- title: "Documentation updates"
77+
regexp: '^.*?docs(\(.+\))??!?:.+$'
78+
order: 400
79+
- title: "Build process updates"
80+
regexp: '^.*?build(\(.+\))??!?:.+$'
81+
order: 400
82+
- title: Other work
83+
order: 9999
84+
85+
release:
86+
disable: false
87+
skip_upload: false

cmd/oak/main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/stuckinforloop/oak/internal/writer"
1212
)
1313

14-
const version = "v0.0.1"
14+
var version string
1515

1616
func main() {
1717
if err := run(os.Args[1:]); err != nil {
@@ -51,7 +51,7 @@ func run(args []string) error {
5151

5252
// Determine what to process
5353
target := opts.GetProcessingTarget()
54-
54+
5555
// Get the paths to process
5656
paths, err := getProcessingPaths(target, cfg)
5757
if err != nil {
@@ -94,7 +94,7 @@ func run(args []string) error {
9494
// Generate code for each package
9595
gen := generator.New(cfg)
9696
fileWriter := writer.New()
97-
97+
9898
var generatedFiles []string
9999

100100
for packageName, structs := range packageStructs {
@@ -110,7 +110,7 @@ func run(args []string) error {
110110
generatedFiles = append(generatedFiles, result.FilePath)
111111
}
112112

113-
fmt.Printf("Successfully processed %d struct(s) in %d package(s)\n",
113+
fmt.Printf("Successfully processed %d struct(s) in %d package(s)\n",
114114
len(allStructs), len(packageStructs))
115115

116116
return nil
@@ -121,27 +121,27 @@ func getProcessingPaths(target *cli.ProcessingTarget, cfg *config.Config) ([]str
121121
case cli.ModeSourceFile, cli.ModePackage:
122122
// Use paths from flags
123123
return target.Paths, nil
124-
124+
125125
case cli.ModePositional:
126126
// Expand positional arguments
127127
return cli.ExpandPaths(target.Paths)
128-
128+
129129
case cli.ModeConfig:
130130
// Use paths from configuration
131131
return cli.ExpandPaths(cfg.GetPackages())
132-
132+
133133
default:
134134
return nil, fmt.Errorf("unknown processing mode")
135135
}
136136
}
137137

138138
func groupStructsByPackage(structs []parser.StructInfo) map[string][]parser.StructInfo {
139139
groups := make(map[string][]parser.StructInfo)
140-
140+
141141
for _, s := range structs {
142142
groups[s.PackageName] = append(groups[s.PackageName], s)
143143
}
144-
144+
145145
return groups
146146
}
147147

0 commit comments

Comments
 (0)