Skip to content

Commit b26fde4

Browse files
committed
chore: 添加自动编译脚本
1 parent a949852 commit b26fde4

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

.github/workflows/goreleaser.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v5
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v6
22+
with:
23+
go-version-file: "go.mod"
24+
cache: true
25+
26+
- name: Run GoReleaser
27+
uses: goreleaser/goreleaser-action@v6
28+
with:
29+
distribution: goreleaser
30+
version: latest
31+
args: release --clean
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
version: 2
2+
3+
before:
4+
hooks:
5+
- go mod tidy
6+
7+
builds:
8+
- id: "gotty" # 内部标识符
9+
binary: "gotty" # 决定了生成的文件名是 gotty (Windows 下自动加 .exe)
10+
env:
11+
- CGO_ENABLED=0
12+
main: .
13+
goos:
14+
- linux
15+
- windows
16+
- darwin
17+
goarch:
18+
- amd64
19+
- arm64
20+
ldflags:
21+
- -s -w
22+
- -X 'gotty/version.version={{.Version}}'
23+
- -X 'gotty/version.buildTime={{.Date}}'
24+
flags:
25+
- -trimpath
26+
27+
archives:
28+
- formats: ["zip"]
29+
name_template: >-
30+
{{ .ProjectName }}_
31+
{{- .Version }}_
32+
{{- title .Os }}_
33+
{{- if eq .Arch "amd64" }}x86_64
34+
{{- else if eq .Arch "386" }}i386
35+
{{- else }}{{ .Arch }}{{ end }}
36+
{{- if .Arm }}v{{ .Arm }}{{ end }}
37+
38+
release:
39+
github:
40+
41+
checksum:
42+
name_template: "checksums.txt"
43+
44+
changelog:
45+
sort: asc
46+
filters:
47+
exclude:
48+
- "^docs:"
49+
- "^test:"

0 commit comments

Comments
 (0)