Build binaries #101
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 binaries | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
compiler: [nuitka, pyinstaller] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
env: | |
BUILD_CERTIFICATE_BASE64: ${{ secrets.MAC_SIGN_CERT }} | |
P12_PASSWORD: ${{ secrets.MAC_SIGN_PASSWORD }} | |
KEYCHAIN_PASSWORD: ${{ secrets.MAC_KEYCHAIN_PASSWORD }} | |
shell: bash | |
run: | | |
export FK_VERSION=$(scripts/common/get-version.sh) | |
echo "FK_VERSION=$FK_VERSION" >> $GITHUB_ENV | |
if [[ "$OSTYPE" == "darwin"* ]]; then | |
scripts/macos/install-create-dmg.sh | |
scripts/macos/install-certificates.sh | |
export BINARY_EXTENSION="" | |
echo "BINARY_EXTENSION=" >> $GITHUB_ENV | |
elif [[ "$OSTYPE" == "msys" ]]; then | |
scripts/windows/install-innosetup.sh | |
export BINARY_EXTENSION=".exe" | |
echo "BINARY_EXTENSION=.exe" >> $GITHUB_ENV | |
else | |
scripts/linux/appimage/install-appimage.sh | |
export BINARY_EXTENSION="" | |
echo "BINARY_EXTENSION=" >> $GITHUB_ENV | |
fi | |
pip install -r requirements.txt | |
if [[ "${{ matrix.compiler}}" == "nuitka" ]]; then | |
pip install nuitka | |
else | |
pip install pyinstaller | |
fi | |
- name: Prepare sources | |
shell: bash | |
run: | | |
scripts/common/generate-resources.sh | |
rm -rf build dist | |
mkdir -p build dist | |
- name: Package builds (PyInstaller) | |
if: ${{ matrix.compiler == 'pyinstaller' }} | |
shell: bash | |
run: | | |
if [[ "$OSTYPE" == "darwin"* ]]; then | |
pyinstaller scripts/common/pyinstaller/normal.spec --distpath=build -- --sign | |
echo "Built PyInstaller for macOS" | |
ls -al build/ | |
else | |
pyinstaller scripts/common/pyinstaller/portable.spec --distpath=build | |
pyinstaller scripts/common/pyinstaller/normal.spec --distpath=build | |
echo "Built PyInstaller for Linux or Windows" | |
ls -al build/ | |
fi | |
- name: Package builds (Nuitka) | |
if: ${{ matrix.compiler == 'nuitka' }} | |
uses: Nuitka/Nuitka-Action@main | |
with: | |
nuitka-version: main | |
script-name: src/fk/desktop/desktop.py | |
mode: ${{ startsWith(matrix.os, 'macOS') && 'app' || 'onefile' }} | |
enable-plugins: pyside6 | |
windows-console-mode: disable | |
windows-icon-from-ico: res/flowkeeper.ico | |
macos-app-icon: flowkeeper.icns | |
macos-signed-app-name: org.flowkeeper.Flowkeeper | |
macos-app-name: Flowkeeper | |
macos-sign-identity: "Developer ID Application: Constantine Kulak (ELWZ9S676C)" | |
macos-app-version: "${{ env.FK_VERSION }}" | |
product-name: Flowkeeper | |
product-version: "${{ env.FK_VERSION }}" | |
file-description: Flowkeeper is a Pomodoro Technique desktop timer for power users | |
copyright: Copyright (c) 2023 Constantine Kulak <[email protected]> | |
output-dir: 'build' | |
output-file: 'Flowkeeper' | |
env: | |
PYTHONPATH: src | |
- name: Create installers | |
env: | |
NOTARIZATION_PASSWORD: ${{ secrets.MAC_NOTARIZATION_PASSWORD }} | |
NOTARIZATION_ID: ${{ secrets.MAC_NOTARIZATION_ID }} | |
NOTARIZATION_TEAM: ${{ secrets.MAC_NOTARIZATION_TEAM }} | |
shell: bash | |
run: | | |
echo "Prepare dist directory" | |
mkdir -p dist/standalone | |
PREFIX="dist/flowkeeper-${FK_VERSION}-${{ matrix.os }}-${{ matrix.compiler }}" | |
echo "Will create artifacts with $PREFIX prefix" | |
if [[ "${{ matrix.compiler}}" == "nuitka" ]]; then | |
if [[ "$OSTYPE" == "darwin"* ]]; then | |
echo "macOS doesn't support portable binaries" | |
mv build/desktop.app dist/standalone/Flowkeeper.app | |
else | |
mv build/Flowkeeper* $PREFIX-portable${BINARY_EXTENSION} | |
mv build/desktop.dist/* dist/standalone | |
fi | |
if [[ "$OSTYPE" == "linux"* ]]; then | |
mv dist/standalone/Flowkeeper.bin dist/standalone/Flowkeeper | |
fi | |
else | |
if [[ "$OSTYPE" == "darwin"* ]]; then | |
echo "macOS doesn't support portable binaries" | |
mv build/Flowkeeper.app dist/standalone | |
else | |
mv build/Flowkeeper${BINARY_EXTENSION} $PREFIX-portable${BINARY_EXTENSION} | |
mv build/flowkeeper/* dist/standalone | |
fi | |
fi | |
echo "Moved ${{ matrix.compiler }} binaries to dist/standalone" | |
tree dist/ | |
if [[ "$OSTYPE" == "darwin"* ]]; then | |
echo "Building macOS DMG installer" | |
scripts/macos/create-dmg.sh | |
scripts/macos/notarize-dmg.sh | |
mv dist/Flowkeeper.dmg "$PREFIX-installer.dmg" | |
elif [[ "$OSTYPE" == "msys" ]]; then | |
echo "Building Windows setup.exe installer" | |
scripts/windows/package-installer.sh | |
mv dist/setup.exe "$PREFIX-installer.exe" | |
else | |
echo "Building Debian "fat" DEB package" | |
scripts/linux/debian/package-deb.sh | |
mv dist/flowkeeper.deb "$PREFIX-package.deb" | |
echo "Building Debian "lean" DEB package" | |
scripts/linux/debian/package-deb-min.sh | |
mv dist/flowkeeper-min.deb "$PREFIX-min-package.deb" | |
# Temporarily disable AppImage build | |
# echo "Building AppImage package" | |
# scripts/linux/appimage/package-appimage.sh | |
# mv dist/org.flowkeeper.Flowkeeper.AppImage "$PREFIX-portable.AppImage" | |
fi | |
echo "Zipping the standalone directory" | |
cd dist/standalone | |
if [[ "$OSTYPE" == "msys" ]]; then | |
echo "No zip on Windows" | |
powershell Compress-Archive . ../../$PREFIX-standalone.zip | |
else | |
zip -9 -r "../../$PREFIX-standalone.zip" ./* | |
fi | |
cd ../.. | |
echo "Cleaning /dist up" | |
rm -rf dist/standalone | |
- name: Archive the binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist-${{ matrix.os }}-${{ matrix.compiler }}-all | |
path: | | |
dist |