From 397e9d950ec30878d8d39e7b0d73d7250825fe16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=85=8E=E9=A5=BC=E6=9E=9C=E5=AD=90=E5=8D=B7=E9=B2=A8?= =?UTF-8?q?=E9=B1=BC=E8=BE=A3=E6=A4=92?= Date: Mon, 30 Dec 2024 19:35:18 +0800 Subject: [PATCH] chore: update .gitignore and enhance auto-tag workflow with cleanup steps - Added Go workspace and cache directories to .gitignore to prevent unnecessary files from being tracked. - Introduced a cleanup step in the auto-tag workflow to remove temporary Go directories and cached files, improving workspace management. - Updated GOPATH, GOCACHE, and GOMODCACHE paths in the workflow to use temporary directories for better isolation during builds. --- .github/workflows/auto-tag-release.yml | 21 ++++++++++++--------- .gitignore | 2 ++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/auto-tag-release.yml b/.github/workflows/auto-tag-release.yml index 73e2f54..ab9e5e5 100644 --- a/.github/workflows/auto-tag-release.yml +++ b/.github/workflows/auto-tag-release.yml @@ -133,12 +133,6 @@ jobs: exit 1 fi - # 添加 Go 工作目录设置 - - name: Set Go Work Directory - run: | - echo "GOPATH=${{ github.workspace }}/go" >> $GITHUB_ENV - echo "${{ github.workspace }}/go/bin" >> $GITHUB_PATH - # 添加依赖检查步骤 - name: Check Dependencies run: | @@ -157,6 +151,15 @@ jobs: echo "GOARCH=${GOARCH:-$(go env GOARCH)}" >> $GITHUB_ENV echo "GO111MODULE=on" >> $GITHUB_ENV + # 添加清理步骤 + - name: Cleanup workspace + run: | + rm -rf /tmp/go/ + rm -rf .cache/ + rm -rf dist/ + git clean -fdx + git status + # 修改 GoReleaser 步骤 - name: Run GoReleaser if: ${{ startsWith(github.ref, 'refs/tags/v') || (success() && steps.get_latest_tag.outputs.version != '') }} @@ -169,10 +172,10 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VERSION: ${{ steps.get_latest_tag.outputs.version }} CGO_ENABLED: 0 - GOPATH: ${{ github.workspace }}/go + GOPATH: /tmp/go GOROOT: ${{ env.GOROOT }} - GOCACHE: ${{ github.workspace }}/.cache/go-build - GOMODCACHE: ${{ github.workspace }}/go/pkg/mod + GOCACHE: /tmp/.cache/go-build + GOMODCACHE: /tmp/go/pkg/mod GORELEASER_DEBUG: 1 GORELEASER_CURRENT_TAG: ${{ steps.get_latest_tag.outputs.version }} # 添加额外的构建信息 diff --git a/.gitignore b/.gitignore index 2d90d08..27161b5 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ dist/ # Go specific go.sum +go/ +.cache/ # IDE and editor files .vscode/