Browse Source

chore: update GoReleaser configuration and enhance auto-tag workflow

- Upgraded GoReleaser configuration to version 2, adding build verification and improved release settings.
- Replaced 'go mod download' with 'go mod vendor' and 'go mod verify' for better dependency management.
- Introduced additional build information such as version, commit, and date in the build flags.
- Enhanced the auto-tag workflow by adding a step to prepare the build environment and sync the vendor directory.
- Improved release notes formatting with a header and footer for better clarity in changelogs.
pull/122/head v0.0.27
煎饼果子卷鲨鱼辣椒 5 months ago
parent
commit
8f40c70504
  1. 32
      .github/workflows/auto-tag-release.yml
  2. 27
      .goreleaser.yml

32
.github/workflows/auto-tag-release.yml

@ -149,6 +149,14 @@ jobs:
go mod vendor
fi
# 添加构建环境准备步骤
- name: Prepare Build Environment
run: |
echo "Building version: ${VERSION:-development}"
echo "GOOS=${GOOS:-$(go env GOOS)}" >> $GITHUB_ENV
echo "GOARCH=${GOARCH:-$(go env GOARCH)}" >> $GITHUB_ENV
echo "GO111MODULE=on" >> $GITHUB_ENV
# 修改 GoReleaser 步骤
- name: Run GoReleaser
if: ${{ startsWith(github.ref, 'refs/tags/v') || (success() && steps.get_latest_tag.outputs.version != '') }}
@ -156,18 +164,38 @@ jobs:
with:
distribution: goreleaser
version: latest
args: release --clean --timeout 60m --snapshot
args: release --clean --timeout 60m
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.get_latest_tag.outputs.version }}
CGO_ENABLED: 0
GOFLAGS: -mod=vendor
GOPATH: ${{ github.workspace }}/go
GOROOT: ${{ env.GOROOT }}
GOCACHE: ${{ github.workspace }}/.cache/go-build
GOMODCACHE: ${{ github.workspace }}/go/pkg/mod
GORELEASER_DEBUG: 1
GORELEASER_CURRENT_TAG: ${{ steps.get_latest_tag.outputs.version }}
# 添加额外的构建信息
BUILD_TIME: ${{ steps.get_latest_tag.outputs.version }}
BUILD_COMMIT: ${{ github.sha }}
# 优化 vendor 同步步骤
- name: Sync vendor directory
run: |
echo "Syncing vendor directory..."
go mod tidy
go mod vendor
go mod verify
# 验证 vendor 目录
if [ -d "vendor" ]; then
echo "Verifying vendor directory..."
go mod verify
# 检查是否有未跟踪的文件
if [ -n "$(git status --porcelain vendor/)" ]; then
echo "Warning: Vendor directory has uncommitted changes"
git status vendor/
fi
fi
# 添加错误检查步骤
- name: Check GoReleaser Output

27
.goreleaser.yml

@ -1,7 +1,10 @@
version: 2
before:
hooks:
- go mod tidy
- go mod download
- go mod vendor
- go mod verify
builds:
- id: cursor-id-modifier
@ -23,10 +26,32 @@ builds:
ldflags:
- -s -w
- -X 'main.version={{.Version}}'
- -X 'main.commit={{.Commit}}'
- -X 'main.date={{.Date}}'
flags:
- -trimpath
mod_timestamp: '{{ .CommitTimestamp }}'
# 添加构建时的项目设置
project_name: cursor-id-modifier
# 添加构建验证
builds_verify:
- skip: false
cmd: "{{.Binary}} --version"
# 改进发布配置
release:
draft: true
prerelease: auto
mode: replace
header: |
## Release {{.Tag}} ({{.Date}})
See [CHANGELOG.md](CHANGELOG.md) for details.
footer: |
**Full Changelog**: https://github.com/owner/repo/compare/{{ .PreviousTag }}...{{ .Tag }}
archives:
- id: binary
format: binary

Loading…
Cancel
Save