Skip to content

Enhance build workflow with versioning and packaging #2

Enhance build workflow with versioning and packaging

Enhance build workflow with versioning and packaging #2

Workflow file for this run

name: Build Game Updater Executables
on:
push:
branches:
- main
tags:
- 'v*.*.*'
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.11]
steps:
# 1. Checkout repository
- uses: actions/checkout@v4
# 2. Setup Python
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# 3. Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
# 4. Determine version from git tag or branch
- name: Determine version
id: version
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION="${GITHUB_REF#refs/tags/}"
else
VERSION="${GITHUB_REF#refs/heads/}"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
# 5. Build all executables
- name: Build executables
run: |
cd scripts
rm -rf dist build __pycache__
for f in *.py; do
echo "Building $f"
if [[ "$RUNNER_OS" == "Windows" ]]; then
pyinstaller --onefile --noconsole "$f"
else
pyinstaller --onefile "$f"
fi
done
# 6. Package into OS-specific zip
- name: Create ZIP package
run: |
cd scripts/dist
OS="${{ matrix.os }}"
if [[ "$OS" == "windows-latest" ]]; then
ZIP="../../MyGameUpdater-${VERSION}-Windows.zip"
elif [[ "$OS" == "ubuntu-latest" ]]; then
ZIP="../../MyGameUpdater-${VERSION}-Linux.zip"
else
ZIP="../../MyGameUpdater-${VERSION}-Mac.zip"
fi
zip -r "$ZIP" ./*
# 7. Upload artifact (NEW v4 API)
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: MyGameUpdater-${{ matrix.os }}
path: |
MyGameUpdater-${VERSION}-Windows.zip
MyGameUpdater-${VERSION}-Linux.zip
MyGameUpdater-${VERSION}-Mac.zip
if-no-files-found: error