Goreleaser: 快速創建 Golang 項目發佈頁面
原文鏈接: https://typonotes.com/posts/2025/05/19/goreleaser-release-app-in-github/
項目可以通過 renovate-bot 進行以來變更管理, 當依賴內容變化後, 可以幫助我們創建 PR。
https://github.com/tangxin/k8s-image-syncer/pulls
goreleaser 可以爲 go 項目快速發佈 Release 頁面。 這對管理項目變更非常重要。 尤其是對於 go library 的依賴而言, 尤爲重要。 當創建 PR 的時候, 可以攜帶所依賴庫的 ChangeLog 內容, 幫助我們快速瞭解依賴的變化內容。
Goreleaser
Goreleaser[1] 是一款專門針對 Go 語言的 編譯、發佈管理工具。 採用 開源(功能限制) + 專業版 的收費模式。
- 執行命令後, 會在本地生成一個
.goreleaser.yaml的配置文件
goreleaser init
- 配置管理
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
# The lines below 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
version:2
builds:
-skip:true# library package, 沒有 main.go, 不需要編譯
changelog:
sort:asc
filters:
exclude:
-"^docs:"
-"^test:"
release:
footer:>-
---
Releasedby[GoReleaser](https://github.com/goreleaser/goreleaser).
- 發佈 GitHub Release 內容
當所有變更都提交、 打完 tag 後。 可以運行以下命令發佈
export GITHUB_TOKEN=xxxx
goreleaser release
Github Action 自動發佈
如果需要 Github Action 自動發佈, 則需要配置 .github/workflows/goreleaser_action.yml 如下。
name: Goreleaser
on:
push:
tags:
-"v*"
permissions:
contents:write
jobs:
goreleaser:
runs-on:ubuntu-latest
steps:
-name:Checkoutrepository
uses:actions/checkout@v4
with:
fetch-depth:0
-name:Setupgo
uses:actions/setup-go@v5
with:
go-version-file:go.mod
check-latest:true
-name:RunGoReleaser
uses:goreleaser/goreleaser-action@v6
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution:goreleaser
version:latest
args:release--clean
env:
GITHUB_TOKEN:${{secrets.ACTION_GITHUB_TOKEN}}
參考資料
[1]
Goreleaser: https://goreleaser.com/intro/
本文由 Readfog 進行 AMP 轉碼,版權歸原作者所有。
來源:https://mp.weixin.qq.com/s/qfCloVjmyX6HK2v9GFNDAA