build: uses goreleaser
This commit is contained in:
parent
dc00175f01
commit
a134755fab
39
.goreleaser.yaml
Normal file
39
.goreleaser.yaml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
# You may remove this if you don't use go modules.
|
||||||
|
- go mod tidy
|
||||||
|
# you may remove this if you don't need go generate
|
||||||
|
- go generate ./...
|
||||||
|
builds:
|
||||||
|
- env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
ldflags:
|
||||||
|
- -s
|
||||||
|
- -w
|
||||||
|
- -extldflags '-static'
|
||||||
|
- -X main.version={{.Version}}
|
||||||
|
- -X main.commit={{.Commit}}
|
||||||
|
- -X main.date={{.Date}}
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
- windows
|
||||||
|
- darwin
|
||||||
|
archives:
|
||||||
|
- format: tar.gz
|
||||||
|
# this name template makes the OS and Arch compatible with the results of uname.
|
||||||
|
name_template: >-
|
||||||
|
{{ .ProjectName }}_ {{- title .Os }}_ {{- if eq .Arch "amd64" }}x86_64 {{- else if eq .Arch "386" }}i386 {{- else }}{{ .Arch }}{{ end }} {{- if .Arm }}v{{ .Arm }}{{ end }}
|
||||||
|
# use zip for windows archives
|
||||||
|
format_overrides:
|
||||||
|
- goos: windows
|
||||||
|
format: zip
|
||||||
|
checksum:
|
||||||
|
name_template: 'checksums.txt'
|
||||||
|
snapshot:
|
||||||
|
name_template: "{{ incpatch .Version }}-next"
|
||||||
|
changelog:
|
||||||
|
sort: asc
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- '^docs:'
|
||||||
|
- '^test:'
|
16
main.go
16
main.go
@ -8,16 +8,32 @@ import (
|
|||||||
"go.xsfx.dev/amseltools/internal/dirtoexcel"
|
"go.xsfx.dev/amseltools/internal/dirtoexcel"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
version = "dev"
|
||||||
|
commit = "none"
|
||||||
|
date = "unknown"
|
||||||
|
)
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{}
|
var rootCmd = &cobra.Command{}
|
||||||
|
|
||||||
|
var versionCmd = &cobra.Command{
|
||||||
|
Use: "version",
|
||||||
|
Short: "Prints version info",
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
fmt.Printf("amseltools %s, commit %s, build at %s", version, commit, date)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
var dirToExcelCmd = &cobra.Command{
|
var dirToExcelCmd = &cobra.Command{
|
||||||
Use: "dir-to-excel [directory]",
|
Use: "dir-to-excel [directory]",
|
||||||
|
Short: "Takes a directory and creates an excel from it",
|
||||||
Run: dirtoexcel.Run,
|
Run: dirtoexcel.Run,
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
rootCmd.AddCommand(dirToExcelCmd)
|
rootCmd.AddCommand(dirToExcelCmd)
|
||||||
|
rootCmd.AddCommand(versionCmd)
|
||||||
|
|
||||||
// Flags.
|
// Flags.
|
||||||
dirToExcelCmd.Flags().StringP("out", "o", "", "output file")
|
dirToExcelCmd.Flags().StringP("out", "o", "", "output file")
|
||||||
|
Loading…
Reference in New Issue
Block a user