Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: auto versioning with goreleaser #101

Merged
merged 1 commit into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions .github/workflows/release-tag.yaml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: release

on:
push:
tags:
- "v*.*.*"

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: stable
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 changes: 0 additions & 43 deletions .github/workflows/release.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bin/
totp-cli
coverage.out
.idea
.idea
dist/
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ issues:
- text: "sig: func \\(\\*?github.com/yitsushi/totp-cli/"
linters:
- wrapcheck
- path: internal/info
linters:
- gochecknoglobals

linters:
enable-all: true
Expand Down
38 changes: 38 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
version: 1

before:
hooks:
- go mod download

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
ldflags:
- -s -w -X github.com/yitsushi/totp-cli/internal/info.Version={{.Version}} -X github.com/yitsushi/totp-cli/internal/info.Commit={{.Commit}}

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
4 changes: 2 additions & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ func newApplication() *cli.App {
stdErr := os.Stderr

return &cli.App{
Name: info.AppName,
Name: info.Name,
HelpName: "totp-cli",
Usage: "Authy/Google Authenticator like TOTP CLI tool written in Go.",
Version: info.AppVersion,
Version: info.Version,
Commands: []*cli.Command{
cmd.AddTokenCommand(),
cmd.ChangePasswordCommand(),
Expand Down
15 changes: 9 additions & 6 deletions internal/info/app.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package info

// AppRepoOwner defined the owner of the repo on GitHub.
const AppRepoOwner string = "yitsushi"
// RepoOwner defined the owner of the repo on GitHub.
const RepoOwner = "yitsushi"

// AppName defined the application name.
const AppName string = "totp-cli"
// Name defined the application name.
const Name = "totp-cli"

// AppVersion defined current version of this application.
const AppVersion string = "v1.8.5"
// Version defined current version of this application.
var Version = "dev"

// Commit defined commit hash of the current build.
var Commit = "unknown"