From 3c194523602c077d9449273b6b51be8b3eab7796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Lidwin?= Date: Wed, 3 Jun 2026 19:27:51 +0200 Subject: [PATCH] ci: split actions and move release to ubuntu-slim --- .github/workflows/build-base.yml | 97 +++++++++++++++++++ .github/workflows/python.yml | 160 +------------------------------ .github/workflows/release.yml | 69 +++++++++++++ 3 files changed, 168 insertions(+), 158 deletions(-) create mode 100644 .github/workflows/build-base.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build-base.yml b/.github/workflows/build-base.yml new file mode 100644 index 0000000..0e30a49 --- /dev/null +++ b/.github/workflows/build-base.yml @@ -0,0 +1,97 @@ +name: Build Base + +on: + workflow_call: + +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 \ No newline at end of file diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 3ecd1fb..e2980f5 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -3,166 +3,10 @@ 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* + build: + uses: ./.github/workflows/build-base.yml \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9e36ab9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,69 @@ +name: Release + +on: + push: + tags: [ '*.*.*' ] + +jobs: + build: + uses: ./.github/workflows/build-base.yml + + pypi: + runs-on: ubuntu-latest + environment: pypi + 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-slim + needs: [build, 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) + 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: dist/legendary* \ No newline at end of file