Merge pull request #100 from macarooni-man/dev #822
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: Compiler | |
on: | |
push: null | |
jobs: | |
# Setup and test variables from the code | |
setup-env: | |
name: Setup environment | |
runs-on: ubuntu-latest | |
outputs: | |
APP_VERSION: ${{ steps.set-vars.outputs.APP_VERSION }} | |
AMS_VERSION: ${{ steps.set-vars.outputs.AMS_VERSION }} | |
TELEPATH_VERSION: ${{ steps.set-vars.outputs.TELEPATH_VERSION }} | |
EXPORTED_ENV: ${{ steps.set-vars.outputs.EXPORTED_ENV }} | |
steps: | |
- name: Clone Repo | |
uses: actions/checkout@v4 | |
- name: Setup environment variables | |
id: set-vars | |
run: | | |
get_env() { | |
local key="$1" | |
local path="source/constants.py" | |
value=$(python3 -c "with open('$path', 'r') as f: print([l for l in f.readlines() if '$key'.lower() in l][0].split(' = ')[1][1:-2].strip())") | |
echo "$key=$value" >> $GITHUB_OUTPUT | |
} | |
# Retrieve and set environment variables | |
get_env APP_VERSION | |
get_env AMS_VERSION | |
get_env TELEPATH_VERSION | |
echo "EXPORTED_ENV=true" >> $GITHUB_OUTPUT | |
test-env: | |
name: Test environment | |
runs-on: ubuntu-latest | |
needs: setup-env | |
steps: | |
- name: Test environment variables | |
run: | | |
echo auto-mcs-${{ needs.setup-env.outputs.APP_VERSION }} | |
echo "${{ needs.setup-env.outputs.EXPORTED_ENV }}" | grep "true" | |
# Compile binaries for every OS | |
windows: | |
name: Windows Build | |
runs-on: windows-2019 | |
needs: [setup-env, test-env] | |
steps: | |
- name: Clone Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: Compile auto-mcs | |
shell: pwsh | |
run: | | |
systeminfo | |
$python_path = "$env:LOCALAPPDATA\Programs\Python\Python39" | |
md $python_path | |
Move-Item -Force C:\hostedtoolcache\windows\Python\3.9.13\x64\* $python_path | |
powershell -noprofile -executionpolicy bypass -file .\build-tools\build-windows.ps1 | |
- name: Upload Executable | |
uses: actions/upload-artifact@v4 | |
with: | |
name: auto-mcs-windows-${{ needs.setup-env.outputs.APP_VERSION }} | |
path: build-tools/dist/ | |
retention-days: 5 | |
macos: | |
name: macOS Build | |
runs-on: macos-13 | |
needs: [setup-env, test-env] | |
steps: | |
- name: Clone Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Install Dependencies | |
run: | | |
brew install [email protected] [email protected] create-dmg | |
- name: Compile auto-mcs | |
run: | | |
root=$(pwd) | |
cd build-tools | |
mkdir -p /Users/runner/Library/Fonts | |
chmod +x build-macos.sh | |
sudo ./build-macos.sh | |
chmod +x dist/auto-mcs.app/Contents/MacOS/auto-mcs | |
# Create .dmg from .app | |
while : ; do | |
[[ -f "$root/build-tools/dist/auto-mcs.dmg" ]] && break | |
sleep 1 | |
sudo create-dmg \ | |
--volname "auto-mcs" \ | |
--volicon "$root/other/macos-dmg/icon.icns" \ | |
--background "$root/other/macos-dmg/bg.png" \ | |
--window-pos 200 120 \ | |
--window-size 835 620 \ | |
--icon-size 128 \ | |
--text-size 16 \ | |
--icon "auto-mcs.app" 230 277 \ | |
--hide-extension "auto-mcs.app" \ | |
--app-drop-link 593 277 \ | |
"$root/build-tools/dist/auto-mcs.dmg" \ | |
"$root/build-tools/dist/auto-mcs.app" | |
done | |
- name: Upload Binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: auto-mcs-macos-${{ needs.setup-env.outputs.APP_VERSION }} | |
path: build-tools/dist/auto-mcs.dmg | |
retention-days: 5 | |
linux: | |
name: Linux Build | |
runs-on: ubuntu-20.04 | |
needs: [setup-env, test-env] | |
steps: | |
- name: Clone Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Install Dependencies | |
run: | | |
sudo apt update -y | |
sudo apt install xvfb fluxbox libasound2 libasound-dev tk8.6 libtk8.6 tcl8.6 libtcl8.6 -y | |
export DISPLAY=:0.0 | |
Xvfb :0 -screen 0 1280x720x24 > /dev/null 2>&1 & | |
sleep 1 | |
fluxbox > /dev/null 2>&1 & | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: Compile auto-mcs | |
run: | | |
spec_file="auto-mcs.linux.spec" | |
sudo cp -f /usr/lib/x86_64-linux-gnu/libcrypt.so.1 /usr/lib64/libcrypt.so.2 | |
export DISPLAY=:0.0 | |
cd build-tools | |
current=$( pwd ) | |
python3.9 -m pip install --upgrade pip setuptools wheel | |
python3.9 -m venv ./venv | |
source ./venv/bin/activate | |
pip install -r reqs-linux.txt | |
python -m kivy.tools.packaging.pyinstaller_hooks hook ./venv/lib/python3.9/site-packages/kivy/tools/packaging/pyinstaller_hooks/kivy-hook.py | |
cp -f ../source/gui-assets/fonts/Consolas* /usr/share/fonts | |
fc-cache -f | |
# python locale-gen.py | |
# Patch plyer (pull #822) | |
FILECHOOSER="./venv/lib/python3.9/site-packages/plyer/platforms/linux/filechooser.py" | |
sed -i 's/--confirm-overwrite//g' "$FILECHOOSER" | |
sed -i '/self\.title/d' "$FILECHOOSER" | |
sed -i '/self\.icon/d' "$FILECHOOSER" | |
echo Compiling auto-mcs | |
export KIVY_AUDIO=ffpyplayer | |
cd $current | |
cp $spec_file ../source | |
cd ../source | |
pyinstaller $spec_file --upx-dir $current/upx/linux --clean | |
cd $current | |
rm -rf ../source/$spec_file | |
mv -f ../source/dist . | |
deactivate | |
if ! [ -f $current/dist/auto-mcs ]; then | |
"[FAIL] Something went wrong during compilation" | |
exit 1 | |
else | |
echo [SUCCESS] Compiled binary: \"$current/dist/auto-mcs\" | |
fi | |
chmod +x dist/auto-mcs | |
- name: Upload Binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: auto-mcs-linux-${{ needs.setup-env.outputs.APP_VERSION }} | |
path: build-tools/dist/ | |
retention-days: 5 | |
linux-arm: | |
name: Linux Build (arm64) | |
runs-on: ubuntu-20.04 | |
needs: [setup-env, test-env] | |
steps: | |
- name: Clone Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Create artifact directory | |
run: | | |
mkdir build-tools/dist | |
- name: Configure VM & compile auto-mcs | |
uses: pguyot/[email protected] | |
with: | |
cpu: cortex-a53 | |
cpu_info: cpuinfo/raspberrypi_zero2_w_arm64 | |
base_image: raspios_lite_arm64:2022-04-04 | |
image_additional_mb: 4096 | |
copy_artifact_path: build-tools/dist/* | |
copy_artifact_dest: build-tools/dist | |
commands: | | |
# Install dependencies | |
mkdir -p /usr/lib64/ | |
sudo cp -f /usr/lib/aarch64-linux-gnu/libcrypt.so.1 /usr/lib64/libcrypt.so.2 | |
sudo apt update -y | |
sudo apt install xvfb fluxbox libasound2 libasound-dev tk8.6 libtk8.6 tcl8.6 libtcl8.6 upx python3-venv python3-tk python3-dev fontconfig -y | |
export DISPLAY=:0.0 | |
Xvfb :0 -screen 0 1280x720x24 > /dev/null 2>&1 & | |
sleep 1 | |
fluxbox > /dev/null 2>&1 & | |
# Build auto-mcs | |
spec_file="auto-mcs.linux.spec" | |
export DISPLAY=:0.0 | |
cd build-tools | |
current=$( pwd ) | |
python3 -m venv ./venv | |
. ./venv/bin/activate | |
pip install -r reqs-linux.txt | |
python -m kivy.tools.packaging.pyinstaller_hooks hook ./venv/lib/python3.9/site-packages/kivy/tools/packaging/pyinstaller_hooks/kivy-hook.py | |
cp -f ../source/gui-assets/fonts/Consolas* /usr/share/fonts | |
fc-cache -f | |
# python locale-gen.py | |
# Patch plyer (pull #822) | |
FILECHOOSER="./venv/lib/python3.9/site-packages/plyer/platforms/linux/filechooser.py" | |
sed -i 's/--confirm-overwrite//g' "$FILECHOOSER" | |
sed -i '/self\.title/d' "$FILECHOOSER" | |
sed -i '/self\.icon/d' "$FILECHOOSER" | |
echo Compiling auto-mcs | |
export KIVY_AUDIO=ffpyplayer | |
cd $current | |
cp $spec_file ../source | |
cd ../source | |
pyinstaller $spec_file --upx-dir /usr/bin --clean | |
cd $current | |
rm -rf ../source/$spec_file | |
mv -f ../source/dist . | |
if ! [ -f $current/dist/auto-mcs ]; then | |
"[FAIL] Something went wrong during compilation" | |
exit 1 | |
else | |
echo [SUCCESS] Compiled binary: \"$current/dist/auto-mcs\" | |
fi | |
chmod +x dist/auto-mcs | |
- name: Upload Binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: auto-mcs-linux-arm64-${{ needs.setup-env.outputs.APP_VERSION }} | |
path: build-tools/dist/ | |
retention-days: 5 | |
alpine: | |
name: Docker Build | |
runs-on: ubuntu-latest | |
needs: [setup-env, test-env] | |
steps: | |
- name: Clone Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Setup Alpine Linux | |
uses: jirutka/setup-alpine@v1 | |
with: | |
branch: v3.15 | |
- name: Install Dependencies | |
run: | | |
apk add xvfb fluxbox python3 py3-pip gcc pangomm-dev pkgconfig python3-dev zlib-dev libffi-dev musl-dev linux-headers mtdev-dev mtdev | |
export DISPLAY=:0.0 | |
Xvfb :0 -screen 0 1280x720x24 > /dev/null 2>&1 & | |
sleep 1 | |
fluxbox > /dev/null 2>&1 & | |
shell: alpine.sh --root {0} | |
- name: Compile auto-mcs | |
run: | | |
spec_file="auto-mcs.docker.spec" | |
export DISPLAY=:0.0 | |
cd build-tools | |
current=$( pwd ) | |
python3.9 -m pip install --upgrade pip setuptools wheel | |
python3.9 -m venv ./venv | |
source ./venv/bin/activate | |
pip install -r reqs-docker.txt | |
echo Compiling auto-mcs | |
cd $current | |
cp $spec_file ../source | |
cd ../source | |
pyinstaller $spec_file --upx-dir $current/upx/linux --clean | |
cd $current | |
rm -rf ../source/$spec_file | |
mv -f ../source/dist . | |
deactivate | |
if ! [ -f $current/dist/auto-mcs ]; then | |
"[FAIL] Something went wrong during compilation" | |
exit 1 | |
else | |
echo [SUCCESS] Compiled binary: \"$current/dist/auto-mcs\" | |
fi | |
chmod +x dist/auto-mcs | |
shell: alpine.sh {0} | |
- name: Upload Binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: auto-mcs-alpine-${{ needs.setup-env.outputs.APP_VERSION }} | |
path: build-tools/dist/ | |
retention-days: 5 | |
alpine-arm: | |
name: Docker Build (arm64) | |
runs-on: ubuntu-latest | |
needs: [setup-env, test-env] | |
steps: | |
- name: Clone Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Setup Alpine Linux | |
uses: jirutka/setup-alpine@v1 | |
with: | |
arch: aarch64 | |
branch: v3.15 | |
- name: Install Dependencies | |
run: | | |
apk add xvfb fluxbox python3 py3-pip gcc pangomm-dev pkgconfig python3-dev zlib-dev libffi-dev musl-dev linux-headers mtdev-dev mtdev | |
export DISPLAY=:0.0 | |
Xvfb :0 -screen 0 1280x720x24 > /dev/null 2>&1 & | |
sleep 1 | |
fluxbox > /dev/null 2>&1 & | |
shell: alpine.sh --root {0} | |
- name: Compile auto-mcs | |
run: | | |
spec_file="auto-mcs.docker.spec" | |
export DISPLAY=:0.0 | |
cd build-tools | |
current=$( pwd ) | |
python3.9 -m pip install --upgrade pip setuptools wheel | |
python3.9 -m venv ./venv | |
source ./venv/bin/activate | |
pip install -r reqs-docker.txt | |
echo Compiling auto-mcs | |
cd $current | |
cp $spec_file ../source | |
cd ../source | |
pyinstaller $spec_file --upx-dir $current/upx/linux --clean | |
cd $current | |
rm -rf ../source/$spec_file | |
mv -f ../source/dist . | |
deactivate | |
if ! [ -f $current/dist/auto-mcs ]; then | |
"[FAIL] Something went wrong during compilation" | |
exit 1 | |
else | |
echo [SUCCESS] Compiled binary: \"$current/dist/auto-mcs\" | |
fi | |
chmod +x dist/auto-mcs | |
shell: alpine.sh {0} | |
- name: Upload Binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: auto-mcs-alpine-arm64-${{ needs.setup-env.outputs.APP_VERSION }} | |
path: build-tools/dist/ | |
retention-days: 5 | |
# Publish images to Docker Hub | |
publish-docker: | |
name: Publish Docker image | |
runs-on: ubuntu-latest | |
needs: [setup-env, alpine, alpine-arm] | |
permissions: | |
packages: write | |
contents: read | |
attestations: write | |
id-token: write | |
env: | |
REGISTRY: docker.io | |
IMAGE_NAME: macarooniman/auto-mcs | |
APP_VERSION: ${{ needs.setup-env.outputs.APP_VERSION }} | |
TAG_SUFFIX: ${{ github.ref_name == 'main' && 'latest' || 'beta' }} | |
steps: | |
- name: Clone Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Download x86_64 binary | |
uses: actions/download-artifact@v4 | |
with: | |
name: auto-mcs-alpine-${{ env.APP_VERSION }} | |
path: ./binaries/x86_64 | |
- name: Download arm64 binary | |
uses: actions/download-artifact@v4 | |
with: | |
name: auto-mcs-alpine-arm64-${{ env.APP_VERSION }} | |
path: ./binaries/arm64 | |
- name: Prepare build context | |
run: | | |
mkdir -p ./docker | |
mv binaries/x86_64/auto-mcs ./docker/auto-mcs-amd64 | |
mv binaries/arm64/auto-mcs ./docker/auto-mcs-arm64 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.IMAGE_NAME }} | |
labels: | | |
org.opencontainers.image.title={{ env.IMAGE_NAME }} | |
org.opencontainers.image.description=auto-mcs (docker) | |
org.opencontainers.image.version={{ env.APP_VERSION }} | |
org.opencontainers.image.revision={{ github.sha }} | |
org.opencontainers.image.created={{ now }} | |
org.opencontainers.image.authors=Kaleb Efflandt <[email protected]> | |
org.opencontainers.image.url=https://auto-mcs.com | |
org.opencontainers.image.source=https://github.com/{{ github.repository }} | |
org.opencontainers.image.licenses=GPL-3.0 | |
- name: Build and push Docker image | |
id: push | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./docker | |
file: ./docker/Dockerfile | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: | | |
${{ env.IMAGE_NAME }}:${{ env.APP_VERSION }} | |
${{ env.IMAGE_NAME }}:${{ env.TAG_SUFFIX }} | |
labels: ${{ steps.meta.outputs.labels }} |