Skip to content

Merge pull request #108 from MRColorR/emulation-layer-status-patch #28

Merge pull request #108 from MRColorR/emulation-layer-status-patch

Merge pull request #108 from MRColorR/emulation-layer-status-patch #28

Workflow file for this run

name: Build and Release Money4Band
on:
push:
tags:
- "*.*.*" # Matches tags like 1.0.0, 2.1.1, etc.
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest] # Build for Linux, macOS, and Windows
architecture: [x64, arm64, arm/v7] # Target architectures
exclude:
- os: macos-latest
architecture: arm/v7 # macOS doesn't support arm/v7
- os: windows-latest
architecture: arm/v7 # Windows doesn't support arm/v7
steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for generating changelogs
fetch-tags: true # Ensure all tags are fetched
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
#cache: 'pip' # Enables caching for pip dependencies , it seems to fail in DinD containers for arm builds
# Step to print platform details for diagnostic purposes
- name: Check Python platform info
shell: bash # Use bash shell for consistency
run: |
echo "Runner OS detected arch: $(uname -a)"
echo "Python detected arch: $(python3 -m platform)"
echo "Expected runner architecture: ${{ matrix.architecture }}"
# Runners supported architectures use normal build process
# Step: Install dependencies
- name: Install dependencies
if: matrix.os != 'ubuntu-latest' || (matrix.architecture != 'arm64' && matrix.architecture != 'arm/v7')
shell: bash # Use bash shell for consistency
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller # Install PyInstaller
# Step: Build with PyInstaller
- name: Build with PyInstaller
if: matrix.os != 'ubuntu-latest' || (matrix.architecture != 'arm64' && matrix.architecture != 'arm/v7')
shell: bash
run: |
pyinstaller --onedir \
--name Money4Band \
main.py \
--hidden-import colorama \
--hidden-import docker \
--hidden-import requests \
--hidden-import pyyaml \
--hidden-import psutil \
--hidden-import yaml \
--hidden-import secrets \
--add-data ".resources:.resources" \
--add-data "config:config" \
--add-data "utils:utils" \
--add-data "legacy_money4bandv3x:legacy_money4bandv3x" \
--add-data "template:template" \
--add-data "LICENSE:LICENSE" \
--add-data "README.md:README.md" \
--contents-directory "." \
-y
# Runners unsupported architectures use docker build process
# Setup QEMU and Docker Buildx only for Ubuntu runners for arch not supported by runners
- name: Set up QEMU for cross-compilation
if: matrix.os == 'ubuntu-latest' && (matrix.architecture == 'arm64' || matrix.architecture == 'arm/v7')
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker Buildx
if: matrix.os == 'ubuntu-latest' && (matrix.architecture == 'arm64' || matrix.architecture == 'arm/v7')
uses: docker/setup-buildx-action@v3
# Use Docker for cross-architecture builds for arch not supported by runners
- name: Build with Docker for ARM architectures
if: matrix.os == 'ubuntu-latest' && (matrix.architecture == 'arm64' || matrix.architecture == 'arm/v7')
run: |
docker build --file workflow-linux-arm64.dockerfile --platform linux/${{ matrix.architecture }} -t money4band-builder --cache-from type=gha --cache-to type=gha .
docker run --platform linux/${{ matrix.architecture }} --rm -v $(pwd)/dist:/app/dist money4band-builder
# Archive build artifacts for Windows
- name: Archive build artifacts for release (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Compress-Archive -Path "dist\Money4Band\*" -DestinationPath "Money4Band-${{ matrix.os }}-${{ matrix.architecture }}-${{ github.ref_name }}.zip"
# Archive build artifacts for Unix (Linux/macOS)
- name: Archive build artifacts for release (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
if [ "${{ matrix.architecture }}" == "arm/v7" ]; then
tar -czvf "Money4Band-${{ matrix.os }}-armv7-${{ github.ref_name }}.tar.gz" dist/Money4Band
else
tar -czvf "Money4Band-${{ matrix.os }}-${{ matrix.architecture }}-${{ github.ref_name }}.tar.gz" dist/Money4Band
fi
# Upload build artifacts (excluded arm/v7)
- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: matrix.architecture != 'arm/v7'
with:
name: "Money4Band-${{ matrix.os }}-${{ matrix.architecture }}-${{ github.ref_name }}"
path: |
Money4Band-${{ matrix.os }}-${{ matrix.architecture }}-${{ github.ref_name }}.zip
Money4Band-${{ matrix.os }}-${{ matrix.architecture }}-${{ github.ref_name }}.tar.gz
if-no-files-found: error # Fail if no files are found
# Upload build artifacts for arm/v7
- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: matrix.architecture == 'arm/v7'
with:
name: "Money4Band-${{ matrix.os }}-armv7-${{ github.ref_name }}"
path: |
Money4Band-${{ matrix.os }}-armv7-${{ github.ref_name }}.zip
Money4Band-${{ matrix.os }}-armv7-${{ github.ref_name }}.tar.gz
if-no-files-found: error # Fail if no files are found
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for generating changelogs
fetch-tags: true # Ensure all tags are fetched
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Generate Changelog
id: changelog
uses: heinrichreimer/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
output: CHANGELOG.md
onlyLastTag: true # Only generate changelog for the last tag
- name: Create a GitHub release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
name: "Money4Band ${{ github.ref_name }}"
tag_name: "${{ github.ref_name }}"
body_path: "./CHANGELOG.md"
files: "./artifacts/**/*"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}