diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..09892b2 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,42 @@ +before: + hooks: + # clean up/install modules + - go mod tidy + - "go run tools/windows_metadata/release.go v{{- .Version }}" +builds: + - main: + hooks: + pre: + - "rm -f resource.syso" + - "go generate" + ignore: + - goos: windows + goarch: arm64 + ldflags: + - '{{ if eq .Os "windows" }}-H=windowsgui{{ end }}' + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin +archives: + - replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^Merge:' + - '^docs:' + - '^test:' + - '^[Bb]ump' + - '^[Cc]lean' diff --git a/dau_nonwindows.go b/dau_nonwindows.go index b236a00..04b8409 100644 --- a/dau_nonwindows.go +++ b/dau_nonwindows.go @@ -1,4 +1,5 @@ -//go:build !windows +//go:build darwin || linux +// +build darwin linux package main diff --git a/dau_windows.go b/dau_windows.go index 29d4510..b0b7947 100644 --- a/dau_windows.go +++ b/dau_windows.go @@ -10,12 +10,10 @@ import ( "github.com/tardisx/discord-auto-upload/version" ) -//go:embed dau.ico -var appIcon []byte - //go:generate goversioninfo -// -manifest=testdata/resource/goversioninfo.exe.manifest +//go:embed dau.ico +var appIcon []byte func mainloop(c *config.ConfigService) { systray.Run(func() { onReady(c) }, onExit) diff --git a/go.mod b/go.mod index b35740f..784a22d 100644 --- a/go.mod +++ b/go.mod @@ -7,9 +7,9 @@ require ( github.com/getlantern/systray v1.2.1 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/gorilla/mux v1.8.0 - github.com/josephspurrier/goversioninfo v1.4.0 // indirect github.com/mitchellh/go-homedir v1.1.0 github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 + github.com/stretchr/testify v1.6.1 // indirect golang.org/x/image v0.0.0-20210504121937-7319ad40d33e golang.org/x/mod v0.4.2 ) diff --git a/go.sum b/go.sum index 7af6fc9..c96ce8c 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw= -github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8= @@ -24,8 +22,6 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF0 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/josephspurrier/goversioninfo v1.4.0 h1:Puhl12NSHUSALHSuzYwPYQkqa2E1+7SrtAPJorKK0C8= -github.com/josephspurrier/goversioninfo v1.4.0/go.mod h1:JWzv5rKQr+MmW+LvM412ToT/IkYDZjaclF2pKDss8IY= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw= @@ -35,7 +31,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EEf9cgbU6AtGPK4CTG3Zf6CKMNqf0MHTggAUA= github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -57,4 +52,5 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/tools/windows_metadata/release.go b/tools/windows_metadata/release.go new file mode 100644 index 0000000..f3d6096 --- /dev/null +++ b/tools/windows_metadata/release.go @@ -0,0 +1,84 @@ +package main + +import ( + "log" + "os" + "regexp" + "strings" + + "golang.org/x/mod/semver" +) + +const versionInfoTemplate = ` +{ + "FixedFileInfo": { + "FileVersion": { + "Major": MAJOR, + "Minor": MINOR, + "Patch": PATCH, + "Build": 0 + }, + "ProductVersion": { + "Major": MAJOR, + "Minor": MINOR, + "Patch": PATCH, + "Build": 0 + }, + "FileFlagsMask": "3f", + "FileFlags ": "00", + "FileOS": "040004", + "FileType": "01", + "FileSubType": "00" + }, + "StringFileInfo": { + "Comments": "", + "CompanyName": "tardisx@github", + "FileDescription": "https://github.com/tardisx/discord-auto-upload", + "FileVersion": "", + "InternalName": "", + "LegalCopyright": "https://github.com/tardisx/discord-auto-upload/blob/master/LICENSE", + "LegalTrademarks": "", + "OriginalFilename": "", + "PrivateBuild": "", + "ProductName": "discord-auto-upload", + "ProductVersion": "VERSION", + "SpecialBuild": "" + }, + "VarFileInfo": { + "Translation": { + "LangID": "0409", + "CharsetID": "04B0" + } + }, + "IconPath": "dau.ico", + "ManifestPath": "" +} +` + +var nonAlphanumericRegex = regexp.MustCompile(`[^0-9]+`) + +func main() { + version := os.Args[1] + if !semver.IsValid(version) { + panic("bad version" + version) + } + parts := strings.Split(version, ".") + if len(parts) != 3 { + log.Fatalf("bad version: %s", version) + } + + parts[0] = nonAlphanumericRegex.ReplaceAllString(parts[0], "") + parts[1] = nonAlphanumericRegex.ReplaceAllString(parts[1], "") + parts[2] = nonAlphanumericRegex.ReplaceAllString(parts[2], "") + + out := versionInfoTemplate + out = strings.Replace(out, "MAJOR", parts[0], -1) + out = strings.Replace(out, "MINOR", parts[1], -1) + out = strings.Replace(out, "PATCH", parts[2], -1) + out = strings.Replace(out, "VERSION", version, -1) + + f, _ := os.Create("versioninfo.json") + f.Write([]byte(out)) + f.Close() + +} diff --git a/version/version_test.go b/version/version_test.go index e0f6b70..1cd07ee 100644 --- a/version/version_test.go +++ b/version/version_test.go @@ -13,7 +13,7 @@ func TestVersioningUpdate(t *testing.T) { } func TestVersioningNoUpdate(t *testing.T) { - // pretend there is a new version + // pretend there is not a new version LatestVersion = "v0.12.1" if UpdateAvailable() { t.Error("should NOT be a version newer than " + CurrentVersion)