1- name : Nuitka Package and Upload(dev)
1+ name : Nuitka Package and Release
22
33on :
44 workflow_dispatch :
99 - ' package/nuitka_config.yml'
1010
1111jobs :
12- package-and-upload :
12+ package-and-release :
1313 runs-on : windows-latest
14- # runs-on: ${{ matrix.os }}
15- # strategy:
16- # matrix:
17- # os: [ubuntu-latest,ubuntu-24.04-arm,windows-latest] # windows-11-arm没有对应的 Python
18- env :
19- PYTHON_VERSION : ' 3.10'
20- NUITKA_CACHE_DIR : ${{ github.workspace }}/nuitka-cache
21- UPXVERSION : ' 5.0.1'
2214
2315 # 添加必要的权限
2416 permissions :
2517 contents : write # 允许创建发布和上传资源
2618
2719 steps :
20+ - name : Set Timezone to China Standard Time
21+ run : tzutil /s "China Standard Time"
22+ shell : pwsh
2823
2924 - name : Checkout code
3025 uses : actions/checkout@v4
3126
32- - name : Set Timezone to China Standard Time on Windows
33- if : ${{ runner.os == 'Windows' }}
34- run : tzutil /s "China Standard Time"
35- shell : pwsh
36-
37- - name : Set Timezone to China Standard Time on Linux
38- if : ${{ runner.os == 'Linux' }}
39- run : sudo timedatectl set-timezone Asia/Shanghai
40-
41- - name : Generate version tag on Windows
42- if : ${{ runner.os == 'Windows' }}
27+ - name : Generate version tag
28+ id : version
4329 run : |
4430 # 使用 UTC 时间确保一致性
4531 $date = (Get-Date).ToUniversalTime().ToString("yy.MM.dd")
4632 $tag = "v$date"
4733 $release = "Release $date"
48- echo "VERSION_TAG=$tag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
49- echo "RELEASE_NAME=$release" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
50- shell : pwsh
51-
52- - name : Generate version tag on Linux
53- if : ${{ runner.os == 'Linux' }}
54- run : |
55- # 使用 UTC 时间确保一致性
56- DATE=$(date -u +%y.%m.%d)
57- echo "VERSION_TAG=v$DATE" >> $GITHUB_ENV
58- echo "RELEASE_NAME=Release $DATE" >> $GITHUB_ENV
59- shell : bash
60-
34+ echo "tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
35+ echo "release_name=$release" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
36+
37+
6138 - name : Set up Python
6239 uses : actions/setup-python@v5
6340 with :
64- python-version : ${{ env.PYTHON_VERSION }}
65-
66- - name : Cache UPX
67- id : cache-upx
68- uses : actions/cache@v4
69- with :
70- path : upx
71- key : ${{ runner.os }}-${{ runner.arch }}-upx-v${{ env.UPXVERSION }}
72- restore-keys : |
73- ${{ runner.os }}-${{ runner.arch }}-upx-
74-
75- - name : Create UPX directory
76- if : ${{ steps.cache-upx.outputs.cache-hit != 'true' }}
77- run : mkdir -p ./upx
78-
79- - name : Install UPX on Linux
80- if : ${{ runner.os == 'Linux' && steps.cache-upx.outputs.cache-hit != 'true' }}
81- run : |
82-
83- UPX_URL="https://github.com/upx/upx/releases/download/v${{ env.UPXVERSION }}/upx-${{ env.UPXVERSION }}-${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}_linux.tar.xz"
84- curl -L "$UPX_URL" -o upx.tar.xz
85- tar -xf upx.tar.xz -C ./upx --strip-components=1
86- chmod +x ./upx/upx
87-
88- shell : bash
41+ python-version : ' 3.10'
8942
90- - name : Install UPX on Windows
91- if : ${{ runner.os == 'Windows' && steps.cache-upx.outputs.cache-hit != 'true' }}
43+ - name : UPX Setup
9244 run : |
93- $arch = if (("${{ runner.arch }}" -eq "amd64") -or ("${{ runner.arch }}" -eq "X64")) { "win64" } else { "win32" }
94- $upxVersion = "${{ env.UPXVERSION }}"
95- $upxUrl = "https://github.com/upx/upx/releases/download/v$upxVersion/upx-$upxVersion-$arch.zip"
96-
97- Invoke-WebRequest -Uri $upxUrl -OutFile upx.zip
98- Expand-Archive -Path upx.zip -DestinationPath ./upx -Force
99-
100- # Windows 版本的 UPX 解压后在子目录中,需要移动到根目录
101- Move-Item -Path "./upx/upx-$upxVersion-$arch/*" -Destination ./upx -Force
102-
103- shell : pwsh
104-
105- - name : Verify UPX installation
106- run : |
107- ./upx/upx --version
108- shell : bash
109-
110- - name : get pip cache dir on Windows
111- if : ${{ runner.os == 'Windows' }}
112- id : pip-cache-dir-window
113- run : echo "pip-cache-dir=$(pip cache dir)" >> $env:GITHUB_OUTPUT
114-
115- - name : get pip cache dir on Linux
116- if : ${{ runner.os == 'Linux' }}
117- id : pip-cache-dir-linux
118- run : echo "pip-cache-dir=$(pip cache dir)" >> $GITHUB_OUTPUT
119-
120- - name : pip cache
121- uses : actions/cache@v4
122- with :
123- path : ${{ runner.os == 'Windows' && steps.pip-cache-dir-window.outputs.pip-cache-dir || steps.pip-cache-dir-linux.outputs.pip-cache-dir }}
124- key : ${{ runner.os }}-${{ runner.arch }}-pip-${{ github.event.inputs.test && hashFiles(github.event.inputs.config_path) || hashFiles('package/nuitka_build.py') }}
125- restore-keys : |
126- ${{ runner.os }}-${{ runner.arch }}-pip-
127-
45+ mkdir upx
46+ curl -o upx/upx.exe https://assets.ksable.top/github/upx/upx/v5.0.1/windows-amd64/upx.exe
12847
12948 - name : Install dependencies
13049 run : |
@@ -145,46 +64,26 @@ jobs:
14564 # # 设置控制台编码为UTF-8
14665 # chcp.com 65001
14766
148- - name : Install ccache on Linux
149- if : ${{ runner.os == 'Linux' }}
150- run : |
151- sudo apt-get update -y
152- sudo apt-get install -y ccache
153-
154- - name : Cache Nuitka cache directory
155- uses : actions/cache@v4
156- with :
157- path : ${{ env.NUITKA_CACHE_DIR }}
158- key : nuitka-${{ runner.os }}-${{ runner.arch }}-python-${{ env.PYTHON_VERSION }}-nuitka-${{ github.event.inputs.test && hashFiles(github.event.inputs.config_path) || hashFiles('package/nuitka_build.py') }}
159- restore-keys : |
160- nuitka-${{ runner.os }}-${{ runner.arch }}-python-${{ env.PYTHON_VERSION }}-
161- nuitka-${{ runner.os }}-${{ runner.arch }}-
162-
163- - name : Run packaging script on Windows
164- if : ${{ runner.os == 'Windows' }}
67+ - name : Run packaging script
16568 run : |
16669 # 设置Python使用UTF-8编码
16770 [System.Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Process')
16871 # 设置控制台编码为UTF-8
16972 chcp.com 65001
170- python ./package/nuitka_build.py ./package/nuitka_config.yml
171-
172- - name : Run packaging script on Linux
173- if : ${{ runner.os == 'Linux' }}
174- run : |
175- python ./package/nuitka_build.py ./package/nuitka_config.yml
73+ cd package
74+ python nuitka_build.py nuitka_config.yml
17675
17776 - name : Create Release
17877 id : create_release
17978 uses : softprops/action-gh-release@v1 # 使用更活跃维护的 release 操作
18079 env :
18180 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
18281 with :
183- tag_name : ${{ env.VERSION_TAG }}
184- name : ${{ env.RELEASE_NAME }}
82+ tag_name : ${{ steps.version.outputs.tag }}
83+ name : ${{ steps.version.outputs.release_name }}
18584 generate_release_notes : true
18685 draft : false
18786 prerelease : false
18887 overwrite_files : true
18988 files : |
190- dist/*
89+ dist/*.exe
0 commit comments