This repository was archived by the owner on Aug 18, 2025. It is now read-only.
v0.9.4 Pre5 #158
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 构建CodeNothing解释器 | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths-ignore: | |
| - 'library_*/**' | |
| - '**.md' | |
| pull_request: | |
| branches: [ main ] | |
| paths-ignore: | |
| - 'library_*/**' | |
| - '**.md' | |
| release: | |
| types: [created] # 发布版本时触发 | |
| workflow_dispatch: # 允许手动触发 | |
| # 添加权限设置 | |
| permissions: | |
| contents: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| name: 构建解释器 | |
| runs-on: ${{ matrix.os }} | |
| continue-on-error: true | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Windows 平台 | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| artifact_name: codenothing-windows-x64 | |
| asset_name: codenothing-windows-x64.zip | |
| release_name: Windows x64 | |
| exe_name: CodeNothing.exe | |
| - os: windows-latest | |
| target: i686-pc-windows-msvc | |
| artifact_name: codenothing-windows-x32 | |
| asset_name: codenothing-windows-x32.zip | |
| release_name: Windows x32 | |
| exe_name: CodeNothing.exe | |
| - os: windows-latest | |
| target: aarch64-pc-windows-msvc | |
| artifact_name: codenothing-windows-arm64 | |
| asset_name: codenothing-windows-arm64.zip | |
| release_name: Windows ARM64 | |
| exe_name: CodeNothing.exe | |
| # Linux 平台 | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| artifact_name: codenothing-linux-x64 | |
| asset_name: codenothing-linux-x64.tar.gz | |
| release_name: Linux x64 | |
| exe_name: CodeNothing | |
| - os: ubuntu-latest | |
| target: i686-unknown-linux-gnu | |
| artifact_name: codenothing-linux-x32 | |
| asset_name: codenothing-linux-x32.tar.gz | |
| release_name: Linux x32 | |
| exe_name: CodeNothing | |
| - os: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| artifact_name: codenothing-linux-arm64 | |
| asset_name: codenothing-linux-arm64.tar.gz | |
| release_name: Linux ARM64 | |
| exe_name: CodeNothing | |
| # Android 平台 | |
| - os: ubuntu-latest | |
| target: aarch64-linux-android | |
| artifact_name: codenothing-android-arm64 | |
| asset_name: codenothing-android-arm64.tar.gz | |
| release_name: Android ARM64 | |
| exe_name: CodeNothing | |
| # macOS 平台 | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| artifact_name: codenothing-macos-intel | |
| asset_name: codenothing-macos-intel.tar.gz | |
| release_name: macOS Intel | |
| exe_name: CodeNothing | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| artifact_name: codenothing-macos-silicon | |
| asset_name: codenothing-macos-silicon.tar.gz | |
| release_name: macOS Apple Silicon | |
| exe_name: CodeNothing | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: 设置Rust工具链 | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: ${{ matrix.target }} | |
| override: true | |
| - name: 安装 Windows 交叉编译工具 | |
| if: matrix.os == 'windows-latest' && matrix.target != 'x86_64-pc-windows-msvc' | |
| run: | | |
| # Windows 交叉编译通常由 Rust 工具链自动处理 | |
| echo "Windows 交叉编译目标: ${{ matrix.target }}" | |
| - name: 安装交叉编译依赖 (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| case ${{ matrix.target }} in | |
| i686-unknown-linux-gnu) | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-multilib g++-multilib | |
| echo "CC_i686_unknown_linux_gnu=i686-linux-gnu-gcc" >> $GITHUB_ENV | |
| echo "CXX_i686_unknown_linux_gnu=i686-linux-gnu-g++" >> $GITHUB_ENV | |
| echo "CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=i686-linux-gnu-gcc" >> $GITHUB_ENV | |
| ;; | |
| aarch64-unknown-linux-gnu) | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
| echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV | |
| echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
| ;; | |
| aarch64-linux-android) | |
| # Android NDK 通过 setup-ndk 安装 | |
| ;; | |
| esac | |
| - name: 验证交叉编译工具 | |
| if: matrix.os == 'ubuntu-latest' && matrix.target != 'x86_64-unknown-linux-gnu' | |
| run: | | |
| case ${{ matrix.target }} in | |
| i686-unknown-linux-gnu) | |
| which i686-linux-gnu-gcc || echo "警告: i686-linux-gnu-gcc 未找到" | |
| ;; | |
| aarch64-unknown-linux-gnu) | |
| which aarch64-linux-gnu-gcc || echo "警告: aarch64-linux-gnu-gcc 未找到" | |
| ;; | |
| esac | |
| - name: 设置 Android NDK | |
| if: matrix.target == 'aarch64-linux-android' | |
| uses: nttld/setup-ndk@v1 | |
| with: | |
| ndk-version: r25c | |
| add-to-path: false | |
| - name: 配置 Android 环境变量 | |
| if: matrix.target == 'aarch64-linux-android' | |
| run: | | |
| echo "CC_aarch64_linux_android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang" >> $GITHUB_ENV | |
| echo "CXX_aarch64_linux_android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++" >> $GITHUB_ENV | |
| echo "AR_aarch64_linux_android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" >> $GITHUB_ENV | |
| echo "CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang" >> $GITHUB_ENV | |
| - name: 显示构建环境信息 | |
| run: | | |
| echo "构建目标: ${{ matrix.target }}" | |
| echo "运行环境: ${{ matrix.os }}" | |
| rustc --version | |
| cargo --version | |
| echo "已安装的目标:" | |
| rustup target list --installed | |
| shell: bash | |
| - name: 构建 | |
| uses: actions-rs/cargo@v1 | |
| with: | |
| command: build | |
| args: --release --target ${{ matrix.target }} | |
| env: | |
| RUST_BACKTRACE: 1 | |
| - name: 创建输出目录 | |
| run: mkdir -p release-package | |
| shell: bash | |
| - name: 打包Windows | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| cp target/${{ matrix.target }}/release/${{ matrix.exe_name }} release-package/ | |
| # 如果examples目录存在,则复制 | |
| if [ -d "examples" ]; then | |
| cp -r examples release-package/ | |
| else | |
| echo "警告:examples目录不存在,跳过复制" | |
| # 创建一个空的examples目录,确保有内容 | |
| mkdir -p release-package/examples | |
| echo "# CodeNothing 示例" > release-package/examples/README.md | |
| fi | |
| 7z a ${{ matrix.asset_name }} ./release-package/* | |
| shell: bash | |
| - name: 打包Linux/macOS/Android | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| cp target/${{ matrix.target }}/release/${{ matrix.exe_name }} release-package/ | |
| # 如果examples目录存在,则复制 | |
| if [ -d "examples" ]; then | |
| cp -r examples release-package/ | |
| else | |
| echo "警告:examples目录不存在,跳过复制" | |
| # 创建一个空的examples目录,确保有内容 | |
| mkdir -p release-package/examples | |
| echo "# CodeNothing 示例" > release-package/examples/README.md | |
| fi | |
| tar -czvf ${{ matrix.asset_name }} -C release-package . | |
| shell: bash | |
| - name: 上传构建产物 | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact_name }} | |
| path: ${{ matrix.asset_name }} | |
| - name: 创建发布 | |
| uses: softprops/action-gh-release@v1 | |
| if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'release' | |
| with: | |
| files: ${{ matrix.asset_name }} | |
| tag_name: ${{ github.ref_name }} | |
| draft: false | |
| generate_release_notes: true |