-
Notifications
You must be signed in to change notification settings - Fork 28
152 lines (134 loc) · 4.47 KB
/
Copy pathrelease.yml
File metadata and controls
152 lines (134 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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.14.3"
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 }}