Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc70e16

Browse files
committed
add gorleaser
1 parent4679e84 commitdc70e16

File tree

4 files changed

+128
-2
lines changed

4 files changed

+128
-2
lines changed

‎.goreleaser.yaml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
before:
2+
hooks:
3+
-go mod tidy
4+
5+
builds:
6+
-env:
7+
-CGO_ENABLED=0
8+
goos:
9+
-darwin
10+
goarch:
11+
-amd64
12+
-arm
13+
-arm64
14+
goarm:
15+
-"5"
16+
-"6"
17+
-"7"
18+
ignore:
19+
-goos:darwin
20+
goarch:arm
21+
-goos:darwin
22+
goarch:ppc64le
23+
-goos:darwin
24+
goarch:s390x
25+
-goos:windows
26+
goarch:ppc64le
27+
-goos:windows
28+
goarch:s390x
29+
-goos:windows
30+
goarch:arm
31+
goarm:"5"
32+
-goos:windows
33+
goarch:arm
34+
goarm:"6"
35+
-goos:windows
36+
goarch:arm
37+
goarm:"7"
38+
-goos:windows
39+
goarch:arm64
40+
-goos:freebsd
41+
goarch:ppc64le
42+
-goos:freebsd
43+
goarch:s390x
44+
-goos:freebsd
45+
goarch:arm
46+
goarm:"5"
47+
-goos:freebsd
48+
goarch:arm
49+
goarm:"6"
50+
-goos:freebsd
51+
goarch:arm
52+
goarm:"7"
53+
-goos:freebsd
54+
goarch:arm64
55+
flags:
56+
--trimpath
57+
ldflags:
58+
--s -w
59+
--X github.com/cage1016/ak/cmd.Version={{.Version}}
60+
--X github.com/cage1016/ak/cmd.Commit={{.ShortCommit}}
61+
binary:>-
62+
{{ .ProjectName }}-
63+
{{- if .IsSnapshot }}{{ .Branch }}-
64+
{{- else }}{{- .Version }}-{{ end }}
65+
{{- .Os }}-
66+
{{- if eq .Arch "amd64" }}amd64
67+
{{- else if eq .Arch "amd64_v1" }}amd64
68+
{{- else if eq .Arch "386" }}386
69+
{{- else }}{{ .Arch }}{{ end }}
70+
{{- if .Arm }}-{{ .Arm }}{{ end }}
71+
no_unique_dist_dir:true
72+
73+
archives:
74+
-format:binary
75+
name_template:"{{ .Binary }}"
76+
allow_different_binary_count:true
77+
78+
checksum:
79+
name_template:'checksums.txt'
80+
81+
snapshot:
82+
name_template:"{{ incpatch .Version }}"

‎Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
GO ?= go
2+
EXECUTABLE := ak
3+
GOFILES :=$(shell find . -type f -name "*.go")
4+
TAGS ?=
5+
LDFLAGS ?= -X 'github.com/cage1016/ak/cmd.Version=$(VERSION)' -X 'github.com/cage1016/ak/cmd.Commit=$(COMMIT)'
6+
7+
ifneq ($(shell uname), Darwin)
8+
EXTLDFLAGS = -extldflags "-static" $(null)
9+
else
10+
EXTLDFLAGS =
11+
endif
12+
13+
ifneq ($(DRONE_TAG),)
14+
VERSION ?= $(DRONE_TAG)
15+
else
16+
VERSION ?= $(shell git describe --tags --always || git rev-parse --short HEAD)
17+
endif
18+
COMMIT ?=$(shell git rev-parse --short HEAD)
19+
120
# Regenerates OPA data from rego files
221
HAVE_GO_BINDATA :=$(shell command -v go-bindata 2> /dev/null)
322
generate:## go generate
@@ -8,6 +27,9 @@ else
827
go generate ./...
928
endif
1029

30+
.PHONY: release
31+
release:## release
32+
goreleaser release --skip-publish --rm-dist
1133

1234
.PHONY: help
1335
help:## this help

‎cmd/root.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*
22
Copyright © 2022 KAI CHU CHUNG <cage.chung@gmail.com>
3-
43
*/
54
package cmd
65

@@ -22,7 +21,6 @@ var rootCmd = &cobra.Command{
2221
Run:func(cmd*cobra.Command,args []string) {
2322
cmd.Help()
2423
},
25-
Version:"0.3.0",
2624
}
2725

2826
// Execute adds all child commands to the root command and sets flags appropriately.

‎cmd/version.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
)
8+
9+
var (
10+
Versionstring=""
11+
Commitstring=""
12+
)
13+
14+
varversionCmd=&cobra.Command{
15+
Use:"version",
16+
Short:"Print the version number",
17+
Run:func(cmd*cobra.Command,args []string) {
18+
fmt.Println("version:",Version,"commit:",Commit)
19+
},
20+
}
21+
22+
funcinit() {
23+
rootCmd.AddCommand(versionCmd)
24+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp