Skip to content

Commit 1a63484

Browse files
authored
feat: auto versioning with goreleaser (#101)
That should prevent incidents coming from me forgetting to update the version constant like #100. Closes #38 References: * #100 * #38 Signed-off-by: Victoria Nadasdi <efertone@pm.me>
1 parent 4e07d7d commit 1a63484

File tree

8 files changed

+84
-83
lines changed

8 files changed

+84
-83
lines changed

.github/workflows/release-tag.yaml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- name: Set up Go
20+
uses: actions/setup-go@v4
21+
with:
22+
go-version: stable
23+
- name: Run GoReleaser
24+
uses: goreleaser/goreleaser-action@v5
25+
with:
26+
distribution: goreleaser
27+
version: latest
28+
args: release --clean
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
bin/
22
totp-cli
33
coverage.out
4-
.idea
4+
.idea
5+
dist/

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ issues:
6363
- text: "sig: func \\(\\*?github.com/yitsushi/totp-cli/"
6464
linters:
6565
- wrapcheck
66+
- path: internal/info
67+
linters:
68+
- gochecknoglobals
6669

6770
linters:
6871
enable-all: true

.goreleaser.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
2+
version: 1
3+
4+
before:
5+
hooks:
6+
- go mod download
7+
8+
builds:
9+
- env:
10+
- CGO_ENABLED=0
11+
goos:
12+
- linux
13+
- windows
14+
- darwin
15+
ldflags:
16+
- -s -w -X github.com/yitsushi/totp-cli/internal/info.Version={{.Version}} -X github.com/yitsushi/totp-cli/internal/info.Commit={{.Commit}}
17+
18+
archives:
19+
- format: tar.gz
20+
# this name template makes the OS and Arch compatible with the results of `uname`.
21+
name_template: >-
22+
{{ .ProjectName }}_
23+
{{- title .Os }}_
24+
{{- if eq .Arch "amd64" }}x86_64
25+
{{- else if eq .Arch "386" }}i386
26+
{{- else }}{{ .Arch }}{{ end }}
27+
{{- if .Arm }}v{{ .Arm }}{{ end }}
28+
# use zip for windows archives
29+
format_overrides:
30+
- goos: windows
31+
format: zip
32+
33+
changelog:
34+
sort: asc
35+
filters:
36+
exclude:
37+
- "^docs:"
38+
- "^test:"

app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ func newApplication() *cli.App {
1414
stdErr := os.Stderr
1515

1616
return &cli.App{
17-
Name: info.AppName,
17+
Name: info.Name,
1818
HelpName: "totp-cli",
1919
Usage: "Authy/Google Authenticator like TOTP CLI tool written in Go.",
20-
Version: info.AppVersion,
20+
Version: info.Version,
2121
Commands: []*cli.Command{
2222
cmd.AddTokenCommand(),
2323
cmd.ChangePasswordCommand(),

internal/info/app.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package info
22

3-
// AppRepoOwner defined the owner of the repo on GitHub.
4-
const AppRepoOwner string = "yitsushi"
3+
// RepoOwner defined the owner of the repo on GitHub.
4+
const RepoOwner = "yitsushi"
55

6-
// AppName defined the application name.
7-
const AppName string = "totp-cli"
6+
// Name defined the application name.
7+
const Name = "totp-cli"
88

9-
// AppVersion defined current version of this application.
10-
const AppVersion string = "v1.8.5"
9+
// Version defined current version of this application.
10+
var Version = "dev"
11+
12+
// Commit defined commit hash of the current build.
13+
var Commit = "unknown"

0 commit comments

Comments
 (0)