Skip to content

Build by Nuitka & Release #83

Build by Nuitka & Release

Build by Nuitka & Release #83

Workflow file for this run

name: Build by Nuitka & Release
on:
workflow_dispatch: # 手动触发
inputs:
version:
description: 'Release version (e.g. v0.1.0.0)'
required: true
default: 'v'
is_prerelease:
description: 'Is this a pre-release?'
type: boolean
required: false
push:
tags:
- 'v*' # 以 v 开头的 tag 自动触发
env:
PYTHON_VERSION: "3.11"
BUILD_SCRIPT: "build.py"
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
arch: x86_64
artifact_suffix: linux-x86_64
- os: ubuntu-24.04-arm
arch: aarch64
artifact_suffix: linux-aarch64
- os: windows-latest
arch: amd64
artifact_suffix: windows-amd64
- os: macos-latest
arch: arm64
artifact_suffix: darwin-arm64
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y patchelf gcc ccache
if: runner.os == 'Linux'
- name: Install macOS dependencies
run: |
brew install ccache
if: runner.os == 'macOS'
- name: Install Nuitka and build tools
run: |
python -m pip install --upgrade pip
pip install nuitka zstandard imageio
pip install -r requirements.txt
pip install certifi==2025.4.26
- name: Install UPX (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y upx || sudo apt-get install -y upx-ucl
- name: Install UPX (Windows)
if: runner.os == 'Windows'
run: |
choco install upx -y
- name: Install UPX (macOS)
if: runner.os == 'macOS'
run: |
brew update
brew install upx
- name: Build up
env:
TARGET_ARCH: ${{ matrix.arch }}
run: |
python ${{ env.BUILD_SCRIPT }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: z0scan-${{ matrix.artifact_suffix }}.zip
path: z0scan-${{ matrix.artifact_suffix }}.zip
if-no-files-found: error
create-release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: z0scan-*.zip
merge-multiple: true
- name: Determine release parameters
id: get_params
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "tag=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
echo "prerelease=${{ github.event.inputs.is_prerelease }}" >> $GITHUB_OUTPUT
else
echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
# 自动判断是否为预发布版本
if [[ "${{ github.ref_name }}" =~ -(beta|alpha|rc|pre) ]]; then
echo "prerelease=true" >> $GITHUB_OUTPUT
else
echo "prerelease=false" >> $GITHUB_OUTPUT
fi
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_params.outputs.tag }}
overwrite: true
release_name: Release ${{ steps.get_params.outputs.tag }}
body: |-
**构建信息:**
- 版本: ${{ steps.get_params.outputs.tag }}
- 提交哈希: ${{ github.sha }}
- 触发方式: ${{ github.event_name }}
- 分支: ${{ github.ref_name }}
**支持平台:**
- 💻 Windows (x86_64): `z0scan-windows-amd64.zip`
- 🐧 Linux (x86_64): `z0scan-linux-x86_64.zip`
- 🐧 Linux (AARCH64): `z0scan-linux-aarch64.zip`
- 🍎 macOS (ARM64): `z0scan-darwin-arm64.zip`
files: |
artifacts/z0scan-linux-x86_64.zip
artifacts/z0scan-linux-aarch64.zip
artifacts/z0scan-windows-amd64.zip
artifacts/z0scan-darwin-arm64.zip
draft: false
prerelease: ${{ steps.get_params.outputs.prerelease }}