mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-09-22 04:50:46 +02:00
87 lines
2.6 KiB
YAML
87 lines
2.6 KiB
YAML
name: Create GitHub Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-windows:
|
|
name: Build Windows EXE
|
|
runs-on: windows-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install dependencies
|
|
shell: powershell
|
|
run: |
|
|
python -m pip install --upgrade pip wheel setuptools
|
|
if (Test-Path 'requirements.txt') { pip install -r requirements.txt }
|
|
pip install pyinstaller
|
|
|
|
- name: Build executable (PyInstaller)
|
|
shell: powershell
|
|
run: |
|
|
# Build using spec for reliable packaging
|
|
pyinstaller mtg_deckbuilder.spec
|
|
if (!(Test-Path dist/mtg-deckbuilder.exe)) {
|
|
Write-Host 'Spec build failed; retrying simple build with --paths code'
|
|
pyinstaller --onefile --name mtg-deckbuilder --paths code code/main.py
|
|
}
|
|
if (!(Test-Path dist/mtg-deckbuilder.exe)) { throw 'Build failed: dist/mtg-deckbuilder.exe not found' }
|
|
|
|
- name: Upload artifact (Windows EXE)
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: mtg-deckbuilder-windows
|
|
path: dist/mtg-deckbuilder.exe
|
|
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
needs: build-windows
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Prepare release notes
|
|
id: notes
|
|
shell: bash
|
|
run: |
|
|
VERSION_REF="${GITHUB_REF##*/}" # e.g. v1.2.3
|
|
VERSION_NO_V="${VERSION_REF#v}"
|
|
TEMPLATE="RELEASE_NOTES_TEMPLATE.md"
|
|
if [ -f "$TEMPLATE" ]; then
|
|
sed "s/\${VERSION}/${VERSION_REF}/g" "$TEMPLATE" > RELEASE_NOTES.md
|
|
else
|
|
echo "# MTG Python Deckbuilder ${VERSION_REF}" > RELEASE_NOTES.md
|
|
echo >> RELEASE_NOTES.md
|
|
echo "Automated release." >> RELEASE_NOTES.md
|
|
fi
|
|
echo "version=$VERSION_REF" >> $GITHUB_OUTPUT
|
|
echo "notes_file=RELEASE_NOTES.md" >> $GITHUB_OUTPUT
|
|
|
|
- name: Download build artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: mtg-deckbuilder-windows
|
|
path: artifacts
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ steps.notes.outputs.version }}
|
|
name: ${{ steps.notes.outputs.version }}
|
|
body_path: ${{ steps.notes.outputs.notes_file }}
|
|
files: |
|
|
artifacts/mtg-deckbuilder.exe
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|