diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a261f29 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist/* diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..10e20f9 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,31 @@ +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + ldflags: -s -w -X main.Version={{.Version}} -X main.Commit={{.Commit}} + binary: tailscale-acl-combiner +archives: + - name_template: "{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}" + 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 6b73dfd..b959d74 100644 --- a/main.go +++ b/main.go @@ -25,9 +25,15 @@ var ( inChildDir = flag.String("d", "", "directory to process files from") outFile = flag.String("o", "", "file to write output to") verbose = flag.Bool("v", false, "enable verbose logging") + version = flag.Bool("version", false, "print version and exit") allowedAclSections aclSections + + // build flags + Version = "snapshot" + Commit = "unknown" ) + type ParsedDocument struct { Path string Object *jwcc.Object @@ -67,6 +73,10 @@ func checkArgs() error { func main() { flag.Var(&allowedAclSections, "allow", "acl sections to allow from children") flag.Parse() + if *version { + fmt.Printf("%s-%s\n", Version, Commit) + os.Exit(0) + } argsErr := checkArgs() if argsErr != nil { fmt.Fprintf(os.Stderr, "%s\n", argsErr)