Skip to content

Commit

Permalink
Switch to goreleaser for release purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
sibprogrammer committed Jun 11, 2021
1 parent 466cb9c commit 3304da9
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 27 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.vscode
/plesk
/.plesk
/plesk.exe
/build/*/plesk*
/build/*.tgz
/dist/
27 changes: 27 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
project_name: plesk
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}}
archives:
- name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}"
replacements:
darwin: mac
linux: linux
windows: win
amd64: x86_64
format: tgz
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}"
20 changes: 7 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
# Copyright 1999-2021. Plesk International GmbH.

OUTFILE=plesk
REVISON:=$(shell git rev-parse --short HEAD)
VERSION:=$(shell cat VERSION)
BUILD_TIME=$(shell date +'%Y-%m-%d_%T')
LDFLAGS=-X main.revision=$(REVISON) -X main.buildTime=$(BUILD_TIME) -X main.version=$(VERSION)
RELEASE_LDFLAGS=$(LDFLAGS) -s -w
COMMIT:=$(shell git rev-parse --short HEAD)
VERSION:=$(shell git describe --abbrev=0 --tags)
DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
LDFLAGS=-X main.commit=$(COMMIT) -X main.date=$(DATE) -X main.version=$(VERSION)

.PHONY: all build clean test

build: test
go build -ldflags "$(LDFLAGS)"

release: test
GOOS=linux go build -ldflags "$(RELEASE_LDFLAGS)" -o ./build/linux/$(OUTFILE)
tar czf ./build/$(OUTFILE)-v$(VERSION)-linux.tgz --directory=build/linux $(OUTFILE)
GOOS=darwin go build -ldflags "$(RELEASE_LDFLAGS)" -o ./build/mac/$(OUTFILE)
tar czf ./build/$(OUTFILE)-v$(VERSION)-mac.tgz --directory=build/mac $(OUTFILE)
GOOS=windows go build -ldflags "$(RELEASE_LDFLAGS)" -o ./build/win/$(OUTFILE).exe
tar czf ./build/$(OUTFILE)-v$(VERSION)-win.tgz --directory=build/win $(OUTFILE).exe
goreleaser release

run:
go run main.go

clean:
$(RM) $(OUTFILE) ./build/*/$(OUTFILE) ./build/*.tgz
$(RM) $(OUTFILE)

test:
go test -v -cover ./...

all: clean release build
all: clean release build
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

Empty file removed build/linux/.keep
Empty file.
Empty file removed build/mac/.keep
Empty file.
Empty file removed build/win/.keep
Empty file.
4 changes: 2 additions & 2 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

// Version information
var (
Revision string
Commit string
BuildTime string
Version string
)
Expand All @@ -22,7 +22,7 @@ var versionCmd = &cobra.Command{
Short: locales.L.Get("version.description"),
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("Client information")
fmt.Printf("Version:\t%s\nRevision:\t%s\nBuild time:\t%s\n", Version, Revision, BuildTime)
fmt.Printf("Version:\t%s\nRevision:\t%s\nBuild time:\t%s\n", Version, Commit, BuildTime)

defaultServerName, err := config.DefaultServer()
if err == nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/jlaffaye/ftp v0.0.0-20210307004419-5d4190119067
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4
github.com/spf13/cobra v1.1.3
github.com/stretchr/testify v1.7.0 // indirect
github.com/stretchr/testify v1.7.0
golang.org/x/net v0.0.0-20210505214959-0714010a04ed // indirect
golang.org/x/sys v0.0.0-20210503173754-0981d6026fa6 // indirect
golang.org/x/term v0.0.0-20210503060354-a79de5458b56
Expand Down
4 changes: 3 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
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 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
Expand Down Expand Up @@ -166,7 +168,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
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=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down Expand Up @@ -296,6 +297,7 @@ google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiq
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
Expand Down
12 changes: 6 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import (
)

var (
revision string
buildTime string
version string
commit string
date string
version string
)

func init() {
cmd.Revision = revision
cmd.BuildTime = buildTime
cmd.Version = version
cmd.Commit = commit
cmd.BuildTime = date
cmd.Version = version[1:]
}

func main() {
Expand Down

0 comments on commit 3304da9

Please sign in to comment.