diff --git a/.github/workflows/release-tag.yaml b/.github/workflows/release-tag.yaml deleted file mode 100644 index b486c55..0000000 --- a/.github/workflows/release-tag.yaml +++ /dev/null @@ -1,31 +0,0 @@ -name: release tag - -on: - push: - tags: - - "v*.*.*" - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Generate release notes - run: | - release_notes=$(gh api repos/{owner}/{repo}/releases/generate-notes -F tag_name=${{ github.ref }} --jq .body) - echo 'RELEASE_NOTES<> $GITHUB_ENV - echo "${release_notes}" >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OWNER: ${{ github.repository_owner }} - REPO: ${{ github.event.repository.name }} - - name: Release - uses: softprops/action-gh-release@v1 - with: - prerelease: false - draft: true - body: ${{ env.RELEASE_NOTES }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..d006c5e --- /dev/null +++ b/.github/workflows/release.yaml @@ -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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 80f0baa..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,43 +0,0 @@ -on: - release: - types: [created, published] - workflow_dispatch: - -name: Release -jobs: - linux: - name: Release linux/amd64 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: release linux/amd64 - uses: wangyoucao577/go-release-action@v1.40 - with: - github_token: ${{ secrets.github_token }} - goarch: amd64 - goos: linux - ldflags: "-s -w" - windows: - name: Release windows/amd64 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: release windows/amd64 - uses: wangyoucao577/go-release-action@v1.40 - with: - github_token: ${{ secrets.github_token }} - goarch: amd64 - goos: windows - ldflags: "-s -w" - darwin: - name: Release darwin/amd64 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: release darwin/amd64 - uses: wangyoucao577/go-release-action@v1.40 - with: - github_token: ${{ secrets.github_token }} - goarch: amd64 - goos: darwin - ldflags: "-s -w" diff --git a/.gitignore b/.gitignore index 4a78e4f..1923f0c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ bin/ totp-cli coverage.out -.idea \ No newline at end of file +.idea +dist/ diff --git a/.golangci.yml b/.golangci.yml index 03b3dd8..89c9259 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -63,6 +63,9 @@ issues: - text: "sig: func \\(\\*?github.com/yitsushi/totp-cli/" linters: - wrapcheck + - path: internal/info + linters: + - gochecknoglobals linters: enable-all: true diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..5bdfaca --- /dev/null +++ b/.goreleaser.yaml @@ -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:" diff --git a/app.go b/app.go index 71c6415..dd0b651 100644 --- a/app.go +++ b/app.go @@ -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(), diff --git a/internal/info/app.go b/internal/info/app.go index 4990033..7e20c16 100644 --- a/internal/info/app.go +++ b/internal/info/app.go @@ -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"