Build binary for device #161
Workflow file for this run
This file contains 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 | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
remote: | |
name: Build for ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout the Git repository | |
uses: actions/checkout@v4 | |
- name: ccache | |
uses: hendrikmuhs/[email protected] | |
with: | |
key: ${{ github.job }}-${{ matrix.os }} | |
- name: Move .ccache | |
shell: bash | |
run: | | |
mkdir -p "$nuitka_cache" .ccache | |
mv .ccache "$nuitka_cache/ccache" | |
env: | |
nuitka_cache: ${{ github.workspace }}/.nuitka | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.8' | |
cache: 'pip' | |
cache-dependency-path: | | |
**/requirements*.txt | |
- name: Install dependencies | |
shell: bash | |
run: | | |
pip install wheel | |
pip install -r requirements.remote.txt | |
pip install nuitka | |
- name: Build codexctl | |
shell: bash | |
run: | | |
mkdir -p dist | |
NUITKA_CACHE_DIR="$nuitka_cache" \ | |
python -m nuitka \ | |
--enable-plugin=pylint-warnings \ | |
--onefile \ | |
--lto=yes \ | |
--assume-yes-for-downloads \ | |
--remove-output \ | |
--output-dir=dist \ | |
codexctl.py | |
env: | |
nuitka_cache: ${{ github.workspace }}/.nuitka | |
- name: Move .ccache | |
shell: bash | |
run: | | |
mv "$nuitka_cache/ccache" .ccache | |
env: | |
nuitka_cache: ${{ github.workspace }}/.nuitka | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.os }} | |
path: dist | |
if-no-files-found: error | |
device: | |
name: Build for remarkable ${{ matrix.fw_version }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
fw_version: ['2.15.1'] | |
steps: | |
- name: Checkout the codexctl repository | |
uses: actions/checkout@v4 | |
- uses: Eeems-Org/run-in-remarkable-action@v1 | |
with: | |
clean_cache: true | |
fw_version: ${{ matrix.fw_version }} | |
setup: | | |
set -e | |
opkg update | |
opkg install perl | |
src_path=/home/root/.local/share/debian | |
debootstrap_path=/home/root/.local/share/debootstrap | |
wget \ | |
https://salsa.debian.org/installer-team/debootstrap/-/archive/master/debootstrap-master.tar.gz \ | |
--output-document=/tmp/debootstrap.tar.gz | |
mkdir -p "$debootstrap_path" | |
tar -xf /tmp/debootstrap.tar.gz -C "$debootstrap_path" | |
rm /tmp/debootstrap.tar.gz | |
if ! DEBOOTSTRAP_DIR="${debootstrap_path}/debootstrap-master" \ | |
"${debootstrap_path}/debootstrap-master/debootstrap" \ | |
--arch=armhf \ | |
--variant=minbase \ | |
--foreign \ | |
bullseye "$src_path"; then | |
cat "${src_path}/debootstrap/debootstrap.log" | |
exit 1 | |
fi | |
if ! chroot "$src_path" /debootstrap/debootstrap --second-stage; then | |
cat "${src_path}/debootstrap/debootstrap.log" | |
exit 1 | |
fi | |
mkdir -p "${src_path}/usr/sbin" | |
cat > "${src_path}/usr/sbin/policy-rc.d" << EOF | |
#!/bin/sh | |
exit 101 | |
EOF | |
chmod a+x "${src_path}/usr/sbin/policy-rc.d" | |
ln -sf /bin/true "${src_path}/usr/bin/ischroot" | |
cp /etc/hosts "${src_path}/etc/hosts" | |
cp /etc/resolv.conf "${src_path}/etc/resolv.conf" | |
ln -sf /root "${src_path}/home/root" | |
mount --bind /dev "${src_path}/dev" | |
mount --bind /dev/pts "${src_path}/dev/pts" | |
mount --bind /proc "${src_path}/proc" | |
mount --bind /sys "${src_path}/sys" | |
mount --bind /run "${src_path}/run" | |
mount -t tmpfs tmpfs "${src_path}/tmp" | |
mount --bind / "${src_path}/mnt/remarkable" | |
mount --bind /home "${src_path}/mnt/remarkable/home" | |
chroot "$src_path" bash -x <<'EOF' | |
set -e | |
apt install -y ca-certificates | |
apt install -y \ | |
python3-dev \ | |
libffi-dev \ | |
python3-pip \ | |
python3-venv | |
python3 -m venv /opt/lib/nuitka | |
source /opt/lib/nuitka/bin/activate | |
pip install nuitka | |
EOF | |
run: | | |
set -eu | |
src_path=/home/root/.local/share/debian | |
chroot "$src_path" bash -x <<'EOF' | |
set -e | |
source /opt/lib/nuitka/bin/activate | |
pip install -r requirements.txt | |
nuitka3 \ | |
--onefile \ | |
--lto=yes \ | |
--jobs=2 \ | |
--output-filename=codexctl \ | |
--output-dir=dist \ | |
codexctl.py | |
EOF | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: remarkable-${{ matrix.fw_version }} | |
path: dist/codexctl | |
if-no-files-found: error | |
release: | |
name: Release | |
needs: [remote,device] | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
permissions: | |
contents: write | |
steps: | |
- name: Set current date as env variable | |
run: | | |
echo "NAME=$(date +'%Y-%m-%d %H:%M')" >> $GITHUB_ENV | |
echo "TAG=$(date +%s)" >> $GITHUB_ENV | |
- uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: Rename artifacts | |
run: | | |
ls artifacts | while read artifact; do | |
pushd artifacts/${artifact} | |
zip -r ../${artifact}.zip . | |
popd | |
done | |
- uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "artifacts/*.zip" | |
name: ${{ env.NAME }} | |
tag: ${{ env.TAG }} | |
commit: ${{ github.sha }} | |
generateReleaseNotes: true | |
makeLatest: true |