Skip to content

Commit a077e74

Browse files
committed
Introduce goreleaser
1 parent 29d0162 commit a077e74

File tree

8 files changed

+69
-16
lines changed

8 files changed

+69
-16
lines changed

.github/workflows/goreleaser.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: goreleaser
2+
on:
3+
push:
4+
tags:
5+
- v[0-9]+.[0-9]+.[0-9]+
6+
jobs:
7+
goreleaser:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-go@v2
12+
with:
13+
go-version: ">=1.19.1"
14+
- uses: goreleaser/goreleaser-action@v2
15+
with:
16+
distribution: goreleaser
17+
version: latest
18+
args: release --rm-dist
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ jobs:
1616
# - macOS-latest
1717
# - windows-latest
1818
go:
19-
- "1.16"
20-
- "1.15"
21-
- "1.14"
19+
- "1.19.1"
2220
services:
2321
postgres:
2422
image: postgres:12
@@ -29,6 +27,8 @@ jobs:
2927
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
3028

3129
steps:
30+
- name: golangci-lint
31+
uses: golangci/golangci-lint-action@v3
3232
- name: Prepare planter
3333
run: |
3434
psql -U postgres -h localhost -d postgres -c 'CREATE USER dgw_test;'

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ _testmain.go
2424
*.prof
2525

2626
vendor
27+
28+
/dist/

.goreleaser.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
before:
2+
hooks:
3+
- go mod tidy
4+
builds:
5+
- ldflags:
6+
- -X main.version={{.Version}}
7+
env:
8+
- CGO_ENABLED=0
9+
goos:
10+
- linux
11+
- windows
12+
- darwin
13+
checksum:
14+
name_template: "checksums.txt"
15+
nfpms:
16+
- id: dgw-nfpms
17+
file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Arch }}"
18+
homepage: https://github.com/achiku/dgw
19+
maintainer: Akira Chiku <akira.chiku@gmail.com>
20+
description: dgw generates Golang struct, and simple Table/Row Data Gateway functions from PostgreSQL table metadata
21+
license: MIT
22+
formats:
23+
- deb
24+
- rpm
25+
bindir: /usr/bin

bindata.go

+13-11
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,18 @@ var _bindata = map[string]func() ([]byte, error){
6868
"template/method.tmpl": template_method_tmpl,
6969
"template/struct.tmpl": template_struct_tmpl,
7070
}
71+
7172
// AssetDir returns the file names below a certain
7273
// directory embedded in the file by go-bindata.
7374
// For example if you run go-bindata on data/... and data contains the
7475
// following hierarchy:
75-
// data/
76-
// foo.txt
77-
// img/
78-
// a.png
79-
// b.png
76+
//
77+
// data/
78+
// foo.txt
79+
// img/
80+
// a.png
81+
// b.png
82+
//
8083
// then AssetDir("data") would return []string{"foo.txt", "img"}
8184
// AssetDir("data/img") would return []string{"a.png", "b.png"}
8285
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
@@ -104,14 +107,13 @@ func AssetDir(name string) ([]string, error) {
104107
}
105108

106109
type _bintree_t struct {
107-
Func func() ([]byte, error)
110+
Func func() ([]byte, error)
108111
Children map[string]*_bintree_t
109112
}
113+
110114
var _bintree = &_bintree_t{nil, map[string]*_bintree_t{
111-
"template": &_bintree_t{nil, map[string]*_bintree_t{
112-
"method.tmpl": &_bintree_t{template_method_tmpl, map[string]*_bintree_t{
113-
}},
114-
"struct.tmpl": &_bintree_t{template_struct_tmpl, map[string]*_bintree_t{
115-
}},
115+
"template": {nil, map[string]*_bintree_t{
116+
"method.tmpl": {template_method_tmpl, map[string]*_bintree_t{}},
117+
"struct.tmpl": {template_struct_tmpl, map[string]*_bintree_t{}},
116118
}},
117119
}}

dgw.go

-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ func (t *PgTable) setPrimaryKeyInfo(cfg *AutoKeyMap) {
142142
}
143143
}
144144
}
145-
return
146145
}
147146

148147
// PgColumn postgres columns

funcmap.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func createInsertSQL(st *Struct) string {
117117
var sql string
118118
sql = "INSERT INTO " + st.Table.Name + " ("
119119

120-
if len(st.Table.Columns) == 1 && st.Table.Columns[0].IsPrimaryKey && st.Table.AutoGenPk{
120+
if len(st.Table.Columns) == 1 && st.Table.Columns[0].IsPrimaryKey && st.Table.AutoGenPk {
121121
sql = sql + st.Table.Columns[0].Name + ") VALUES (DEFAULT)"
122122
} else {
123123
var colNames []string

main.go

+5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ var (
2020
customTmpl = kingpin.Flag("template", "custom template path").String()
2121
outFile = kingpin.Flag("output", "output file path").Short('o').String()
2222
noQueryInterface = kingpin.Flag("no-interface", "output without Queryer interface").Bool()
23+
version string
2324
)
2425

26+
func init() {
27+
kingpin.Version(version)
28+
}
29+
2530
func main() {
2631
kingpin.Parse()
2732

0 commit comments

Comments
 (0)