From e22f0f62ac0c2cc1f4ff2c439a788344d4f2e534 Mon Sep 17 00:00:00 2001 From: tbphp Date: Sun, 20 Jul 2025 09:43:38 +0800 Subject: [PATCH 1/7] chore: release linux --- .github/workflows/build-go.yml | 70 ----------------------------- .github/workflows/release-linux.yml | 47 +++++++++++++++++++ 2 files changed, 47 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/build-go.yml create mode 100644 .github/workflows/release-linux.yml diff --git a/.github/workflows/build-go.yml b/.github/workflows/build-go.yml deleted file mode 100644 index 4b1d9c6..0000000 --- a/.github/workflows/build-go.yml +++ /dev/null @@ -1,70 +0,0 @@ -# .github/workflows/build.yml - -name: Build and Package gpt_load - -# 工作流触发条件 -on: - # 1. 自动触发:当代码推送到 main 分支时 - push: - branches: - - main - # 2. 自动触发:当向 main 分支发起 Pull Request 时 - pull_request: - branches: - - main - # 3. 手动触发:允许在 Actions 页面手动运行此工作流 - workflow_dispatch: - -jobs: - build-and-package: - # 指定运行环境 - runs-on: ubuntu-latest - - steps: - # 1. 检出代码 - - name: Checkout code - uses: actions/checkout@v4 - - # 2. 设置 Go 环境 - - name: Setup Go environment - uses: actions/setup-go@v5 - with: - go-version: '1.22.x' - - # 3. 设置 Node.js 环境 (用于编译 Vue) - - name: Setup Node.js environment - uses: actions/setup-node@v4 - with: - node-version: '20.x' - cache: 'npm' - cache-dependency-path: 'web/package-lock.json' - - # 4. 构建 Vue 前端 - - name: Build Vue Frontend - run: npm install && npm run build - working-directory: ./web - - # 5. 编译 Go 应用 - # 我们将编译后的二进制文件命名为 gpt_load - - name: Build Go Application - run: go build -v -ldflags="-s -w" -o gpt_load ./main.go - - # 6. 准备用于打包的目录 - # 将 gpt_load 和 dist 目录移入打包目录 - - name: Prepare Package Directory - run: | - mkdir release_package - mv gpt_load release_package/ - mv web/dist release_package/ - - # 7. 创建压缩包 - # 将压缩包命名为 gpt_load-linux-amd64.tar.gz - - name: Create Compressed Archive - run: tar -czvf gpt_load-linux-amd64.tar.gz -C release_package . - - # 8. 上传最终的压缩包作为产物 - - name: Upload Release Package - uses: actions/upload-artifact@v4 - with: - name: gpt_load-package-linux-amd64 # Artifact的名称也更新 - path: gpt_load-linux-amd64.tar.gz # 上传更新后的压缩文件 diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml new file mode 100644 index 0000000..27349f9 --- /dev/null +++ b/.github/workflows/release-linux.yml @@ -0,0 +1,47 @@ +name: Release Linux Build + +on: + push: + tags: + - "*" +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: "20.x" + cache: "npm" + cache-dependency-path: "web/package-lock.json" + - name: Build Frontend + run: VITE_VERSION=${{ github.ref_name }} npm install && npm run build + working-directory: ./web + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.23.x" + - name: Build Go for amd64 + run: | + go mod download + go build -ldflags "-s -w -X gpt-load/internal/version.Version=${{ github.ref_name }}"" -extldflags '-static'" -o gpt-load + - name: Build Go for arm64 + run: | + sudo apt-get update + DEBIAN_FRONTEND=noninteractive sudo apt-get install -y gcc-aarch64-linux-gnu + CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X gpt-load/internal/version.Version=${{ github.ref_name }}"" -extldflags '-static'" -o gpt-load-arm64 + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + gpt-load + gpt-load-arm64 + draft: true + generate_release_notes: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b50bb7ea3bbbf327c4fb858d0567520cbe7f17a5 Mon Sep 17 00:00:00 2001 From: tbphp Date: Sun, 20 Jul 2025 09:53:06 +0800 Subject: [PATCH 2/7] fix: build --- .github/workflows/release-linux.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index 27349f9..2d4da70 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -28,12 +28,10 @@ jobs: - name: Build Go for amd64 run: | go mod download - go build -ldflags "-s -w -X gpt-load/internal/version.Version=${{ github.ref_name }}"" -extldflags '-static'" -o gpt-load + go build -ldflags "-s -w -X gpt-load/internal/version.Version=${{ github.ref_name }}" -o gpt-load - name: Build Go for arm64 run: | - sudo apt-get update - DEBIAN_FRONTEND=noninteractive sudo apt-get install -y gcc-aarch64-linux-gnu - CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X gpt-load/internal/version.Version=${{ github.ref_name }}"" -extldflags '-static'" -o gpt-load-arm64 + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X gpt-load/internal/version.Version=${{ github.ref_name }}" -o gpt-load-arm64 - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') From d18f8e322830ee827ea69eab9be1c642e3d5cacb Mon Sep 17 00:00:00 2001 From: tbphp Date: Sun, 20 Jul 2025 10:15:27 +0800 Subject: [PATCH 3/7] fix: release linux --- .github/workflows/release-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index 2d4da70..81fc253 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -28,7 +28,7 @@ jobs: - name: Build Go for amd64 run: | go mod download - go build -ldflags "-s -w -X gpt-load/internal/version.Version=${{ github.ref_name }}" -o gpt-load + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X gpt-load/internal/version.Version=${{ github.ref_name }}" -o gpt-load - name: Build Go for arm64 run: | CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X gpt-load/internal/version.Version=${{ github.ref_name }}" -o gpt-load-arm64 From a3d7eff97e048fa063bef93addb7b3e7938f2111 Mon Sep 17 00:00:00 2001 From: tbphp Date: Sun, 20 Jul 2025 10:26:50 +0800 Subject: [PATCH 4/7] fix: release permission --- .github/workflows/release-linux.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index 81fc253..950cd44 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -1,4 +1,6 @@ name: Release Linux Build +permissions: + contents: write on: push: From 31dec6112b8488637f36882d403ae0cd53b42b76 Mon Sep 17 00:00:00 2001 From: tbphp Date: Sun, 20 Jul 2025 10:32:26 +0800 Subject: [PATCH 5/7] feat: build full --- .github/workflows/release-linux.yml | 6 ++-- .github/workflows/release-macos.yml | 43 +++++++++++++++++++++++++ .github/workflows/release-windows.yml | 46 +++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release-macos.yml create mode 100644 .github/workflows/release-windows.yml diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index 950cd44..5a607c4 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -27,11 +27,11 @@ jobs: uses: actions/setup-go@v5 with: go-version: "1.23.x" - - name: Build Go for amd64 + - name: Build Backend for amd64 run: | go mod download - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X gpt-load/internal/version.Version=${{ github.ref_name }}" -o gpt-load - - name: Build Go for arm64 + go build -ldflags "-s -w -X gpt-load/internal/version.Version=${{ github.ref_name }}" -o gpt-load + - name: Build Backend for arm64 run: | CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X gpt-load/internal/version.Version=${{ github.ref_name }}" -o gpt-load-arm64 - name: Release diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml new file mode 100644 index 0000000..569eaec --- /dev/null +++ b/.github/workflows/release-macos.yml @@ -0,0 +1,43 @@ +name: Release Linux Build +permissions: + contents: write + +on: + push: + tags: + - "*" +jobs: + release: + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: "20.x" + cache: "npm" + cache-dependency-path: "web/package-lock.json" + - name: Build Frontend + run: VITE_VERSION=${{ github.ref_name }} npm install && npm run build + working-directory: ./web + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.23.x" + - name: Build Backend + run: | + go mod download + go build -ldflags "-s -w -X gpt-load/internal/version.Version=${{ github.ref_name }}" -o gpt-load-macos + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + gpt-load-macos + draft: true + generate_release_notes: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml new file mode 100644 index 0000000..113e499 --- /dev/null +++ b/.github/workflows/release-windows.yml @@ -0,0 +1,46 @@ +name: Release Linux Build +permissions: + contents: write + +on: + push: + tags: + - "*" +jobs: + release: + runs-on: windows-latest + defaults: + run: + shell: bash + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: "20.x" + cache: "npm" + cache-dependency-path: "web/package-lock.json" + - name: Build Frontend + run: VITE_VERSION=${{ github.ref_name }} npm install && npm run build + working-directory: ./web + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.23.x" + - name: Build Backend + run: | + go mod download + go build -ldflags "-s -w -X gpt-load/internal/version.Version=${{ github.ref_name }}" -o gpt-load.exe + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + gpt-load.exe + draft: true + generate_release_notes: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a46c01e37036bd95e2b09d2e407a2d986db64c18 Mon Sep 17 00:00:00 2001 From: tbphp Date: Sun, 20 Jul 2025 10:36:24 +0800 Subject: [PATCH 6/7] fix: release name --- .github/workflows/release-macos.yml | 2 +- .github/workflows/release-windows.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml index 569eaec..23a532d 100644 --- a/.github/workflows/release-macos.yml +++ b/.github/workflows/release-macos.yml @@ -1,4 +1,4 @@ -name: Release Linux Build +name: Release MacOS Build permissions: contents: write diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index 113e499..9f293ae 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -1,4 +1,4 @@ -name: Release Linux Build +name: Release Windows Build permissions: contents: write From 39320da0b2eb1f38cd78e94ff0feb6a80db8cc7f Mon Sep 17 00:00:00 2001 From: tbphp Date: Sun, 20 Jul 2025 10:41:04 +0800 Subject: [PATCH 7/7] fix: releae fe version --- .github/workflows/release-linux.yml | 2 +- .github/workflows/release-macos.yml | 2 +- .github/workflows/release-windows.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index 5a607c4..8156b93 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -21,7 +21,7 @@ jobs: cache: "npm" cache-dependency-path: "web/package-lock.json" - name: Build Frontend - run: VITE_VERSION=${{ github.ref_name }} npm install && npm run build + run: npm install && VITE_VERSION=${{ github.ref_name }} npm run build working-directory: ./web - name: Setup Go uses: actions/setup-go@v5 diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml index 23a532d..8d51bf9 100644 --- a/.github/workflows/release-macos.yml +++ b/.github/workflows/release-macos.yml @@ -21,7 +21,7 @@ jobs: cache: "npm" cache-dependency-path: "web/package-lock.json" - name: Build Frontend - run: VITE_VERSION=${{ github.ref_name }} npm install && npm run build + run: npm install && VITE_VERSION=${{ github.ref_name }} npm run build working-directory: ./web - name: Setup Go uses: actions/setup-go@v5 diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index 9f293ae..6c2c729 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -24,7 +24,7 @@ jobs: cache: "npm" cache-dependency-path: "web/package-lock.json" - name: Build Frontend - run: VITE_VERSION=${{ github.ref_name }} npm install && npm run build + run: npm install && VITE_VERSION=${{ github.ref_name }} npm run build working-directory: ./web - name: Setup Go uses: actions/setup-go@v5