Release now uses the exact tag name (e.g., v4.0.23 or 4.0.23) instead of reconstructing it. Artifact filenames no longer include a v prefix (e.g., csc-4.0.23-linux-x64.tar.gz). Existing releases will have new artifacts appended instead of recreated. Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
201 lines
6.4 KiB
YAML
201 lines
6.4 KiB
YAML
name: Publish Binary
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
ref:
|
|
description: '分支或 tag (例如: main 或 v4.0.23)'
|
|
required: true
|
|
type: string
|
|
platform:
|
|
description: '编译平台'
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- all
|
|
- linux
|
|
- linux-baseline
|
|
- linux-musl
|
|
- linux-musl-baseline
|
|
- win
|
|
- win-baseline
|
|
- mac-arm64
|
|
- mac-x64
|
|
- mac-x64-baseline
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
resolve:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.resolve.outputs.version }}
|
|
tag_name: ${{ steps.resolve.outputs.tag_name }}
|
|
is_tag: ${{ steps.resolve.outputs.is_tag }}
|
|
matrix: ${{ steps.resolve.outputs.matrix }}
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
fetch-depth: 0
|
|
ref: ${{ inputs.ref }}
|
|
|
|
- name: Resolve version and matrix
|
|
id: resolve
|
|
run: |
|
|
REF="${{ inputs.ref }}"
|
|
|
|
# Determine if ref is a tag
|
|
if git rev-parse --verify "refs/tags/${REF}" >/dev/null 2>&1; then
|
|
TAG_NAME="${REF}"
|
|
VERSION="${REF#v}"
|
|
IS_TAG=true
|
|
else
|
|
VERSION=$(git rev-parse --short HEAD)
|
|
TAG_NAME=""
|
|
IS_TAG=false
|
|
fi
|
|
|
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
echo "tag_name=${TAG_NAME}" >> "$GITHUB_OUTPUT"
|
|
echo "is_tag=${IS_TAG}" >> "$GITHUB_OUTPUT"
|
|
|
|
# Build matrix based on platform input
|
|
case "${{ inputs.platform }}" in
|
|
all)
|
|
MATRIX='["linux-x64","linux-x64-baseline","linux-x64-musl","linux-x64-musl-baseline","windows-x64","windows-x64-baseline","darwin-arm64","darwin-x64","darwin-x64-baseline"]'
|
|
;;
|
|
linux)
|
|
MATRIX='["linux-x64"]'
|
|
;;
|
|
linux-baseline)
|
|
MATRIX='["linux-x64-baseline"]'
|
|
;;
|
|
linux-musl)
|
|
MATRIX='["linux-x64-musl"]'
|
|
;;
|
|
linux-musl-baseline)
|
|
MATRIX='["linux-x64-musl-baseline"]'
|
|
;;
|
|
win)
|
|
MATRIX='["windows-x64"]'
|
|
;;
|
|
win-baseline)
|
|
MATRIX='["windows-x64-baseline"]'
|
|
;;
|
|
mac-arm64)
|
|
MATRIX='["darwin-arm64"]'
|
|
;;
|
|
mac-x64)
|
|
MATRIX='["darwin-x64"]'
|
|
;;
|
|
mac-x64-baseline)
|
|
MATRIX='["darwin-x64-baseline"]'
|
|
;;
|
|
*)
|
|
echo "Unknown platform: ${{ inputs.platform }}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
echo "matrix=${MATRIX}" >> "$GITHUB_OUTPUT"
|
|
|
|
build:
|
|
needs: resolve
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
target: ${{ fromJson(needs.resolve.outputs.matrix) }}
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
ref: ${{ inputs.ref }}
|
|
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
with:
|
|
bun-version: "1.3.11"
|
|
|
|
- name: Setup SSH for review agent generation
|
|
uses: webfactory/ssh-agent@v0.9.0
|
|
with:
|
|
ssh-private-key: ${{ secrets.MY_SSH_PRIVATE_KEY }}
|
|
continue-on-error: true
|
|
|
|
- name: Install dependencies
|
|
env:
|
|
CLAUDE_CODE_SKIP_CHROME_MCP_SETUP: "1"
|
|
run: bun install --frozen-lockfile
|
|
|
|
- name: Build
|
|
run: bun run build
|
|
|
|
- name: Compile
|
|
run: |
|
|
TARGET="${{ matrix.target }}"
|
|
case "$TARGET" in
|
|
linux-x64)
|
|
bun build dist/cli.js --compile --target=bun-linux-x64 --outfile "dist/csc-${TARGET}"
|
|
;;
|
|
linux-x64-baseline)
|
|
bun build dist/cli.js --compile --target=bun-linux-x64-baseline --outfile "dist/csc-${TARGET}"
|
|
;;
|
|
linux-x64-musl)
|
|
bun build dist/cli.js --compile --target=bun-linux-x64-musl --outfile "dist/csc-${TARGET}"
|
|
;;
|
|
linux-x64-musl-baseline)
|
|
bun build dist/cli.js --compile --target=bun-linux-x64-musl-baseline --outfile "dist/csc-${TARGET}"
|
|
;;
|
|
windows-x64)
|
|
bun build dist/cli.js --compile --target=bun-windows-x64 --outfile "dist/csc-${TARGET}.exe"
|
|
;;
|
|
windows-x64-baseline)
|
|
bun build dist/cli.js --compile --target=bun-windows-x64-baseline --outfile "dist/csc-${TARGET}.exe"
|
|
;;
|
|
darwin-arm64)
|
|
bun build dist/cli.js --compile --target=bun-darwin-arm64 --outfile "dist/csc-${TARGET}"
|
|
;;
|
|
darwin-x64)
|
|
bun build dist/cli.js --compile --target=bun-darwin-x64 --outfile "dist/csc-${TARGET}"
|
|
;;
|
|
darwin-x64-baseline)
|
|
bun build dist/cli.js --compile --target=bun-darwin-x64-baseline --outfile "dist/csc-${TARGET}"
|
|
;;
|
|
esac
|
|
|
|
- name: Package
|
|
run: |
|
|
VERSION="${{ needs.resolve.outputs.version }}"
|
|
TARGET="${{ matrix.target }}"
|
|
mkdir -p release
|
|
|
|
if [[ "$TARGET" == windows* ]]; then
|
|
zip -j "release/csc-${VERSION}-${TARGET}.zip" "dist/csc-${TARGET}.exe"
|
|
else
|
|
tar -czf "release/csc-${VERSION}-${TARGET}.tar.gz" -C dist "csc-${TARGET}"
|
|
fi
|
|
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: csc-${{ matrix.target }}
|
|
path: release/*
|
|
|
|
release:
|
|
needs: [resolve, build]
|
|
runs-on: ubuntu-latest
|
|
if: needs.resolve.outputs.is_tag == 'true'
|
|
steps:
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
|
with:
|
|
path: release
|
|
pattern: csc-*
|
|
merge-multiple: true
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2
|
|
with:
|
|
tag_name: ${{ needs.resolve.outputs.tag_name }}
|
|
name: ${{ needs.resolve.outputs.tag_name }}
|
|
files: release/*
|
|
draft: false
|
|
prerelease: ${{ contains(needs.resolve.outputs.version, 'rc') || contains(needs.resolve.outputs.version, 'beta') || contains(needs.resolve.outputs.version, 'alpha') }}
|