From cf58f91e75927a773ea0ea76518602ab4865de96 Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Mon, 2 May 2022 14:03:51 +0100 Subject: [PATCH] Constant build tag. --- .github/workflows/go.yml | 2 +- cmd/zenity/build.sh | 12 +++++++----- cmd/zenity/main.go | 6 ++---- cmd/zenity/tag.go | 3 +++ go.mod | 4 ++-- go.sum | 8 ++++---- internal/zenutil/env.go | 1 + internal/zenutil/env_darwin.go | 2 +- internal/zenutil/env_unix.go | 3 +-- internal/zenutil/osa_generated.go | 2 +- 10 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 cmd/zenity/tag.go diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 5bdb24e..c3f9e5f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -20,7 +20,7 @@ jobs: go-version: 1.18 - name: Build - run: go build -v ./... + run: go build -v -tags dev ./... - name: Test run: go test -v ./... diff --git a/cmd/zenity/build.sh b/cmd/zenity/build.sh index 6961115..fbda411 100755 --- a/cmd/zenity/build.sh +++ b/cmd/zenity/build.sh @@ -1,19 +1,20 @@ #!/bin/bash -TAG=$(git tag --sort=-version:refname | head -n 1) +TAG=$(git tag --points-at HEAD) +echo 'package main; const tag = "'$TAG'"' > tag.go go run github.com/josephspurrier/goversioninfo/cmd/goversioninfo -GOOS=windows GOARCH=386 CGO_ENABLED=0 go build -ldflags="-s -w -X main.tag=$TAG" -trimpath && +GOOS=windows GOARCH=386 CGO_ENABLED=0 go build -trimpath && zip -9 zenity_win32.zip zenity.exe -GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.tag=$TAG" -trimpath && +GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -trimpath && zip -9 zenity_win64.zip zenity.exe rm resource.syso -GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.tag=$TAG" -trimpath -o zenity_macos_x64 && -GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.tag=$TAG" -trimpath -o zenity_macos_arm && +GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -o zenity_macos_x64 && +GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -trimpath -o zenity_macos_arm && go run github.com/randall77/makefat zenity zenity_macos_x64 zenity_macos_arm && zip -9 zenity_macos.zip zenity @@ -22,3 +23,4 @@ rm zenity zenity_macos_* zenity.exe GOOS=linux go build -tags dev go build -tags dev +git restore tag.go diff --git a/cmd/zenity/main.go b/cmd/zenity/main.go index dc33820..4bca1f6 100644 --- a/cmd/zenity/main.go +++ b/cmd/zenity/main.go @@ -26,8 +26,6 @@ import ( const unspecified = "\x00" -var tag = "" - var ( // Application Options errorDlg bool @@ -105,9 +103,9 @@ var ( ) func init() { - prevUsage := flag.Usage + usage := flag.Usage flag.Usage = func() { - prevUsage() + usage() os.Exit(-1) } } diff --git a/cmd/zenity/tag.go b/cmd/zenity/tag.go new file mode 100644 index 0000000..a5baa96 --- /dev/null +++ b/cmd/zenity/tag.go @@ -0,0 +1,3 @@ +package main + +const tag = "" diff --git a/go.mod b/go.mod index 8182500..fb75722 100644 --- a/go.mod +++ b/go.mod @@ -5,11 +5,11 @@ go 1.17 require ( github.com/dchest/jsmin v0.0.0-20220218165748-59f39799265f github.com/josephspurrier/goversioninfo v1.4.0 - github.com/ncruces/go-strftime v0.1.7 + github.com/ncruces/go-strftime v0.1.8 github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844 go.uber.org/goleak v1.1.12 // test golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 - golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 + golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 ) require ( diff --git a/go.sum b/go.sum index 4846aad..64b29ea 100644 --- a/go.sum +++ b/go.sum @@ -9,8 +9,8 @@ github.com/josephspurrier/goversioninfo v1.4.0/go.mod h1:JWzv5rKQr+MmW+LvM412ToT github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/ncruces/go-strftime v0.1.7 h1:FV16xPnWrx4zAD7zipPZYCzTI6ryUdQsiqPF2pUcC98= -github.com/ncruces/go-strftime v0.1.7/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/ncruces/go-strftime v0.1.8 h1:mdN5UnDgSCnhCjW0VavOAWSMT57lI5bCRXA6bxPozbg= +github.com/ncruces/go-strftime v0.1.8/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844 h1:GranzK4hv1/pqTIhMTXt2X8MmMOuH3hMeUR0o9SP5yc= @@ -42,8 +42,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc= -golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 h1:Js08h5hqB5xyWR789+QqueR6sDE8mk+YvpETZ+F6X9Y= +golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/internal/zenutil/env.go b/internal/zenutil/env.go index 12e4d5f..43ff36c 100644 --- a/internal/zenutil/env.go +++ b/internal/zenutil/env.go @@ -1,3 +1,4 @@ +// Package zenutil is internal. DO NOT USE. package zenutil // These are internal. diff --git a/internal/zenutil/env_darwin.go b/internal/zenutil/env_darwin.go index c4fd4a5..0b0af9f 100644 --- a/internal/zenutil/env_darwin.go +++ b/internal/zenutil/env_darwin.go @@ -4,7 +4,7 @@ package zenutil var ( Command bool Timeout int - LineBreak = "\n" Separator = "\x00" + LineBreak = "\n" DateFormat = "%F" ) diff --git a/internal/zenutil/env_unix.go b/internal/zenutil/env_unix.go index eaec7df..7c6336f 100644 --- a/internal/zenutil/env_unix.go +++ b/internal/zenutil/env_unix.go @@ -1,13 +1,12 @@ //go:build !windows && !darwin -// Package zenutil is internal. DO NOT USE. package zenutil // These are internal. var ( Command bool Timeout int - LineBreak = "\n" Separator = "\x1e" + LineBreak = "\n" DateFormat = "%F" ) diff --git a/internal/zenutil/osa_generated.go b/internal/zenutil/osa_generated.go index 91dbdf6..1aa7ba6 100644 --- a/internal/zenutil/osa_generated.go +++ b/internal/zenutil/osa_generated.go @@ -48,7 +48,7 @@ var res=alert.runModal switch(res){case $.NSAlertThirdButtonReturn:$.puts({{json .Extra}}) case $.NSAlertSecondButtonReturn:$.exit(1)} var fmt=$.NSDateFormatter.alloc.init -fmt.dateFormat={{json .Format}} +fmt.locale=$.NSLocale.localeWithLocaleIdentifier("en_US_POSIX");fmt.dateFormat={{json .Format}} fmt.stringFromDate(date.dateValue) {{- end}} {{define "dialog" -}}