f5e3c8dff0
- 仓库不再内置 25MB+ 的 Python 运行时与依赖;改由 PyInstaller 在 CI 打成单 exe,内嵌 UAC manifest,双击自动请求管理员权限 - 新增 GitHub / Gitea Actions(推送 v* tag 或页面手动触发),自动构建并发布 release,附 release zip(exe + config.ini + README) - release body 由 workflow 抽取 CHANGELOG.md 对应版本段,并自动注入 UTC 构建日期;CHANGELOG 文件不再手填日期 - script.py 适配 PyInstaller 冻结模式:config.ini 从 exe 同目录读取,避免落入 _MEI 临时解压目录 - README 重写使用流程,强调本工具仅支持「按住开镜」模式,与「切换/按键开镜」不兼容 - 新增 requirements.txt 记录运行/构建依赖;.gitignore 排除 build/ dist/ release/ *.spec
82 lines
2.4 KiB
YAML
82 lines
2.4 KiB
YAML
name: release
|
||
|
||
on:
|
||
push:
|
||
tags:
|
||
- 'v*'
|
||
workflow_dispatch:
|
||
inputs:
|
||
tag:
|
||
description: 'Release tag, 例如 v0.1.0(会自动创建 tag 并发布 release)'
|
||
required: true
|
||
type: string
|
||
|
||
permissions:
|
||
contents: write
|
||
|
||
jobs:
|
||
build:
|
||
runs-on: windows-latest
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
|
||
- name: Resolve release tag
|
||
shell: pwsh
|
||
run: |
|
||
if ($env:GITHUB_EVENT_NAME -eq 'workflow_dispatch') {
|
||
$t = '${{ inputs.tag }}'
|
||
} else {
|
||
$t = $env:GITHUB_REF_NAME
|
||
}
|
||
echo "RELEASE_TAG=$t" >> $env:GITHUB_ENV
|
||
|
||
- uses: actions/setup-python@v5
|
||
with:
|
||
python-version: '3.12'
|
||
cache: pip
|
||
|
||
- name: Install dependencies
|
||
run: pip install -r requirements.txt
|
||
|
||
- name: Build exe
|
||
run: pyinstaller --onefile --uac-admin --console --name df-scope-hold script.py
|
||
|
||
- name: Package release zip
|
||
shell: pwsh
|
||
run: |
|
||
New-Item -ItemType Directory -Force -Path release | Out-Null
|
||
Copy-Item dist/df-scope-hold.exe release/
|
||
Copy-Item config.ini release/
|
||
Copy-Item README.md release/
|
||
Compress-Archive -Path release/* -DestinationPath "df-scope-hold-$env:RELEASE_TAG.zip" -Force
|
||
echo "ASSET_ZIP=df-scope-hold-$env:RELEASE_TAG.zip" >> $env:GITHUB_ENV
|
||
|
||
- name: Upload workflow artifact
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: df-scope-hold-${{ env.RELEASE_TAG }}
|
||
path: ${{ env.ASSET_ZIP }}
|
||
|
||
- name: Extract release notes from CHANGELOG.md
|
||
shell: pwsh
|
||
run: |
|
||
$content = Get-Content CHANGELOG.md -Raw
|
||
$escaped = [regex]::Escape($env:RELEASE_TAG)
|
||
$pattern = "(?ms)^## \[$escaped\].*?(?=^## |\Z)"
|
||
$m = [regex]::Match($content, $pattern)
|
||
if ($m.Success) {
|
||
$body = ($m.Value -replace '^## .*\r?\n', '').Trim()
|
||
} else {
|
||
$body = "Release $env:RELEASE_TAG"
|
||
}
|
||
$date = [DateTime]::UtcNow.ToString('yyyy-MM-dd')
|
||
$body = "**发布日期**: $date (UTC)`n`n" + $body
|
||
Set-Content -Path release-notes.md -Value $body -Encoding utf8
|
||
|
||
- name: Create GitHub Release
|
||
uses: softprops/action-gh-release@v2
|
||
with:
|
||
tag_name: ${{ env.RELEASE_TAG }}
|
||
files: ${{ env.ASSET_ZIP }}
|
||
body_path: release-notes.md
|