-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (73 loc) · 2.43 KB
/
release.yml
File metadata and controls
84 lines (73 loc) · 2.43 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
name: Build and Release (Windows)
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build-windows:
runs-on: windows-latest
permissions:
contents: write
defaults:
run:
shell: pwsh
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
run: |
pip install uv
- name: Cache uv
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-uv-
- name: 安装依赖项
run: |
uv init \
uv sync
- name: 使用 PyInstaller 构建(规范)
run: |
uv run pyinstaller main.spec
- name: List dist
run: |
Get-ChildItem -Recurse dist | Format-List
- name: 确定版本和包
id: pkg
run: |
$tag = if ("${{ github.ref_type }}" -eq 'tag') { "${{ github.ref_name }}" } else { "manual" }
$version = $tag.TrimStart('v')
# Default artifact folder name from spec
$defaultFolder = Join-Path "dist" "NovaAutoScript"
if (-Not (Test-Path $defaultFolder)) {
# Fallback to first directory in dist
$firstDir = Get-ChildItem dist -Directory | Select-Object -First 1
if ($null -eq $firstDir) { throw "在 dist 下找不到构建输出" }
$defaultFolder = $firstDir.FullName
}`
$zipName = "Nova-AutoScript-windows-$version.zip"
Compress-Archive -Path "$defaultFolder/*" -DestinationPath $zipName -Force
Write-Output "zip=$zipName" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: 上传项目
uses: actions/upload-artifact@v4
with:
name: ${{ steps.pkg.outputs.zip }}
path: ${{ steps.pkg.outputs.zip }}
- name: 创建 GitHub 发布
if: github.ref_type == 'tag'
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.pkg.outputs.zip }}
name: Release ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
draft: false
prerelease: ${{ contains(github.ref_name, 'rc') || contains(github.ref_name, 'beta') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}