Skip to content

Commit

Permalink
Adopt goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
waynezhang committed Jul 29, 2022
1 parent 7a09e50 commit 0ff0fc8
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
go-version: 1.18

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
40 changes: 40 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
project_name: foto
env:
- GO111MODULE=on
before:
hooks:
- go mod tidy
builds:
- main: .
binary: foto
ldflags:
- -s -w
- -X github.com/waynezhang/foto/internal/cmd.Version={{.Version}}
- -X github.com/waynezhang/foto/internal/cmd.Revision={{.ShortCommit}}
env:
- CGO_ENABLED=0
archives:
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
replacements:
darwin: darwin
linux: linux
windows: windows
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip
brews:
- tap:
owner: waynezhang
name: homebrew-tap
commit_author:
name: waynezhang
email: [email protected]
homepage: "https://github.com/waynezhang/foto"
description: "Yet another another publishing tool for minimalist photographers."
license: "MIT License"
skip_upload: auto

release:
prerelease: auto
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
OUTPUT_PATH=bin
BINARY=foto

VERSION=1.0.3
VERSION=`git tag | tr -d "v"`
BUILD_TIME=`date +%Y%m%d%H%M`

LDFLAGS=-ldflags "-X github.com/waynezhang/foto/internal/cmd.Version=${VERSION} -X github.com/waynezhang/foto/internal/cmd.BuildTime=${BUILD_TIME}"
LDFLAGS=-ldflags "-X github.com/waynezhang/foto/internal/cmd.Version=${VERSION} -X github.com/waynezhang/foto/internal/cmd.Revision=${BUILD_TIME}"

all: build

Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
)

var Version = ""
var BuildTime = ""
var Revision = ""

var VersionCmd = &cobra.Command {
Use: "version",
Short: "Print the version",
Run: func(cmd *cobra.Command, args []string) {
log.Println("foto v%s+%s", Version, BuildTime)
log.Println("foto v%s+%s", Version, Revision)
},
}

0 comments on commit 0ff0fc8

Please sign in to comment.