Skip to content

Commit 8e91edd

Browse files
committed
add goreleaser
1 parent 405efe5 commit 8e91edd

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

.github/workflows/release.yml

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

.goreleaser.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
project_name: tp
2+
release:
3+
github:
4+
owner: minefuto
5+
name: tp
6+
env:
7+
- GO111MODULE=on
8+
before:
9+
hooks:
10+
- go mod tidy
11+
builds:
12+
- main: .
13+
binary: tp
14+
ldflags:
15+
- -s -w
16+
- -X main.version={{.Version}}
17+
- -X main.commit={{.ShortCommit}}
18+
env:
19+
- CGO_ENABLED=0
20+
goos:
21+
- linux
22+
- darwin
23+
goarch:
24+
- amd64
25+
changelog:
26+
skip: true
27+
archives:
28+
- files:
29+
- LICENSE*

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ import (
2020
"golang.org/x/text/transform"
2121
)
2222

23-
const (
23+
var (
2424
name = "tp"
2525
version = "0.1.0"
26+
commit = "devel"
2627
)
2728

2829
var (
@@ -479,7 +480,7 @@ func main() {
479480
}
480481

481482
if versionFlag {
482-
fmt.Printf("%s version %s\n", name, version)
483+
fmt.Printf("%s version %s-%s\n", name, version, commit)
483484
os.Exit(0)
484485
}
485486

0 commit comments

Comments
 (0)