diff --git a/.gitignore b/.gitignore index d02ff6b..819dc73 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ gropple +dist +release diff --git a/build_release.pl b/build_release.pl new file mode 100755 index 0000000..6812b6b --- /dev/null +++ b/build_release.pl @@ -0,0 +1,39 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +open my $fh, "<", "main.go" || die $!; + +my $version; +while (<$fh>) { + $version = $1 if /^const\s+currentVersion.*?"(v[\d\.]+)"/; +} +close $fh; + +die "no version?" unless defined $version; + +# quit if tests fail +system("go test ./...") && die "not building release with failing tests"; + +# so lazy +system "rm", "-rf", "release", "dist"; +system "mkdir", "release"; +system "mkdir", "dist"; + +my %build = ( + win => { env => { GOOS => 'windows', GOARCH => 'amd64' }, filename => 'gropple.exe' }, + linux => { env => { GOOS => 'linux', GOARCH => 'amd64' }, filename => 'gropple' }, + mac => { env => { GOOS => 'darwin', GOARCH => 'amd64' }, filename => 'gropple' }, +); + +foreach my $type (keys %build) { + mkdir "release/$type"; +} + +foreach my $type (keys %build) { + local $ENV{GOOS} = $build{$type}->{env}->{GOOS}; + local $ENV{GOARCH} = $build{$type}->{env}->{GOARCH}; + system "go", "build", "-o", "release/$type/" . $build{$type}->{filename}; + system "zip", "-j", "dist/gropple-$type-$version.zip", ( glob "release/$type/*" ); +} diff --git a/main.go b/main.go index 051c3ec..595d3bf 100644 --- a/main.go +++ b/main.go @@ -39,6 +39,8 @@ var downloadPath = "./" var address string +const currentVersion = "v0.01" + //go:embed web var webFS embed.FS @@ -64,7 +66,7 @@ func main() { ReadTimeout: 5 * time.Second, } - log.Print("starting web service") + log.Printf("starting gropple %s - https://github.com/tardisx/gropple", currentVersion) log.Printf("go to %s for details on installing the bookmarklet and to check status", address) log.Fatal(srv.ListenAndServe())