-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (66 loc) · 2.49 KB
/
Copy pathrelease.yml
File metadata and controls
75 lines (66 loc) · 2.49 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
name: Release
# 兩種發佈方式:
# 1. 命令列推 v* tag: git tag v1.4 && git push origin v1.4
# 2. Actions 分頁手動:Run workflow → 在「tag」欄填 v1.4
# tag 欄留空時只建置+上傳 artifact 驗證,不會發 release。
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
tag:
description: '要發佈的版本 tag(例如 v1.4)。留空=只建置驗證、不發 release。'
required: false
default: ''
prerelease:
description: '標記為 pre-release'
type: boolean
default: false
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # 需要完整歷史與 tag 才能產生 changelog
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install PyInstaller
run: pip install pyinstaller
- name: Build exe
run: pyinstaller --noconfirm --onefile --windowed --name KKCardsClassifier KKCardsClassifier.py
- name: Upload build artifact (validation runs)
uses: actions/upload-artifact@v4
with:
name: KKCardsClassifier-exe
path: dist/KKCardsClassifier.exe
- name: Generate changelog from commits
if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.tag != ''
id: changelog
shell: bash
run: |
TARGET="${{ github.event.inputs.tag || github.ref_name }}"
PREV=$(git tag --sort=-creatordate | grep -vx "$TARGET" | head -1)
{
if [ -n "$PREV" ]; then
echo "## What's Changed (since $PREV)"; echo
git log --no-merges --pretty='- %s' "$PREV..HEAD"
else
echo "## What's Changed"; echo
git log --no-merges --pretty='- %s'
fi
} > "$RUNNER_TEMP/notes.md"
echo "path=$RUNNER_TEMP/notes.md" >> "$GITHUB_OUTPUT"
- name: Publish release
if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.tag != ''
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
name: KKCardsClassifier ${{ github.event.inputs.tag || github.ref_name }}
body_path: ${{ steps.changelog.outputs.path }}
generate_release_notes: true
prerelease: ${{ github.event.inputs.prerelease == 'true' }}
files: dist/KKCardsClassifier.exe