270 lines
8.9 KiB
YAML
270 lines
8.9 KiB
YAML
name: Build Multi-Platform Binaries
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build-windows:
|
|
runs-on: windows-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.12
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install Poetry
|
|
uses: snok/install-poetry@v1
|
|
with:
|
|
version: latest
|
|
virtualenvs-create: true
|
|
virtualenvs-in-project: true
|
|
|
|
- name: Ensure Poetry is on PATH (Windows)
|
|
shell: pwsh
|
|
run: |
|
|
$poetryPath = Join-Path $env:USERPROFILE ".local\bin"
|
|
Write-Output $poetryPath >> $Env:GITHUB_PATH
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
poetry install
|
|
|
|
- name: Build Windows executable
|
|
run: |
|
|
poetry run pyinstaller --onefile --windowed --icon=icon_media/robot_files_256.ico --name android-file-handler src/main.py
|
|
|
|
- name: Upload Windows artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: windows-binary
|
|
path: dist/android-file-handler.exe
|
|
|
|
build-debian:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: python:3.12-slim
|
|
steps:
|
|
- name: Install system dependencies
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y curl git build-essential ruby ruby-dev gcc make build-essential zlib1g-dev
|
|
gem install --no-document fpm
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.12
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install Poetry
|
|
uses: snok/install-poetry@v1
|
|
with:
|
|
version: latest
|
|
virtualenvs-create: true
|
|
virtualenvs-in-project: true
|
|
|
|
- name: Configure Poetry
|
|
run: |
|
|
echo 'export PATH="$HOME/.local/bin:$PATH"' >> $GITHUB_ENV
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
poetry config virtualenvs.create true
|
|
poetry config virtualenvs.in-project true
|
|
|
|
- name: Install dependencies & build executable
|
|
run: |
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
poetry env use python3.12 || true
|
|
poetry install
|
|
poetry run pyinstaller --onefile --icon=icon_media/robot_files_256.png --name android-file-handler src/main.py
|
|
|
|
- name: Package .deb (fpm)
|
|
run: |
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
VERSION="$(poetry version -s)"
|
|
mkdir -p dist
|
|
chmod +x dist/android-file-handler
|
|
fpm -s dir -t deb -n android-file-handler -v "$VERSION" --architecture amd64 --prefix /usr/local/bin -p "dist/android-file-handler_${VERSION}_amd64.deb" dist/android-file-handler
|
|
|
|
- name: Upload Debian .deb
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: debian-package
|
|
path: dist/*.deb
|
|
|
|
build-arch:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: archlinux:latest
|
|
steps:
|
|
- name: Install system dependencies (Arch)
|
|
run: |
|
|
pacman -Syu --noconfirm
|
|
pacman -S --noconfirm python python-pip curl git base-devel ruby
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.12
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install Poetry
|
|
uses: snok/install-poetry@v1
|
|
with:
|
|
version: latest
|
|
virtualenvs-create: true
|
|
virtualenvs-in-project: true
|
|
|
|
- name: Configure Poetry
|
|
run: |
|
|
echo 'export PATH="$HOME/.local/bin:$PATH"' >> $GITHUB_ENV
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
poetry config virtualenvs.create true
|
|
poetry config virtualenvs.in-project true
|
|
|
|
- name: Install dependencies & build executable
|
|
run: |
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
poetry install
|
|
poetry run pyinstaller --onefile --icon=icon_media/robot_files_256.png --name android-file-handler src/main.py
|
|
|
|
- name: Install fpm (gem) and package pacman
|
|
run: |
|
|
# install fpm (gem)
|
|
gem install --no-document fpm
|
|
|
|
# compute user gem bin dir dynamically (avoids hardcoding ruby version)
|
|
GEM_BIN="$(ruby -e 'print Gem.user_dir')/bin"
|
|
|
|
echo "User gem bin: $GEM_BIN"
|
|
|
|
# add Poetry user bin (common) and Ruby gem bin to PATH for subsequent steps
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
echo "$GEM_BIN" >> $GITHUB_PATH
|
|
|
|
# make available immediately in this step too (optional)
|
|
export PATH="$HOME/.local/bin:$GEM_BIN:$PATH"
|
|
VERSION="$(poetry version -s)"
|
|
mkdir -p dist
|
|
chmod +x dist/android-file-handler
|
|
fpm -s dir -t pacman -n android-file-handler -v "$VERSION" --architecture x86_64 --prefix /usr/local/bin -p "dist/android-file-handler-${VERSION}-1-x86_64.pkg.tar.zst" dist/android-file-handler
|
|
|
|
- name: Upload Arch package
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: arch-package
|
|
path: dist/*.pkg.tar.*
|
|
|
|
build-rocky:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: rockylinux:9
|
|
steps:
|
|
- name: Install system build dependencies for Python and pyenv (enable CRB for -devel pkgs)
|
|
run: |
|
|
dnf -y install dnf-plugins-core
|
|
dnf config-manager --set-enabled crb
|
|
dnf -y update
|
|
dnf -y install git gcc make openssl-devel bzip2-devel libffi-devel zlib-devel xz-devel \
|
|
readline-devel sqlite-devel tk-devel gdbm-devel libuuid-devel patch ruby ruby-devel rubygems rpm-build
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install pyenv and build Python 3.12.11 (idempotent)
|
|
env:
|
|
PYENV_ROOT: ${{ github.workspace }}/.pyenv_temp
|
|
run: |
|
|
export PYENV_ROOT="$HOME/.pyenv"
|
|
export PATH="$PYENV_ROOT/bin:$PATH"
|
|
if [ -d "$PYENV_ROOT/.git" ]; then
|
|
cd "$PYENV_ROOT"
|
|
git fetch --all --prune
|
|
git reset --hard origin/master || true
|
|
cd -
|
|
else
|
|
git clone https://github.com/pyenv/pyenv.git "$PYENV_ROOT"
|
|
fi
|
|
if [ -d "$PYENV_ROOT/plugins/python-build/.git" ]; then
|
|
cd "$PYENV_ROOT/plugins/python-build"
|
|
git fetch --all --prune
|
|
git reset --hard origin/master || true
|
|
cd -
|
|
else
|
|
git clone https://github.com/pyenv/pyenv-build.git "$PYENV_ROOT/plugins/python-build"
|
|
fi
|
|
echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV
|
|
echo "PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH" >> $GITHUB_ENV
|
|
export PATH="$PYENV_ROOT/bin:$PATH"
|
|
eval "$($PYENV_ROOT/bin/pyenv init -)"
|
|
$PYENV_ROOT/bin/pyenv install -s 3.12.11
|
|
$PYENV_ROOT/bin/pyenv global 3.12.11
|
|
python --version
|
|
pip --version
|
|
|
|
- name: Install Poetry (use action)
|
|
uses: snok/install-poetry@v1
|
|
with:
|
|
version: latest
|
|
virtualenvs-create: true
|
|
virtualenvs-in-project: true
|
|
|
|
- name: Configure Poetry
|
|
run: |
|
|
echo 'export PATH="$HOME/.local/bin:$PATH"' >> $GITHUB_ENV
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
poetry config virtualenvs.create true
|
|
poetry config virtualenvs.in-project true
|
|
|
|
- name: Install dependencies & build executable
|
|
run: |
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
poetry env use 3.12.11 || true
|
|
poetry install
|
|
poetry run pyinstaller --onefile --icon=icon_media/robot_files_256.png --name android-file-handler src/main.py
|
|
|
|
- name: Install fpm (gem) and package .rpm
|
|
run: |
|
|
gem install --no-document fpm
|
|
VERSION="$(poetry version -s)"
|
|
mkdir -p dist
|
|
chmod +x dist/android-file-handler
|
|
fpm -s dir -t rpm -n android-file-handler -v "$VERSION" --architecture x86_64 --prefix /usr/local/bin -p "dist/android-file-handler-${VERSION}-1.x86_64.rpm" dist/android-file-handler
|
|
|
|
- name: Upload Rocky RPM
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: rocky-package
|
|
path: dist/*.rpm
|
|
|
|
create-release:
|
|
needs: [build-windows, build-debian, build-arch, build-rocky]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
merge-multiple: true
|
|
path: ./binaries
|
|
|
|
- name: Create Release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
files: |
|
|
./binaries/android-file-handler.exe
|
|
./binaries/android-file-handler_*.deb
|
|
./binaries/android-file-handler-*.rpm
|
|
./binaries/android-file-handler-*-x86_64.pkg.tar.*
|
|
draft: false
|
|
prerelease: false
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |