Skip to content

make

make #2

Workflow file for this run

# Make executable files for multiple operating systems using Nuitka
# ref: https://nuitka.net/doc/user-manual.html#use-case-7-building-with-github-workflows
name: make
on:
workflow_dispatch:
inputs:
scriptname:
description: 'Path to python script to generate executable of'
required: true
default: 'src/ezsam/gui/app.py'
name:
description: 'Name of generated executable'
required: true
default: ezsam
version:
description: 'Semantic version string, must be integers x.y.z'
required: true
default: 0.0.0
description:
description: 'Description embedded in executable'
required: true
default: 'ezsam is a tool to extract objects from images or video via text prompt - info at https://www.ezsam.org'
datadir:
description: 'Directory containing assets to embed into the executable'
required: true
default: 'src/ezsam/gui/assets'
all_platforms:
description: 'Run workflow on all supported platforms'
required: true
type: boolean
default: true
platform:
description: 'Single platform to use if not all platforms'
required: true
type: choice
options:
- ubuntu-latest
- windows-latest
default: ubuntu-latest
concurrency:
group: 'make'
cancel-in-progress: true
jobs:
make-executable:
timeout-minutes: 180
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
exclude:
- os: ${{ github.event.inputs.all_platforms != 'true' && github.event.inputs.platform != 'ubuntu-latest' && 'ubuntu-latest' }}
- os: ${{ github.event.inputs.all_platforms != 'true' && github.event.inputs.platform != 'windows-latest' && 'windows-latest' }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pdm
uses: pdm-project/setup-pdm@v4
- name: Restore cached venv
id: cache-venv-restore
uses: actions/cache/restore@v4
with:
path: |
.venv
key: ${{ runner.os }}-venv
- name: Install dependencies
run: |
pdm install-all
shell: bash
- name: Save venv to cache
id: cache-venv-save
uses: actions/cache/save@v4
with:
path: |
.venv
key: ${{ steps.cache-venv-restore.outputs.cache-primary-key }}
- name: Build executable with Nuitka
run: |
pdm make-nuitka "${{ github.event.inputs.name }}" "${{ github.event.inputs.scriptname }}" \
"${{ github.event.inputs.version }}" dist \
"${{ github.event.inputs.datadir }}" "${{ github.event.inputs.description }}"
shell: bash
- name: Fix executable
# Preserve executable permissions on Linux.
# ref: https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss
# ref: https://stackoverflow.com/a/57948488
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
cd dist
tar -cvf ${{ github.event.inputs.name }}-${{ github.event.inputs.version }}.tar ${{ github.event.inputs.name }}-${{ github.event.inputs.version }}
rm -rf ${{ github.event.inputs.name }}-${{ github.event.inputs.version }}
cd onefile
tar -cvf ${{ github.event.inputs.name }}.tar ${{ github.event.inputs.name }}
cd ../..
elif [ "$RUNNER_OS" == "Windows" ]; then
echo "Nothing to fix"
fi
shell: bash
- name: Upload standalone archive
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.inputs.name }}-${{ github.event.inputs.version }}-${{ runner.os }}
path: |
dist/${{ github.event.inputs.name }}-${{ github.event.inputs.version }}.tar
dist/${{ github.event.inputs.name }}-${{ github.event.inputs.version }}/
- name: Upload onefile executable
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.inputs.name }}-${{ github.event.inputs.version }}-${{ runner.os }}-onefile
path: |
dist/onefile/*.tar
dist/onefile/*.exe
compression-level: 0
- name: Upload onefile executable checksum
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.inputs.name }}-${{ github.event.inputs.version }}-${{ runner.os }}-onefile-checksum
path: |
dist/onefile/*.sha256
compression-level: 0