Skip to content

Commit 7f5c905

Browse files
committed
config: 配置 goreleaser 工作流设置
1 parent 9eee832 commit 7f5c905

5 files changed

Lines changed: 173 additions & 77 deletions

File tree

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,44 @@
1-
# This workflow will build a golang project
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3-
4-
name: Create Release
1+
# .github/workflows/release.yml
2+
name: build and release
53

64
on:
5+
pull_request:
6+
push:
7+
# run only against tags
8+
tags:
9+
- "*"
710
release:
811
types: [created]
912

1013
permissions:
11-
contents: write
12-
packages: write
13-
14+
contents: write
15+
# packages: write
16+
# issues: write
17+
# id-token: write
18+
1419
jobs:
15-
releases:
16-
name: Create Release
20+
goreleaser:
1721
runs-on: ubuntu-latest
18-
strategy:
19-
matrix:
20-
goos: [linux, windows, darwin]
21-
goarch: [amd64]
2222
steps:
23-
- name: Checkout
24-
uses: actions/checkout@v3
25-
26-
- name: Set up Go
27-
uses: actions/setup-go@v4
28-
with:
29-
go-version: '1.21.2'
30-
31-
- name: Run GoReleaser
32-
uses: goreleaser/goreleaser-action@v5
33-
with:
34-
distribution: goreleaser
35-
version: latest
36-
args: release -f .goreleaser.yaml --clean
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
- name: Set up Go
28+
uses: actions/setup-go@v5
29+
with:
30+
go-version: stable
31+
# More assembly might be required: Docker logins, GPG, etc.
32+
# It all depends on your needs.
33+
- name: Run GoReleaser
34+
uses: goreleaser/goreleaser-action@v6
35+
with:
36+
# either 'goreleaser' (default) or 'goreleaser-pro'
37+
distribution: goreleaser
38+
# 'latest', 'nightly', or a semver
39+
version: "~> v2"
40+
args: release --clean
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
44+
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ data/output_google_translate_ips.txt
2525
data/output_cloudflare_ips.txt
2626

2727
.idea/
28+
.vscode/
2829
dist/

.goreleaser.yaml

Lines changed: 134 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,70 @@
1-
# This is an example .goreleaser.yml file with some sensible defaults.
2-
# Make sure to check the documentation at https://goreleaser.com
3-
4-
# The lines bellow are called `modelines`. See `:help modeline`
5-
# Feel free to remove those if you don't want/need to use them.
6-
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
7-
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
1+
# .goreleaser.yaml
2+
version: 2
3+
env:
4+
- GO111MODULE=on
85

96
before:
107
hooks:
11-
# You may remove this if you don't use go modules.
128
- go mod tidy
13-
# you may remove this if you don't need go generate
149
- go generate ./...
1510

11+
snapshot:
12+
version_template: "{{ incpatch .Version }}-next"
13+
1614
builds:
17-
- env:
18-
- CGO_ENABLED=0
19-
goos:
20-
- linux
21-
- darwin
22-
- windows
23-
goarch:
24-
- amd64
25-
dir: ./cmd
26-
id: "ip_scanner"
15+
- main: ./cmd/ip_scanner
16+
id: ip_scanner
2717
binary: ip_scanner
28-
main: ./ip_scanner
29-
18+
env:
19+
- CGO_ENABLED=0
20+
targets:
21+
- windows_amd64
22+
- linux_amd64
23+
- darwin_amd64
24+
- darwin_arm64
25+
3026
- main: ./cmd/cloudflare
31-
id: "cloudflare"
27+
id: cloudflare
3228
binary: cloudflare
33-
goos:
34-
- linux
35-
- darwin
36-
- windows
37-
goarch:
38-
- amd64
29+
env:
30+
- CGO_ENABLED=0
31+
targets:
32+
- windows_amd64
33+
- linux_amd64
34+
- darwin_amd64
35+
- darwin_arm64
3936

4037
- main: ./cmd/fetch_ip_ranges
41-
id: "fetch_ip_ranges"
38+
id: fetch_ip_ranges
4239
binary: fetch_ip_ranges
43-
goos:
44-
- linux
45-
- darwin
46-
- windows
47-
goarch:
48-
- amd64
40+
env:
41+
- CGO_ENABLED=0
42+
targets:
43+
- windows_amd64
44+
- linux_amd64
45+
- darwin_amd64
46+
- darwin_arm64
4947

5048
- main: ./cmd/google_translate
51-
id: "google_translate"
49+
id: google_translate
5250
binary: google_translate
53-
goos:
54-
- linux
55-
- darwin
56-
- windows
57-
goarch:
58-
- amd64
51+
env:
52+
- CGO_ENABLED=0
53+
targets:
54+
- windows_amd64
55+
- linux_amd64
56+
- darwin_amd64
57+
- darwin_arm64
5958

6059
archives:
6160
- format: tar.gz
62-
# this name template makes the OS and Arch compatible with the results of `uname`.
6361
name_template: >-
6462
{{ .ProjectName }}_
6563
{{- title .Os }}_
6664
{{- if eq .Arch "amd64" }}x86_64
6765
{{- else if eq .Arch "386" }}i386
6866
{{- else }}{{ .Arch }}{{ end }}
6967
{{- if .Arm }}v{{ .Arm }}{{ end }}
70-
# use zip for windows archives
7168
format_overrides:
7269
- goos: windows
7370
format: zip
@@ -77,9 +74,99 @@ archives:
7774
- configs/*
7875
- data/*
7976

77+
checksum:
78+
name_template: "checksums.txt"
79+
8080
changelog:
81-
sort: asc
81+
sort: asc # 按提交时间升序排序,最早的提交显示在最前面
82+
use: github
8283
filters:
8384
exclude:
84-
- "^docs:"
85-
- "^test:"
85+
- "^test(:|\\()"
86+
- "merge conflict"
87+
- "Merge (pull request|remote-tracking branch|branch)"
88+
- "go mod tidy"
89+
- "^更新文件"
90+
- "^测试(:|\\()"
91+
92+
groups:
93+
# feat(UI): 新增用户登录界面、新增: 实现用户认证功能。
94+
- title: "New Features" # “新功能”
95+
regexp: '^.*?(feat|功能|新增|feature)(\(.+\))??!?[-:\s].+$'
96+
order: 100 # 排序优先级
97+
98+
99+
# fix: 修复UI组件加载延迟问题
100+
- title: "Bug fixes" # “Bug 修复”
101+
regexp: '^.*?(fix|修复|bug|错误|bugfix)(\(.+\))??!?[-:\s].+$'
102+
order: 200
103+
104+
# sec: 修复 XSS 漏洞,增强安全策略。
105+
- title: "Security updates" # “安全更新”
106+
regexp: '^.*?(sec|安全|漏洞|security)(\(.+\))??!?[-:\s].+$'
107+
order: 300
108+
109+
110+
# deps: 更新依赖库版本,提升稳定性。
111+
- title: "Dependency updates" # “依赖更新”
112+
regexp: '^.*?(deps|依赖|dependency)(\(.+\))??!?[-:\s].+$'
113+
order: 400
114+
115+
116+
# docs: 更新API使用说明,添加示例代码。
117+
- title: "Documentation updates" # “文档更新”
118+
regexp: '^.*?(docs?|文档|说明|documentation|注释)(\(.+\))??!?[-:\s].+$'
119+
order: 500
120+
121+
122+
# i18n: 添加西班牙语翻译,完善国际化支持。
123+
- title: "Translation updates" # “翻译更新”
124+
regexp: '^.*?(i18n|翻译|localization|国际化|本地化)(\(.+\))??!?[-:\s].+$'
125+
order: 600
126+
127+
128+
# optimization: 优化用户登录流程,减少加载时间。
129+
- title: "Code Optimization" # “代码优化”
130+
regexp: '^.*?(optimization|优化|性能|代码|performance|refactor)(\(.+\))??!?[-:\s].+$'
131+
order: 700
132+
133+
134+
# config: 更新环境变量配置文件。
135+
- title: "Config updates" # “配置更新”
136+
regexp: '^.*?(config|配置|configuration)(\(.+\))??!?[-:\s].+$'
137+
order: 800
138+
139+
140+
# ci(build): 添加持续集成任务,自动构建和发布。
141+
- title: "Build process updates" # “构建过程更新”
142+
regexp: '^.*?(build|ci|构建|持续集成)(\(.+\))??!?[-:\s].+$'
143+
order: 900
144+
145+
146+
# test: 增加单元测试用例,覆盖率提升到 85%。
147+
- title: "Test-related changes" # “测试相关变更”
148+
regexp: '^.*?(test|测试|单元测试|集成测试)(\(.+\))??!?[-:\s].+$'
149+
order: 950
150+
151+
152+
# chore: 更新项目文档索引,整理文件结构。
153+
- title: "Other work" # “其他工作”
154+
order: 9999
155+
156+
157+
release:
158+
name_template: "v{{ .Version }} {{.TagSubject}}"
159+
160+
replace_existing_artifacts: true
161+
mode: replace
162+
163+
header: |
164+
165+
**Latest Update:**
166+
167+
> {{.TagContents}}
168+
169+
Released in {{ .CommitDate }}
170+
171+
footer: |
172+
**Full Changelog**: https://github.com/sinspired/ip-scanner/compare/{{ .PreviousTag }}...{{ if .IsNightly }}nightly{{ else }}{{ .Tag }}{{ end }}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99

1010
require (
1111
github.com/fsnotify/fsnotify v1.6.0 // indirect
12+
github.com/google/go-cmp v0.6.0 // indirect
1213
github.com/hashicorp/hcl v1.0.0 // indirect
1314
github.com/magiconair/properties v1.8.7 // indirect
1415
github.com/mitchellh/mapstructure v1.5.0 // indirect

go.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
9797
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
9898
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
9999
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
100-
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
100+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
101+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
101102
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
102103
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
103104
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=

0 commit comments

Comments
 (0)