Skip to content

Commit d505fec

Browse files
authored
Merge pull request #4 from God-2077/dev
若干更新
2 parents 6857fed + 471165e commit d505fec

3 files changed

Lines changed: 109 additions & 28 deletions

File tree

.github/workflows/auto_package_and_release.yml

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,48 @@
1-
name: Package and Release
1+
name: Auto Package and Release
2+
23

34
on:
45
workflow_dispatch:
56
push:
7+
branches:
8+
- main
69
paths:
710
- 'package/config.yml'
811

912
jobs:
10-
package-and-release:
13+
release:
14+
name: release
15+
runs-on: windows-latest
16+
outputs: # 新增 outputs 部分
17+
release_id: ${{ steps.create_release.outputs.id }}
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0 # 获取所有历史记录以便生成标签
23+
24+
- name: Generate version tag
25+
id: version
26+
run: |
27+
# 使用 UTC 时间确保一致性
28+
$date = (Get-Date).ToUniversalTime().ToString("yy.MM.dd")
29+
$tag = "v$date"
30+
$release = "Release $date"
31+
echo "tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
32+
echo "release_name=$release" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
33+
34+
- name: Create Release
35+
id: create_release
36+
uses: softprops/action-gh-release@v1 # 使用更活跃维护的 release 操作
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
with:
40+
tag_name: ${{ steps.version.outputs.tag }}
41+
name: ${{ steps.version.outputs.release_name }}
42+
generate_release_notes: true
43+
draft: false
44+
prerelease: false
45+
package:
1146
strategy:
1247
matrix:
1348
os: [windows-latest, windows-11-arm]
@@ -28,16 +63,6 @@ jobs:
2863
with:
2964
python-version: '3.12'
3065

31-
- name: Generate version tag
32-
id: version
33-
run: |
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
40-
4166
- name: UPX Setup(Windows amd64)
4267
if: ${{ matrix.os == 'windows-latest' }}
4368
run: |
@@ -61,23 +86,12 @@ jobs:
6186
cd package
6287
python build.py config.yml
6388
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-
76-
- name: Upload Release Assets
89+
- name: Upload Release Assets}
7790
uses: xresloader/upload-to-github-release@main
7891
env:
7992
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8093
with:
8194
file: "./dist/*.exe;./dist/*.zip"
82-
release_id: ${{ steps.create_release.outputs.id }}
83-
verbose: true
95+
release_id: ${{ needs.release.outputs.release_id }}
96+
verbose: false
97+
overwrite: true
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Dev Package and Upload(dev)
2+
3+
4+
5+
on:
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- dev
10+
paths:
11+
- 'package/config.yml'
12+
13+
jobs:
14+
package:
15+
strategy:
16+
matrix:
17+
os: [windows-latest, windows-11-arm]
18+
runs-on: os.${{ matrix.os }}
19+
20+
# 添加必要的权限
21+
permissions:
22+
contents: write # 允许创建发布和上传资源
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0 # 获取所有历史记录以便生成标签
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.12'
34+
35+
- name: UPX Setup(Windows amd64)
36+
if: ${{ matrix.os == 'windows-latest' }}
37+
run: |
38+
mkdir upx
39+
curl -o upx/upx.exe https://assets.ksable.top/github/upx/upx/v5.0.1/windows-amd64/upx.exe
40+
41+
- name: Install dependencies
42+
run: |
43+
python -m pip install --upgrade pip
44+
pip install pyinstaller pyyaml
45+
46+
- name: Fix Python encoding (Windows)
47+
run: |
48+
# 设置Python使用UTF-8编码
49+
[System.Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Process')
50+
# 设置控制台编码为UTF-8
51+
chcp.com 65001
52+
53+
- name: Run packaging script
54+
run: |
55+
cd package
56+
python build.py config.yml
57+
58+
- name: Upload files with wildcards
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: Artifact
62+
path: |
63+
./dist/*.exe
64+
./dist/*.zip
65+
retention-days: 90
66+
if-no-files-found: warn
67+
overwrite: true

.github/workflows/package_and_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Package and Release
1+
name: Package and Release(old)
22

33
on:
44
workflow_dispatch:

0 commit comments

Comments
 (0)