1- name : Auto Package and Release
1+ name : Package and Release
22
33on :
44 workflow_dispatch :
77 - ' package/config.yml'
88
99jobs :
10- release :
11- name : release
12- runs-on : windows-latest
13- outputs : # 新增 outputs 部分
14- release_id : ${{ steps.create_release.outputs.id }}
15- steps :
16- - name : Checkout code
17- uses : actions/checkout@v4
18- with :
19- fetch-depth : 0 # 获取所有历史记录以便生成标签
20-
21- - name : Generate version tag
22- id : version
23- run : |
24- # 使用 UTC 时间确保一致性
25- $date = (Get-Date).ToUniversalTime().ToString("yy.MM.dd")
26- $tag = "v$date"
27- $release = "Release $date"
28- echo "tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
29- echo "release_name=$release" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
30-
31- - name : Create Release
32- id : create_release
33- uses : softprops/action-gh-release@v1 # 使用更活跃维护的 release 操作
34- env :
35- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
36- with :
37- tag_name : ${{ steps.version.outputs.tag }}
38- name : ${{ steps.version.outputs.release_name }}
39- generate_release_notes : true
40- draft : false
41- prerelease : false
42-
43- package :
44- needs : release
45- name : package
10+ package-and-release :
4611 strategy :
4712 matrix :
48- os : [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm]
49-
50- runs-on : ${{ matrix.os }}
13+ os : [windows-latest, windows-11-arm]
14+ runs-on : os.${{ matrix.os }}
5115
5216 # 添加必要的权限
5317 permissions :
@@ -58,48 +22,34 @@ jobs:
5822 uses : actions/checkout@v4
5923 with :
6024 fetch-depth : 0 # 获取所有历史记录以便生成标签
61-
62- - name : Tree (linux)
63- if : ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' }}
64- run : |
65- pwd
66- tree
67-
68- - name : Tree (Windows)
69- if : ${{ matrix.os == 'windows-latest' || matrix.os == 'windows-11-arm' }}
70- run : |
71- chdir
72- tree
25+
7326 - name : Set up Python
7427 uses : actions/setup-python@v5
7528 with :
7629 python-version : ' 3.12'
7730
78- - name : UPX Setup(Windows amd64)
79- if : ${{ matrix.os == 'windows-latest' }}
31+ - name : Generate version tag
32+ id : version
8033 run : |
81- mkdir upx
82- curl -o upx/upx.exe https://assets.ksable.top/github/upx/upx/v5.0.1/upx.exe
34+ # 使用 UTC 时间确保一致性
35+ $date = (Get-Date).ToUniversalTime().ToString("yy.MM.dd")
36+ $tag = "v$date"
37+ $release = "Release $date"
38+ echo "tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
39+ echo "release_name=$release" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
8340
84- - name : UPX Setup(Linux amd64)
85- if : ${{ matrix.os == 'ubuntu-latest' }}
86- run : |
87- mkdir upx
88- curl -o upx/upx https://assets.ksable.top/github/upx/upx/v5.0.1/linux-amd64/upx
89-
90- - name : UPX Setup(Linux arm64)
91- if : ${{ matrix.os == 'ubuntu-24.04-arm' }}
41+ - name : UPX Setup(Windows amd64)
42+ if : ${{ matrix.os == 'windows-latest' }}
9243 run : |
9344 mkdir upx
94- curl -o upx/upx https://assets.ksable.top/github/upx/upx/v5.0.1/linux-arm64 /upx
45+ curl -o upx/upx.exe https://assets.ksable.top/github/upx/upx/v5.0.1/windows-amd64 /upx.exe
9546
9647 - name : Install dependencies
9748 run : |
9849 python -m pip install --upgrade pip
9950 pip install pyinstaller pyyaml
10051
10152 - name : Fix Python encoding (Windows)
102- if : ${{ matrix.os == 'windows-latest' || matrix.os == 'windows-11-arm'}}
10353 run : |
10454 # 设置Python使用UTF-8编码
10555 [System.Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Process')
@@ -110,42 +60,24 @@ jobs:
11060 run : |
11161 cd package
11262 python build.py config.yml
113-
114- # - name: Check
115- # run: |
116- # python ./package/md5.py dist
11763
118- # 检查 ./dist/ 是否存在文件(Linux)
119- - name : Check if ./dist exists and has files
120- if : ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' }}
121- run : |
122- if [ -d "./dist" ] && [ -n "$(ls -A ./dist)" ]; then
123- echo "havefilel=1" >> $GITHUB_ENV
124-
125- else
126- echo "havefilel=0" >> $GITHUB_ENV
127- fi
128-
129- - name : Check if ./dist exists and has files (CMD)
130- if : ${{ matrix.os == 'windows-latest' || matrix.os == 'windows-11-arm' }}
131- shell : cmd
132- run : |
133- if exist dist\ (
134- cd dist
135- for /f "delims=" %%a in ('dir /b 2^>nul') do (
136- echo havefilew=1 >> "%GITHUB_ENV%"
137- exit /b 0
138- )
139- )
140- echo havefile=0 >> "%GITHUB_ENV%"
141-
64+ - name : Create Release
65+ id : create_release
66+ uses : softprops/action-gh-release@v1 # 使用更活跃维护的 release 操作
67+ env :
68+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
69+ with :
70+ tag_name : ${{ steps.version.outputs.tag }}
71+ name : ${{ steps.version.outputs.release_name }}
72+ generate_release_notes : true
73+ draft : false
74+ prerelease : false
75+
14276 - name : Upload Release Assets
143- if : ${{ env.havefilew == '1' || env.havefilel =='1'}}
14477 uses : xresloader/upload-to-github-release@main
14578 env :
14679 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
14780 with :
148- file : " ./dist/*.exe;./dist/*/*.exe;./dist/*"
149- release_id : ${{ needs.release.outputs.release_id }} # 修正引用路径
150- verbose : false
151- overwrite : true
81+ file : " ./dist/*.exe;./dist/*.zip"
82+ release_id : ${{ steps.create_release.outputs.id }}
83+ verbose : true
0 commit comments