ci: integrate GoReleaser for streamlined release management

- Rename job from `release` to `goreleaser` in `release-tag.yml`
- Change the tag pattern from `' * '` to `" * "` in `release-tag.yml`
- Update job steps to better describe their actions in `release-tag.yml`
- Replace build steps with GoReleaser action steps in `release-tag.yml`
- Add configuration file `.goreleaser.yaml` for GoReleaser
- Include hooks, builds, archives, changelog sorting, and release footer in `.goreleaser.yaml`

Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
appleboy
2025-04-08 21:33:57 +08:00
parent f1b4a208a7
commit 6993bb2b5d
2 changed files with 82 additions and 25 deletions

View File

@@ -1,41 +1,32 @@
name: release name: release
on: on:
push: push:
tags: tags:
- '*' - "*"
jobs: jobs:
release: goreleaser:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - name: Checkout
uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: setup go - name: Set up Go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version-file: 'go.mod' go-version: stable
- name: release-build - name: Run GoReleaser
run: go build -ldflags="-s -w -X 'main.Version=${{ gitea.ref_name }}'" -o bin/mcp-gitea-${{ gitea.ref_name }}-linux-amd64 uses: goreleaser/goreleaser-action@v6
- name: release-build-windows
run: GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X 'main.Version=${{ gitea.ref_name }}'" -o bin/mcp-gitea-${{ gitea.ref_name }}-windows-amd64.exe
- name: release-build-darwin
run: GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X 'main.Version=${{ gitea.ref_name }}'" -o bin/mcp-gitea-${{ gitea.ref_name }}-darwin-amd64
- name: release-build-arm64
run: GOARCH=arm64 go build -ldflags="-s -w -X 'main.Version=${{ gitea.ref_name }}'" -o bin/mcp-gitea-${{ gitea.ref_name }}-linux-arm64
- name: release-build-windows-arm64
run: GOOS=windows GOARCH=arm64 go build -ldflags="-s -w -X 'main.Version=${{ gitea.ref_name }}'" -o bin/mcp-gitea-${{ gitea.ref_name }}-windows-arm64.exe
- name: release-build-darwin-arm64
run: GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X 'main.Version=${{ gitea.ref_name }}'" -o bin/mcp-gitea-${{ gitea.ref_name }}-darwin-arm64
- name: Use Go Action
id: use-go-action
uses: https://gitea.com/actions/gitea-release-action@main
with: with:
files: |- distribution: goreleaser
bin/** # 'latest', 'nightly', or a semver
token: '${{secrets.RELEASE_TOKEN}}' version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-image: release-image:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:

66
.goreleaser.yaml Normal file
View File

@@ -0,0 +1,66 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
version: 2
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
main: .
goos:
- linux
- windows
- darwin
archives:
- formats: 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
formats: zip
changelog:
sort: asc
groups:
- title: Features
regexp: "^.*feat[(\\w)]*:+.*$"
order: 0
- title: "Bug fixes"
regexp: "^.*fix[(\\w)]*:+.*$"
order: 1
- title: "Enhancements"
regexp: "^.*chore[(\\w)]*:+.*$"
order: 2
- title: "Refactor"
regexp: "^.*refactor[(\\w)]*:+.*$"
order: 3
- title: "Build process updates"
regexp: ^.*?(build|ci)(\(.+\))??!?:.+$
order: 4
- title: "Documentation updates"
regexp: ^.*?docs?(\(.+\))??!?:.+$
order: 4
- title: Others
order: 999
filters:
exclude:
- "^docs:"
- "^test:"
release:
footer: >-
---
Released by [GoReleaser](https://github.com/goreleaser/goreleaser).