Release #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |