Scert/.github/workflows/release.yml
xuans 0ab3246c62
Some checks are pending
Build and Release / Build Release Package (tar.gz, amd64, linux) (push) Waiting to run
Build and Release / Build Release Package (tar.gz, arm64, linux) (push) Waiting to run
Build and Release / Build Release Package (zip, amd64, windows) (push) Waiting to run
ci: 完善双仓库自动化构建工作流并支持分支与标签自动发布
2026-10-18 15:51:27 +08:00

84 lines
2.3 KiB
YAML

name: Build and Release
on:
workflow_dispatch:
push:
branches:
- main
tags:
- 'v*'
- 'V*'
release:
types: [published]
jobs:
build:
name: Build Release Package
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
include:
- goos: linux
goarch: amd64
archive_ext: tar.gz
- goos: linux
goarch: arm64
archive_ext: tar.gz
- goos: windows
goarch: amd64
archive_ext: zip
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.26.x'
cache-dependency-path: backend/go.sum
- name: Determine Version
id: version_step
run: |
if [ -n "${{ github.ref_name }}" ] && [[ "${{ github.ref_name }}" =~ ^[vV][0-9] ]]; then
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
else
PKG_VER=$(node -p "require('./frontend/package.json').version")
echo "VERSION=v${PKG_VER#v}" >> $GITHUB_ENV
fi
- name: Build Frontend
run: |
cd frontend
npm ci
npm run build
- name: Package Release
run: |
node deploy/package.mjs --target=${{ matrix.goos }}_${{ matrix.goarch }} --version=${{ env.VERSION }}
echo "PACKAGE_FILE=Scert_${{ env.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}.${{ matrix.archive_ext }}" >> $GITHUB_ENV
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: Scert_${{ env.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}
path: |
out/${{ env.PACKAGE_FILE }}
out/${{ env.PACKAGE_FILE }}.sha256
- name: Upload to Release (Tag or Release event)
if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: |
out/${{ env.PACKAGE_FILE }}
out/${{ env.PACKAGE_FILE }}.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}