Skip to content

Build & Release Bangen #19

Build & Release Bangen

Build & Release Bangen #19

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: Cache Nuitka
uses: actions/cache@v4
with:
path: ~/.cache/Nuitka
key: nuitka-${{ runner.os }}-${{ hashFiles('**/*.py') }}
restore-keys: nuitka-${{ runner.os }}-
- name: Install system deps (Linux)
if: runner.os == 'Linux'
run: 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: Build with Nuitka
shell: bash
run: |
printf 'from bangen.app import main\nif __name__ == "__main__":\n main()\n' > _entry.py
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"
powershell -Command "Compress-Archive -Path dist\\$NAME.exe -DestinationPath dist\\$NAME.zip"
rm dist/"$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/*
retention-days: 1
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
- name: Generate checksums
run: |
cd artifacts
sha256sum * > SHA256SUMS.txt
- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Bangen ${{ github.ref_name }}
files: artifacts/*