Skip to content

Commit

Permalink
fix(CI/CD workflow): WIP 3 #95 incorrect arch selected for the runner
Browse files Browse the repository at this point in the history
  • Loading branch information
MRColorR committed Oct 10, 2024
1 parent 65998d6 commit 72a6202
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
33 changes: 22 additions & 11 deletions .github/workflows/release-on-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,10 @@ jobs:
echo "Python detected arch: $(python3 -m platform)"
echo "Expected runner architecture: ${{ matrix.architecture }}"
# Setup QEMU and Docker Buildx only for Ubuntu runners targeting arm/arm64 architectures
- name: Set up QEMU for cross-compilation
if: matrix.os == 'ubuntu-latest' && (matrix.architecture == 'arm64' || matrix.architecture == 'armv7')
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Set up Docker Buildx
if: matrix.os == 'ubuntu-latest' && (matrix.architecture == 'arm64' || matrix.architecture == 'armv7')
uses: docker/setup-buildx-action@v3

# Runners supported architectures use normal build process
# Step: Install dependencies
- name: Install dependencies
if: matrix.os != 'ubuntu-latest' || (matrix.architecture != 'arm64' && matrix.architecture != 'armv7')
shell: bash # Use bash shell for consistency
run: |
python -m pip install --upgrade pip
Expand All @@ -61,6 +52,7 @@ jobs:
# Step: Build with PyInstaller
- name: Build with PyInstaller
if: matrix.os != 'ubuntu-latest' || (matrix.architecture != 'arm64' && matrix.architecture != 'armv7')
shell: bash
run: |
pyinstaller --onedir \
Expand All @@ -83,6 +75,25 @@ jobs:
--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 == 'armv7')
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Set up Docker Buildx
if: matrix.os == 'ubuntu-latest' && (matrix.architecture == 'arm64' || matrix.architecture == 'armv7')
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 == 'armv7')
run: |
docker build --file workflow-linux-arm64.dockerfile --platform linux/${{ matrix.architecture }} -t money4band-builder .
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'
Expand Down
31 changes: 31 additions & 0 deletions workflow-linux-arm64.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Use Python 3.12 as the base image
FROM python:3.12

# Set environment variables for non-interactive installation
ENV DEBIAN_FRONTEND=noninteractive

# Install necessary packages
RUN apt-get update && \
apt-get install -y \
build-essential \
libssl-dev \
libffi-dev \
python3-setuptools \
git \
curl \
&& apt-get clean

# Install PyInstaller
RUN pip install pyinstaller

# Set the working directory
WORKDIR /app

# Copy project files into the container
COPY . .

# Install Python dependencies
RUN pip install -r requirements.txt

# Build the project using PyInstaller
CMD ["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"]

0 comments on commit 72a6202

Please sign in to comment.