Files
e-ink-dash/.gitea/workflows/build-exe.yml
T
Kareem Horstink 68a9c4047b
Build Server .exe / build (push) Failing after 2m9s
ci: updated build-exe to hopefully work
2026-07-01 11:52:22 +00:00

141 lines
4.9 KiB
YAML

name: Build Server .exe
on:
push:
branches: [main]
paths:
- "server/**"
- ".gitea/workflows/build-exe.yml"
pull_request:
branches: [main]
paths:
- "server/**"
- ".gitea/workflows/build-exe.yml"
workflow_dispatch:
env:
WINEPREFIX: ${{ github.workspace }}/wine-prefix
WINEPYTHON: ${{ github.workspace }}/wine-prefix/drive_c/Python312/python.exe
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Wine
run: |
sudo dpkg --add-architecture i386
sudo mkdir -p /etc/apt/keyrings
sudo wget -qO /etc/apt/keyrings/winehq-archive.key \
https://dl.winehq.org/wine-builds/winehq.key
# Use the actual Ubuntu codename of the runner
CODENAME=$(lsb_release -cs)
sudo wget -qO /etc/apt/sources.list.d/winehq-${CODENAME}.sources \
"https://dl.winehq.org/wine-builds/ubuntu/dists/${CODENAME}/winehq-${CODENAME}.sources"
sudo apt-get update
sudo apt-get install --install-recommends winehq-stable -y
- name: Set up Wine prefix
run: |
mkdir -p "$WINEPREFIX"
wineboot --init
- name: Download Python installer
run: |
wget -q \
https://www.python.org/ftp/python/3.12.4/python-3.12.4-amd64.exe \
-O /tmp/python.exe
- name: Install Python in Wine
run: |
wine /tmp/python.exe \
/quiet \
InstallAllUsers=1 \
PrependPath=1 \
Include_test=0
rm /tmp/python.exe
- name: Install Python dependencies
run: |
cd server
wine "$WINEPYTHON" -m pip install --upgrade pip
wine "$WINEPYTHON" -m pip install -r requirements.txt
- name: Run tests
run: |
cd server
wine "$WINEPYTHON" -m pip install pytest pytest-asyncio
wine "$WINEPYTHON" -m pytest tests/ -v
- name: Build .exe with PyInstaller
run: |
cd server
wine "$WINEPYTHON" -m PyInstaller \
tray_wrapper.py \
--name PaperDash \
--onefile \
--noconsole \
--clean
ls -la dist/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: PaperDash.exe
path: server/dist/PaperDash.exe
if-no-files-found: error
- name: Create or update draft release
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: rolling-draft
run: |
# API base URL (e.g. https://your-gitea.example.com/api/v1)
API="${{ github.api_url }}/repos/${{ github.repository }}"
# Check if release for this tag already exists
RESPONSE=$(curl -sS -H "Authorization: token $GITEA_TOKEN" \
"$API/releases/tags/$RELEASE_TAG")
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id // empty')
if [ -n "$RELEASE_ID" ]; then
echo "Updating existing draft release (ID $RELEASE_ID)"
# Update draft status and body
curl -sS -X PATCH -H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"draft": true,
"name": "Draft (latest build)",
"body": "Latest PaperDash server build from commit '"${{ github.sha }}"'. Built on Linux via Wine + PyInstaller. Edit tag, name, and notes before publishing."
}' \
"$API/releases/$RELEASE_ID"
# Delete existing assets of this release (so we can upload a fresh one)
ASSETS=$(curl -sS -H "Authorization: token $GITEA_TOKEN" \
"$API/releases/$RELEASE_ID/assets")
for asset_id in $(echo "$ASSETS" | jq -r '.[].id'); do
curl -sS -X DELETE -H "Authorization: token $GITEA_TOKEN" \
"$API/releases/$RELEASE_ID/assets/$asset_id"
done
else
echo "Creating new draft release"
RESPONSE=$(curl -sS -X POST -H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"tag_name": "'"$RELEASE_TAG"'",
"draft": true,
"name": "Draft (latest build)",
"body": "Latest PaperDash server build from commit '"${{ github.sha }}"'. Built on Linux via Wine + PyInstaller. Edit tag, name, and notes before publishing."
}' \
"$API/releases")
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')
fi
# Upload the .exe as a release asset
echo "Uploading PaperDash.exe to release $RELEASE_ID"
curl -sS -X POST -H "Authorization: token $GITEA_TOKEN" \
-F "attachment=@server/dist/PaperDash.exe;type=application/vnd.microsoft.portable-executable" \
"$API/releases/$RELEASE_ID/assets"