diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml new file mode 100644 index 0000000..6c3096d --- /dev/null +++ b/.github/workflows/build-macos.yml @@ -0,0 +1,137 @@ +name: build-macos + +on: + push: + branches: [ main, master ] + tags: [ 'v*' ] + pull_request: + branches: [ main, master ] + workflow_dispatch: + +jobs: + build: + name: Build paze for macOS (${{ matrix.arch }}) + strategy: + fail-fast: false + matrix: + include: + - arch: x64 + runner: macos-13 + rid: osx-x64 + - arch: arm64 + runner: macos-14 + rid: osx-arm64 + runs-on: ${{ matrix.runner }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET 10 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '10.0.x' + dotnet-quality: 'preview' + + - name: Restore + run: dotnet restore src/PazeE.Compiler/PazeE.Compiler.csproj + + - name: Determine channel & version + id: meta + run: | + if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then + CHANNEL="release" + else + CHANNEL="alpha" + fi + VERSION=$(dotnet msbuild src/PazeE.Compiler/PazeE.Compiler.csproj \ + -p:BuildChannel=$CHANNEL \ + -getProperty:Version \ + -nologo) + echo "channel=$CHANNEL" >> "$GITHUB_OUTPUT" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "Channel: $CHANNEL Version: $VERSION" + + - name: Publish (self-contained, ${{ matrix.rid }}) + run: | + dotnet publish src/PazeE.Compiler/PazeE.Compiler.csproj \ + -c Release \ + -p:BuildChannel=${{ steps.meta.outputs.channel }} \ + -r ${{ matrix.rid }} \ + --self-contained true \ + -p:PublishSingleFile=true \ + -p:EnableCompressionInSingleFile=true + + - name: Stage artifacts + run: | + STAGE="staging/paze-${{ steps.meta.outputs.version }}-macos-${{ matrix.arch }}" + mkdir -p "$STAGE/bin" + cp -v publish/${{ steps.meta.outputs.version }}/bin/* "$STAGE/bin/" 2>/dev/null || true + # 单文件模式下主程序重命名为 paze 并赋予执行权限 + if [ -f "$STAGE/bin/paze" ]; then + chmod +x "$STAGE/bin/paze" + fi + # 包含测试源文件以便验证 + mkdir -p "$STAGE/tests" + cp -v tests/*.pe "$STAGE/tests/" 2>/dev/null || true + # 生成版本说明 + cat > "$STAGE/VERSION.txt" <