Skip to content

Commit 0439f8b

Browse files
committed
ci(workflow): 重构 release 流程并优化构建步骤
- 将 release job 拆分为独立流程,仅在 tag 推送时触发 - 构建与打包步骤仍在主 job 中执行,并条件触发 - 新增步骤从 artifact 下载构建产物以生成 release - 使用 release-action 工具发布 GitHub Release,支持精确指定 artifacts
1 parent 60706c5 commit 0439f8b

File tree

1 file changed

+21
-32
lines changed

1 file changed

+21
-32
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -42,53 +42,42 @@ jobs:
4242
- name: Test
4343
run: make test
4444

45-
release:
46-
if: startsWith(github.ref, 'refs/tags/v')
47-
needs: build-test
48-
runs-on: ubuntu-latest
49-
steps:
50-
- name: Checkout code
51-
uses: actions/checkout@v4
52-
53-
- name: Set up Go
54-
uses: actions/setup-go@v5
55-
with:
56-
go-version: ${{ env.GO_VERSION }}
57-
58-
- name: Install dependencies
59-
run: |
60-
go mod tidy
61-
go get github.com/stretchr/testify
62-
63-
- name: Install golangci-lint
64-
run: |
65-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${{ env.GOLANGCI_LINT_VERSION }}
66-
67-
- name: Lint
68-
run: make lint
69-
70-
- name: Code format
71-
run: |
72-
if [ -f style.sh ]; then bash style.sh; fi
73-
74-
- name: Build binaries (multi-platform)
45+
- name: Build binaries
46+
if: startsWith(github.ref, 'refs/tags/v')
7547
run: make build-binaries
7648

7749
- name: Package binaries
50+
if: startsWith(github.ref, 'refs/tags/v')
7851
run: make package-binaries
7952

8053
- name: Upload Binaries
54+
if: startsWith(github.ref, 'refs/tags/v')
8155
uses: actions/upload-artifact@v4
8256
with:
8357
name: binaries
8458
path: |
8559
dist/*.tar.gz
8660
dist/*.zip
8761
88-
- name: Create GitHub Release
62+
release:
63+
name: Create GitHub Release
64+
if: startsWith(github.ref, 'refs/tags/v')
65+
needs: build-test
66+
runs-on: ubuntu-latest
67+
68+
steps:
69+
- name: Download Binaries
70+
uses: actions/download-artifact@v4
71+
with:
72+
name: binaries
73+
74+
- name: List Downloaded Files
75+
run: ls -l
76+
77+
- name: Create Release
8978
uses: ncipollo/release-action@v1
9079
with:
91-
artifacts: dist/*
80+
artifacts: "*.tar.gz,*.zip"
9281
token: ${{ secrets.GITHUB_TOKEN }}
9382
tag: ${{ github.ref_name }}
9483
name: Release ${{ github.ref_name }}

0 commit comments

Comments
 (0)