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.19.0 - 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: Generate Release Notes if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/') run: | echo "# Scert Release ${{ env.VERSION }}" > release_notes.md echo "" >> release_notes.md echo "### 本次版本主要修改与优化内容:" >> release_notes.md git log -n 10 --pretty=format:"- %s (%h)" >> release_notes.md echo "" >> release_notes.md - 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: body_path: release_notes.md files: | out/${{ env.PACKAGE_FILE }} out/${{ env.PACKAGE_FILE }}.sha256 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}