diff --git a/.gitignore b/.gitignore index f4c8532..4ac12e9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ discord-auto-upload.exe *.png *.jpg .DS_Store +versioninfo.json \ No newline at end of file diff --git a/build-release.pl b/build-release.pl index 95607e7..d5eaa5d 100755 --- a/build-release.pl +++ b/build-release.pl @@ -2,17 +2,27 @@ use strict; use warnings; +use Mojo::JSON qw/encode_json decode_json/; +use Mojo::File; open my $fh, "<", "version/version.go" || die $!; my $version; while (<$fh>) { - $version = $1 if /^const\s+CurrentVersion.*?"(v[\d\.]+)"/; + $version = $1 if /^const\s+CurrentVersion.*?"v([\d\.]+)"/; } close $fh; - die "no version?" unless defined $version; +my @version_parts = split /\./, $version; +die "bad version?" unless defined $version_parts[2]; + +foreach (@version_parts) { + $_ = 0 + $_; +} + +$version = "v$version"; + # quit if tests fail system("go test ./...") && die "not building release with failing tests"; @@ -42,6 +52,20 @@ foreach my $type (keys %build) { my @ldflags = (); if ($type eq "win") { + # create the versioninfo.json based on the current version + my $tmp = Mojo::File->new("versioninfo.json-template")->slurp(); + my $vdata = decode_json($tmp); + $vdata->{FixedFileInfo}->{FileVersion}->{Major} = $version_parts[0] ; + $vdata->{FixedFileInfo}->{FileVersion}->{Minor} = $version_parts[1] ; + $vdata->{FixedFileInfo}->{FileVersion}->{Patch} = $version_parts[2] ; + $vdata->{FixedFileInfo}->{ProductVersion}->{Major} = $version_parts[0] ; + $vdata->{FixedFileInfo}->{ProductVersion}->{Minor} = $version_parts[1] ; + $vdata->{FixedFileInfo}->{ProductVersion}->{Patch} = $version_parts[2] ; + + $vdata->{StringFileInfo}->{ProductVersion} = $version; + + Mojo::File->new("versioninfo.json")->spurt(encode_json($vdata)); + @ldflags = (qw/ -ldflags -H=windowsgui/); system "go", "generate"; } diff --git a/dau_windows.go b/dau_windows.go index a1eacda..29d4510 100644 --- a/dau_windows.go +++ b/dau_windows.go @@ -13,7 +13,7 @@ import ( //go:embed dau.ico var appIcon []byte -//go:generate goversioninfo -icon=dau.ico +//go:generate goversioninfo // -manifest=testdata/resource/goversioninfo.exe.manifest diff --git a/versioninfo.json b/versioninfo.json-template similarity index 69% rename from versioninfo.json rename to versioninfo.json-template index 7f5b906..fc6cb64 100644 --- a/versioninfo.json +++ b/versioninfo.json-template @@ -1,13 +1,13 @@ { "FixedFileInfo": { "FileVersion": { - "Major": 1, + "Major": 0, "Minor": 0, "Patch": 0, "Build": 0 }, "ProductVersion": { - "Major": 1, + "Major": 0, "Minor": 0, "Patch": 0, "Build": 0 @@ -20,16 +20,16 @@ }, "StringFileInfo": { "Comments": "", - "CompanyName": "", - "FileDescription": "", + "CompanyName": "tardisx@github", + "FileDescription": "https://github.com/tardisx/discord-auto-upload", "FileVersion": "", "InternalName": "", - "LegalCopyright": "", + "LegalCopyright": "https://github.com/tardisx/discord-auto-upload/blob/master/LICENSE", "LegalTrademarks": "", "OriginalFilename": "", "PrivateBuild": "", - "ProductName": "", - "ProductVersion": "v1.0.0.0", + "ProductName": "discord-auto-upload", + "ProductVersion": "v0.0.0", "SpecialBuild": "" }, "VarFileInfo": {