From 5fa17a67581ae4af6f42dfa31a225a6d8fa851a3 Mon Sep 17 00:00:00 2001 From: Takumasa Sakao Date: Thu, 1 Jul 2021 00:20:50 +0900 Subject: [PATCH] Add release flow --- .github/workflows/release.yml | 26 ++++++++++++++++++++++ .goreleaser.yml | 42 +++++++++++++++++++++++++++++++++++ main.go | 7 +++++- version.go | 4 ---- 4 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml delete mode 100644 version.go diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..602371f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: Release + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Unshallow + run: git fetch --prune --unshallow + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.16.x + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v1 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.COMMITTER_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..14bfd13 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,42 @@ +before: + hooks: + - go mod download +builds: +- env: + - CGO_ENABLED=0 + binary: toggl + goos: + - darwin + - linux + - windows + goarch: + - amd64 + ldflags: + - -s -w -X github.com/sachaos/toggl.version={{.Version}} +archives: +- replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' +brews: +- tap: + owner: sachaos + name: homebrew-tap + folder: Formula + homepage: https://github.com/sachaos/toggl + description: Toggl CLI client + skip_upload: auto + test: | + system "#{bin}/toggl", "--version" diff --git a/main.go b/main.go index b9faf19..ca2b0bc 100644 --- a/main.go +++ b/main.go @@ -24,6 +24,11 @@ const ( ConfigType = "json" ) + +const Name string = "toggl" + +var version string + func main() { cache.New(os.Getenv("HOME") + "/.toggl.cache.json") cache.Init() @@ -34,7 +39,7 @@ func main() { app := cli.NewApp() app.Name = Name - app.Version = Version + app.Version = version app.Author = "sachaos" app.Email = "sakataku7@gmail.com" app.Usage = "Toggl API CLI Client" diff --git a/version.go b/version.go deleted file mode 100644 index ae4d9cb..0000000 --- a/version.go +++ /dev/null @@ -1,4 +0,0 @@ -package main - -const Name string = "toggl" -const Version string = "0.4.0"