diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..315c09b --- /dev/null +++ b/.goreleaser.yaml @@ -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:' diff --git a/main.go b/main.go index 62df382..0356909 100644 --- a/main.go +++ b/main.go @@ -8,16 +8,32 @@ import ( "go.xsfx.dev/amseltools/internal/dirtoexcel" ) +var ( + version = "dev" + commit = "none" + date = "unknown" +) + 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{ - Use: "dir-to-excel [directory]", - Run: dirtoexcel.Run, - Args: cobra.ExactArgs(1), + Use: "dir-to-excel [directory]", + Short: "Takes a directory and creates an excel from it", + Run: dirtoexcel.Run, + Args: cobra.ExactArgs(1), } func main() { rootCmd.AddCommand(dirToExcelCmd) + rootCmd.AddCommand(versionCmd) // Flags. dirToExcelCmd.Flags().StringP("out", "o", "", "output file")