Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version output and goreleaser build config #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/*
31 changes: 31 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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:"
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down