Skip to content

Commit

Permalink
config: 配置 goreleaser 工作流设置
Browse files Browse the repository at this point in the history
  • Loading branch information
sinspired committed Nov 15, 2024
1 parent 9eee832 commit 7f5c905
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 77 deletions.
64 changes: 35 additions & 29 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Create Release
# .github/workflows/release.yml
name: build and release

on:
pull_request:
push:
# run only against tags
tags:
- "*"
release:
types: [created]

permissions:
contents: write
packages: write

contents: write
# packages: write
# issues: write
# id-token: write

jobs:
releases:
name: Create Release
goreleaser:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.2'

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release -f .goreleaser.yaml --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
# More assembly might be required: Docker logins, GPG, etc.
# It all depends on your needs.
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ data/output_google_translate_ips.txt
data/output_cloudflare_ips.txt

.idea/
.vscode/
dist/
181 changes: 134 additions & 47 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,73 +1,70 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines bellow are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
# .goreleaser.yaml
version: 2
env:
- GO111MODULE=on

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...

snapshot:
version_template: "{{ incpatch .Version }}-next"

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
dir: ./cmd
id: "ip_scanner"
- main: ./cmd/ip_scanner
id: ip_scanner
binary: ip_scanner
main: ./ip_scanner

env:
- CGO_ENABLED=0
targets:
- windows_amd64
- linux_amd64
- darwin_amd64
- darwin_arm64

- main: ./cmd/cloudflare
id: "cloudflare"
id: cloudflare
binary: cloudflare
goos:
- linux
- darwin
- windows
goarch:
- amd64
env:
- CGO_ENABLED=0
targets:
- windows_amd64
- linux_amd64
- darwin_amd64
- darwin_arm64

- main: ./cmd/fetch_ip_ranges
id: "fetch_ip_ranges"
id: fetch_ip_ranges
binary: fetch_ip_ranges
goos:
- linux
- darwin
- windows
goarch:
- amd64
env:
- CGO_ENABLED=0
targets:
- windows_amd64
- linux_amd64
- darwin_amd64
- darwin_arm64

- main: ./cmd/google_translate
id: "google_translate"
id: google_translate
binary: google_translate
goos:
- linux
- darwin
- windows
goarch:
- amd64
env:
- CGO_ENABLED=0
targets:
- windows_amd64
- linux_amd64
- darwin_amd64
- darwin_arm64

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
Expand All @@ -77,9 +74,99 @@ archives:
- configs/*
- data/*

checksum:
name_template: "checksums.txt"

changelog:
sort: asc
sort: asc # 按提交时间升序排序,最早的提交显示在最前面
use: github
filters:
exclude:
- "^docs:"
- "^test:"
- "^test(:|\\()"
- "merge conflict"
- "Merge (pull request|remote-tracking branch|branch)"
- "go mod tidy"
- "^更新文件"
- "^测试(:|\\()"

groups:
# feat(UI): 新增用户登录界面、新增: 实现用户认证功能。
- title: "New Features" # “新功能”
regexp: '^.*?(feat|功能|新增|feature)(\(.+\))??!?[-:\s].+$'
order: 100 # 排序优先级


# fix: 修复UI组件加载延迟问题
- title: "Bug fixes" # “Bug 修复”
regexp: '^.*?(fix|修复|bug|错误|bugfix)(\(.+\))??!?[-:\s].+$'
order: 200

# sec: 修复 XSS 漏洞,增强安全策略。
- title: "Security updates" # “安全更新”
regexp: '^.*?(sec|安全|漏洞|security)(\(.+\))??!?[-:\s].+$'
order: 300


# deps: 更新依赖库版本,提升稳定性。
- title: "Dependency updates" # “依赖更新”
regexp: '^.*?(deps|依赖|dependency)(\(.+\))??!?[-:\s].+$'
order: 400


# docs: 更新API使用说明,添加示例代码。
- title: "Documentation updates" # “文档更新”
regexp: '^.*?(docs?|文档|说明|documentation|注释)(\(.+\))??!?[-:\s].+$'
order: 500


# i18n: 添加西班牙语翻译,完善国际化支持。
- title: "Translation updates" # “翻译更新”
regexp: '^.*?(i18n|翻译|localization|国际化|本地化)(\(.+\))??!?[-:\s].+$'
order: 600


# optimization: 优化用户登录流程,减少加载时间。
- title: "Code Optimization" # “代码优化”
regexp: '^.*?(optimization|优化|性能|代码|performance|refactor)(\(.+\))??!?[-:\s].+$'
order: 700


# config: 更新环境变量配置文件。
- title: "Config updates" # “配置更新”
regexp: '^.*?(config|配置|configuration)(\(.+\))??!?[-:\s].+$'
order: 800


# ci(build): 添加持续集成任务,自动构建和发布。
- title: "Build process updates" # “构建过程更新”
regexp: '^.*?(build|ci|构建|持续集成)(\(.+\))??!?[-:\s].+$'
order: 900


# test: 增加单元测试用例,覆盖率提升到 85%。
- title: "Test-related changes" # “测试相关变更”
regexp: '^.*?(test|测试|单元测试|集成测试)(\(.+\))??!?[-:\s].+$'
order: 950


# chore: 更新项目文档索引,整理文件结构。
- title: "Other work" # “其他工作”
order: 9999


release:
name_template: "v{{ .Version }} {{.TagSubject}}"

replace_existing_artifacts: true
mode: replace

header: |
**Latest Update:**
> {{.TagContents}}
Released in {{ .CommitDate }}
footer: |
**Full Changelog**: https://github.com/sinspired/ip-scanner/compare/{{ .PreviousTag }}...{{ if .IsNightly }}nightly{{ else }}{{ .Tag }}{{ end }}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (

require (
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
Expand Down

0 comments on commit 7f5c905

Please sign in to comment.