mirror of
https://github.com/derrod/legendary.git
synced 2026-06-22 16:07:11 +00:00
168 lines
3.9 KiB
YAML
168 lines
3.9 KiB
YAML
name: Python
|
|
|
|
on:
|
|
push:
|
|
branches: [ '*' ]
|
|
tags: [ '*.*.*' ]
|
|
pull_request:
|
|
branches: [ '*' ]
|
|
|
|
jobs:
|
|
pyinstaller:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [
|
|
'windows-2025', 'windows-11-arm',
|
|
'macos-15-intel', 'macos-15'
|
|
]
|
|
fail-fast: false
|
|
env:
|
|
UV_SYSTEM_PYTHON: 1
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version-file: "pyproject.toml"
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v7
|
|
with:
|
|
enable-cache: true
|
|
|
|
- name: Dependencies and build tools
|
|
run: uv sync --extra pyinstaller_build --no-install-local
|
|
|
|
- name: Optional dependencies (WebView)
|
|
run: uv sync --extra webview --no-install-local --inexact
|
|
if: runner.os != 'macOS'
|
|
|
|
- name: Set strip option on non-Windows
|
|
id: strip
|
|
run: echo "option=--strip" >> $GITHUB_OUTPUT
|
|
if: runner.os != 'Windows'
|
|
|
|
- name: Build
|
|
working-directory: legendary
|
|
run: uv run --module PyInstaller
|
|
--onefile
|
|
--name legendary
|
|
${{ steps.strip.outputs.option }}
|
|
-i ../assets/windows_icon.ico
|
|
cli.py
|
|
env:
|
|
PYTHONOPTIMIZE: 1
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: ${{ runner.os }}-${{ runner.arch }}-package
|
|
path: legendary/dist/*
|
|
|
|
zipapp:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [
|
|
'ubuntu-24.04', 'ubuntu-24.04-arm'
|
|
]
|
|
fail-fast: false
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version-file: "pyproject.toml"
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v7
|
|
with:
|
|
enable-cache: true
|
|
|
|
- run: mkdir -p build dist
|
|
|
|
- name: Dependencies
|
|
run: uv export --format requirements.txt --no-editable | uv pip install --requirement - --target build
|
|
|
|
- run: cp zipapp_main.py build/__main__.py
|
|
|
|
- name: Build
|
|
run: python -m zipapp
|
|
--output dist/legendary
|
|
--python "/usr/bin/env python3"
|
|
--compress
|
|
build
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: ${{ runner.os }}-${{ runner.arch }}-package
|
|
path: dist/legendary
|
|
|
|
# Publishing
|
|
|
|
pypi:
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: pypi
|
|
if: github.ref_type == 'tag'
|
|
env:
|
|
UV_SYSTEM_PYTHON: 1
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version-file: "pyproject.toml"
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v7
|
|
with:
|
|
enable-cache: true
|
|
|
|
- name: Build
|
|
run: uv build
|
|
|
|
- name: Publish
|
|
run: uv publish
|
|
|
|
release:
|
|
permissions:
|
|
contents: write
|
|
runs-on: ubuntu-latest
|
|
if: github.ref_type == 'tag'
|
|
needs: [pyinstaller, zipapp, pypi]
|
|
steps:
|
|
- name: Download builds
|
|
uses: actions/download-artifact@v8
|
|
|
|
- name: Setup distribution dir
|
|
run: mkdir dist
|
|
|
|
- name: Copy binaries
|
|
run: |
|
|
oses=("Linux" "macOS" "Windows")
|
|
arches=("X64" "ARM64")
|
|
for os in ${oses[@]}; do
|
|
for arch in ${arches[@]}; do
|
|
file="./$os-$arch-package/legendary"*
|
|
if [ -f $file ]; then
|
|
filename=$(basename $file)
|
|
name="${filename%%.*}"
|
|
ext=${filename#*.}
|
|
if [[ "$ext" == "$filename" ]]; then
|
|
ext=""
|
|
else
|
|
ext=".$ext"
|
|
fi
|
|
cp $file "./dist/legendary_${os,}_${arch,,}$ext"
|
|
fi
|
|
done
|
|
done
|
|
|
|
- uses: softprops/action-gh-release@v3
|
|
with:
|
|
draft: true
|
|
generate_release_notes: true
|
|
files: release/legendary*
|
|
|