250 lines
7.2 KiB
YAML
250 lines
7.2 KiB
YAML
---
|
|
name: Cross-Compile Binaries
|
|
|
|
"on":
|
|
"workflow_dispatch":
|
|
push:
|
|
branches:
|
|
- '*'
|
|
paths:
|
|
- 'src/**'
|
|
- 'go.**'
|
|
schedule:
|
|
- cron: '0 0 * * 6'
|
|
|
|
env:
|
|
py_down_url: https://www.python.org/ftp/python/3.13.12/python-3.13.12-embed-amd64.zip
|
|
get_pip_url: https://bootstrap.pypa.io/get-pip.py
|
|
|
|
jobs:
|
|
prepare-linux:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
steps:
|
|
- name: Checkout and pull the code
|
|
uses: actions/checkout@v6
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Set the Python programming language
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '3.13'
|
|
cache: 'pip'
|
|
|
|
- name: Install python dependencies
|
|
run: |
|
|
cd ./meshbook
|
|
|
|
pip install -r ./requirements.txt
|
|
pip install pyinstaller
|
|
|
|
- name: Compile the python binary
|
|
run: |
|
|
cd ./meshbook
|
|
|
|
pyinstaller \
|
|
--onefile \
|
|
--name meshbook \
|
|
--distpath /dist \
|
|
meshbook.py
|
|
|
|
- name: Upload binaries as artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: linux-bin
|
|
path: /dist
|
|
|
|
prepare-windows:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
steps:
|
|
- name: Checkout and pull the code
|
|
uses: actions/checkout@v6
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Set the Wine Windows Emulation program up
|
|
# https://gitlab.winehq.org/wine/wine/-/wikis/Debian-Ubuntu
|
|
run: |
|
|
mv /etc/apt/sources.list.d/microsoft-prod.list /etc/apt/sources.list.d/microsoft-prod.list.disabled
|
|
|
|
until apt-get update; do
|
|
echo -e "-----\napt-get update failed, retrying in 1s...\n-----"
|
|
sleep 1
|
|
done
|
|
|
|
mkdir -pm755 /etc/apt/keyrings
|
|
wget -O - https://dl.winehq.org/wine-builds/winehq.key | sudo gpg --dearmor -o /etc/apt/keyrings/winehq-archive.key -
|
|
|
|
dpkg --add-architecture i386
|
|
wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/noble/winehq-noble.sources
|
|
|
|
until apt-get update; do
|
|
echo -e "-----\napt-get update failed, retrying in 1s...\n-----"
|
|
sleep 1
|
|
done
|
|
apt-get install -y --install-recommends winehq-devel
|
|
wine --version
|
|
|
|
- name: Install python under wine
|
|
run: |
|
|
cd ./meshbook
|
|
|
|
export PYTHONHOME=/root/meshbook/python-win
|
|
export PYTHONPATH=/root/meshbook/python-win/Lib/site-packages
|
|
|
|
wget ${{ env.py_down_url }} -O ./python.zip
|
|
unzip ./python.zip -d ./python-win
|
|
sed -i 's/^#\s*import site/import site/' ./python-win/python313._pth
|
|
|
|
wget ${{ env.get_pip_url }} -O ./get-pip.py
|
|
wine ./python-win/python.exe ./get-pip.py
|
|
|
|
wine ./python-win/python.exe -m pip install --upgrade pip
|
|
wine ./python-win/python.exe -m pip install -r ./requirements.txt
|
|
wine ./python-win/python.exe -m pip install pyinstaller
|
|
|
|
- name: Compile the binary with python wine
|
|
run: |
|
|
cd ./meshbook
|
|
|
|
wine ./python-win/python.exe -m PyInstaller \
|
|
--onefile \
|
|
--name meshbook \
|
|
--distpath /dist \
|
|
meshbook.py
|
|
|
|
- name: Upload binaries as artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: windows-bin
|
|
path: /dist
|
|
|
|
compile-linux:
|
|
runs-on: ubuntu-latest
|
|
needs: prepare-linux
|
|
strategy:
|
|
fail-fast: false
|
|
steps:
|
|
- name: Checkout and pull the code
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: linux-bin
|
|
|
|
- name: Setup the Go programming language
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version: 'stable'
|
|
|
|
- name: Install build dependencies
|
|
run: |
|
|
mv /etc/apt/sources.list.d/microsoft-prod.list \
|
|
/etc/apt/sources.list.d/microsoft-prod.list.disabled
|
|
|
|
until apt-get update; do
|
|
echo -e "-----\napt-get update failed, retrying in 1s...\n-----"
|
|
sleep 1s
|
|
done
|
|
|
|
apt-get install -y \
|
|
build-essential libgl1-mesa-dev libx11-dev libxrandr-dev \
|
|
libxi-dev libxcursor-dev libxinerama-dev libglfw3-dev \
|
|
libxxf86vm-dev
|
|
|
|
- name: Compile the fyne application for native Linux
|
|
run: |
|
|
export CGO_ENABLED=1
|
|
export CC=gcc
|
|
export CXX=g++
|
|
export GOOS=linux
|
|
export GOARCH=amd64
|
|
go build -o ./patchworks ./src
|
|
|
|
- name: upload the building actifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: package-linux64
|
|
path: |
|
|
./patchworks
|
|
retention-days: 7
|
|
overwrite: true
|
|
|
|
compile-windows:
|
|
runs-on: ubuntu-latest
|
|
needs: prepare-windows
|
|
strategy:
|
|
fail-fast: false
|
|
steps:
|
|
- name: Checkout and pull the code
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: windows-bin
|
|
|
|
- name: Setup the Go programming language
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version: 'stable'
|
|
|
|
- name: Install build dependencies
|
|
run: |
|
|
mv /etc/apt/sources.list.d/microsoft-prod.list \
|
|
/etc/apt/sources.list.d/microsoft-prod.list.disabled
|
|
|
|
until apt-get update; do
|
|
echo -e "-----\napt-get update failed, retrying in 1s...\n-----"
|
|
sleep 1s
|
|
done
|
|
|
|
apt-get install -y \
|
|
build-essential libgl1-mesa-dev libx11-dev libxrandr-dev \
|
|
libxi-dev libxcursor-dev libxinerama-dev libglfw3-dev \
|
|
libxxf86vm-dev gcc-mingw-w64 gcc-multilib
|
|
|
|
- name: Install go binary
|
|
run: |
|
|
go install github.com/tc-hib/go-winres@latest
|
|
env:
|
|
GOBIN: /usr/local/bin
|
|
|
|
- name: Compile the fyne application for Windows
|
|
run: |
|
|
export CGO_ENABLED=1
|
|
export GOOS=windows
|
|
export GOARCH=amd64
|
|
export CC=x86_64-w64-mingw32-gcc
|
|
export CXX=x86_64-w64-mingw32-g++
|
|
export CGO_LDFLAGS="-static-libgcc -static-libstdc++"
|
|
go-winres simply --icon ./src/icon.ico --manifest gui
|
|
mv *.syso ./src
|
|
go build -o ./patchworks.exe -ldflags -H=windowsgui ./src
|
|
|
|
- name: Compile the fyne application DEBUG style for Windows
|
|
run: |
|
|
export CGO_ENABLED=1
|
|
export GOOS=windows
|
|
export GOARCH=amd64
|
|
export CC=x86_64-w64-mingw32-gcc
|
|
export CXX=x86_64-w64-mingw32-g++
|
|
export CGO_LDFLAGS="-static-libgcc -static-libstdc++"
|
|
go-winres simply --icon ./src/icon.ico --manifest gui
|
|
mv *.syso ./src
|
|
go build -o ./patchworks-debug.exe ./src
|
|
|
|
- name: upload the building actifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: package-win64
|
|
path: |
|
|
./*.exe
|
|
retention-days: 7
|
|
overwrite: true
|