文件
JGZ_YES 8bab209287 ci: chmod +x compiled smoke-test binary before running
paze does not set the executable bit on output ELF/Mach-O, so the
smoke test hit "Permission denied". Add chmod +x so the compiled
hello binary actually executes on both Linux and macOS workflows.
2026-08-03 21:41:46 +08:00

152 行
5.0 KiB
YAML

name: build-linux
on:
push:
branches: [ main, master ]
tags: [ 'v*' ]
pull_request:
branches: [ main, master ]
workflow_dispatch:
jobs:
build:
name: Build paze for Linux (${{ matrix.arch }})
strategy:
fail-fast: false
matrix:
include:
# 公共仓库可免费使用 ubuntu-24.04-arm 原生 ARM64 runner。
- arch: x64
runner: ubuntu-latest
rid: linux-x64
- arch: arm64
runner: ubuntu-24.04-arm
rid: linux-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 }}-linux-${{ matrix.arch }}"
mkdir -p "$STAGE/bin"
cp -v publish/${{ steps.meta.outputs.version }}/bin/* "$STAGE/bin/" 2>/dev/null || true
# 单文件模式下 paze 主程序即 paze.dll/paze.exe → 重命名为 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" <<EOF
PazeE Compiler
Version: ${{ steps.meta.outputs.version }}
Channel: ${{ steps.meta.outputs.channel }}
Target: ${{ matrix.rid }} (self-contained .NET 10)
Commit: ${GITHUB_SHA}
Built: ${GITHUB_RUN_ID}
EOF
# 打包
cd staging
tar -czf ../paze-${{ steps.meta.outputs.version }}-linux-${{ matrix.arch }}.tar.gz *
zip -r -q ../paze-${{ steps.meta.outputs.version }}-linux-${{ matrix.arch }}.zip *
cd ..
ls -lh paze-*.tar.gz paze-*.zip
- name: Smoke test — compile hello.pe
env:
# arm64 构建用 --arch arm 产出 ARM64 ELF;x64 用默认 AMD64。
ARCH_FLAG: ${{ matrix.arch == 'arm64' && '--arch arm' || '' }}
run: |
BIN="staging/paze-${{ steps.meta.outputs.version }}-linux-${{ matrix.arch }}/bin"
if [ -f "$BIN/paze" ]; then
"$BIN/paze" tests/hello.pe --target linux $ARCH_FLAG -o /tmp/hello.elf
file /tmp/hello.elf
chmod +x /tmp/hello.elf
/tmp/hello.elf || true
elif [ -f "$BIN/paze.dll" ]; then
dotnet "$BIN/paze.dll" tests/hello.pe --target linux $ARCH_FLAG -o /tmp/hello.elf
file /tmp/hello.elf
chmod +x /tmp/hello.elf
/tmp/hello.elf || true
else
echo "WARN: paze binary not found, listing bin/:"
ls -la "$BIN"
fi
- name: Upload artifact (tar.gz)
uses: actions/upload-artifact@v4
with:
name: paze-${{ steps.meta.outputs.version }}-linux-${{ matrix.arch }}-tar
path: paze-${{ steps.meta.outputs.version }}-linux-${{ matrix.arch }}.tar.gz
if-no-files-found: error
- name: Upload artifact (zip)
uses: actions/upload-artifact@v4
with:
name: paze-${{ steps.meta.outputs.version }}-linux-${{ matrix.arch }}-zip
path: paze-${{ steps.meta.outputs.version }}-linux-${{ matrix.arch }}.zip
if-no-files-found: error
release:
name: Publish GitHub Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release
uses: softprops/action-gh-release@v2
with:
name: PazeE ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
generate_release_notes: true
files: |
artifacts/**/*.tar.gz
artifacts/**/*.zip