mirror of
https://github.com/setube/ogame-vue-ts.git
synced 2026-05-12 07:55:11 +08:00
chore(workflow): 优化构建与发布流程
- 统一上传步骤命名,增强可读性 - 精确指定上传文件后缀,避免多余目录或文件被上传 - 合并下载与上传步骤,简化 release 流程 - 移除冗余的权限声明与注释 - 修复 release assets 路径引用问题
This commit is contained in:
64
.github/workflows/build.yml
vendored
64
.github/workflows/build.yml
vendored
@@ -35,14 +35,15 @@ jobs:
|
|||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.21'
|
go-version: '1.21'
|
||||||
|
|
||||||
- name: Build Frontend & Server
|
- name: Build Frontend & Server
|
||||||
run: |
|
run: |
|
||||||
pnpm install
|
pnpm install
|
||||||
pnpm run build
|
pnpm run build
|
||||||
[ -f go.mod ] || go mod init ogame-app
|
|
||||||
go mod tidy
|
go mod tidy
|
||||||
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -o ${{ matrix.executable }} main.go
|
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -o ${{ matrix.executable }} main.go
|
||||||
- name: Upload
|
|
||||||
|
- name: Upload Server Binaries
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: server-${{ matrix.goos }}-${{ matrix.goarch }}
|
name: server-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||||
@@ -72,6 +73,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 20
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
|
||||||
- name: Build Electron
|
- name: Build Electron
|
||||||
run: |
|
run: |
|
||||||
pnpm install
|
pnpm install
|
||||||
@@ -79,11 +81,12 @@ jobs:
|
|||||||
pnpm run build:electron --${{ matrix.platform }}
|
pnpm run build:electron --${{ matrix.platform }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Upload
|
|
||||||
|
# 【关键点】这里只上传安装包后缀,不上传文件夹
|
||||||
|
- name: Upload Electron Installers
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: electron-${{ matrix.platform }}
|
name: electron-${{ matrix.platform }}
|
||||||
# 仅上传 pkg 下的安装包,忽略 unpacked 目录
|
|
||||||
path: |
|
path: |
|
||||||
pkg/*.exe
|
pkg/*.exe
|
||||||
pkg/*.dmg
|
pkg/*.dmg
|
||||||
@@ -92,56 +95,35 @@ jobs:
|
|||||||
|
|
||||||
# 3. 发布 Release
|
# 3. 发布 Release
|
||||||
release:
|
release:
|
||||||
needs: [ build-server, build-electron ]
|
needs: [build-server, build-electron]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write # 必须确保有写权限
|
contents: write
|
||||||
pull-requests: read
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
# 1. 获取版本号
|
|
||||||
- name: Get Version
|
- name: Get Version
|
||||||
id: get_version
|
id: get_version
|
||||||
shell: bash
|
run: echo "VERSION=v$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
|
||||||
run: |
|
|
||||||
VERSION=$(node -p "require('./package.json').version")
|
- name: Download All Artifacts
|
||||||
echo "VERSION=v$VERSION" >> $GITHUB_OUTPUT
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: ./release-assets
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
# 2. 创建 Release (先创建,不上传文件)
|
|
||||||
# 这一步能有效避免 404,确保 Release 实体已存在
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
id: create_release
|
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.get_version.outputs.VERSION }}
|
tag_name: ${{ steps.get_version.outputs.VERSION }}
|
||||||
name: Release ${{ steps.get_version.outputs.VERSION }}
|
name: Release ${{ steps.get_version.outputs.VERSION }}
|
||||||
draft: false
|
# 【核心修复】精确指定文件后缀,避免上传 package.json 或 unpacked 目录
|
||||||
prerelease: false
|
files: |
|
||||||
|
./release-assets/*.exe
|
||||||
|
./release-assets/*.dmg
|
||||||
|
./release-assets/*.AppImage
|
||||||
|
./release-assets/*.zip
|
||||||
|
./release-assets/ogame-server-*
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
# 3. 下载产物并上传到已创建的 Release
|
|
||||||
- name: Download and Upload Assets
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
path: ./downloads
|
|
||||||
merge-multiple: true
|
|
||||||
|
|
||||||
- name: Upload Assets to Release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
with:
|
|
||||||
tag_name: ${{ steps.get_version.outputs.VERSION }}
|
|
||||||
append_body: true
|
|
||||||
# 显式指定文件名,不带版本号
|
|
||||||
files: |
|
|
||||||
./downloads/ogame-server-win.exe
|
|
||||||
./downloads/ogame-server-linux
|
|
||||||
./downloads/ogame-server-linux-arm64
|
|
||||||
./downloads/ogame-Setup.exe
|
|
||||||
./downloads/*.dmg
|
|
||||||
./downloads/*.AppImage
|
|
||||||
./downloads/*.zip
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
Reference in New Issue
Block a user