Build & Release Bangen #18
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: Build & Release Bangen | |
| on: | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| - "*.*.*" | |
| concurrency: | |
| group: release-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: Build (${{ matrix.name }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| name: linux | |
| - os: windows-latest | |
| name: windows | |
| - os: macos-latest | |
| name: macos | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Cache pip | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/pip | |
| ~/AppData/Local/pip/Cache | |
| key: pip-${{ runner.os }}-${{ hashFiles('requirements*.txt') }} | |
| restore-keys: pip-${{ runner.os }}- | |
| - name: Install system deps (Linux) | |
| if: runner.os == 'Linux' | |
| run: sudo apt-get update && sudo apt-get install -y patchelf | |
| - name: MSVC setup (Windows) | |
| if: runner.os == 'Windows' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Install Python deps | |
| shell: bash | |
| run: | | |
| python -m pip install -U pip wheel nuitka zstandard | |
| [[ -f requirements.txt ]] && pip install -r requirements.txt || true | |
| - name: Write entrypoint | |
| shell: bash | |
| run: | | |
| printf 'from bangen.app import main\nif __name__ == "__main__":\n main()\n' > _entry.py | |
| - name: Build with Nuitka | |
| shell: bash | |
| run: | | |
| python -m nuitka \ | |
| --mode=onefile \ | |
| --assume-yes-for-downloads \ | |
| --output-dir=build \ | |
| --output-filename=bangen \ | |
| --nofollow-import-to=tkinter,unittest,test,distutils,setuptools,pkg_resources \ | |
| --python-flag=no_asserts,no_docstrings,isolated \ | |
| --onefile-tempdir-spec="{CACHE_DIR}/bangen/${{ github.ref_name }}" \ | |
| _entry.py | |
| - name: Package artifact | |
| shell: bash | |
| run: | | |
| mkdir -p dist | |
| NAME="bangen-${{ matrix.name }}-${{ github.ref_name }}" | |
| if [[ "$RUNNER_OS" == "Windows" ]]; then | |
| mv build/bangen.exe dist/"$NAME.exe" | |
| (cd dist && zip "$NAME.zip" "$NAME.exe" && rm "$NAME.exe") | |
| else | |
| mv build/bangen dist/"$NAME" | |
| (cd dist && tar -czf "$NAME.tar.gz" "$NAME" && rm "$NAME") | |
| fi | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.name }}-build | |
| path: dist/* | |
| release: | |
| name: Publish Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: Bangen ${{ github.ref_name }} | |
| files: artifacts/* |