Skip to content

Commit

Permalink
💚 fix CI workflow (#137)
Browse files Browse the repository at this point in the history
### TL;DR

Updated CI workflow to fix the backend build process for different platforms (Linux, macOS, Windows) and ensure executables are correctly placed in the frontend directory.

### What changed?

- Removed direct calls to reusable workflows for building backend executables.
- Implemented a GitHub Action to dispatch workflows for building executables based on version changes.
- Added steps to ensure executables are copied to `frontend/src-tauri/bin/` directory.
- Modified the `pyinstaller` commands to remove unnecessary flags and added a step to create necessary directories.

### How to test?

- Check if the CI workflow builds backend executables for all specified platforms (Linux, macOS, Windows) and places them in the correct directory.
- Verify the version check is working correctly and triggers builds only when version is updated.

### Why make this change?

This change ensures that backend executables are built and placed correctly in the frontend directory for easier access and reduces redundancy by utilizing GitHub Actions to dispatch workflows. It aims to streamline the CI process and increase maintainability.

---
  • Loading branch information
mingi3314 authored Jun 9, 2024
1 parent 61928ef commit dc214d9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
42 changes: 27 additions & 15 deletions .github/workflows/backend-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,6 @@ jobs:
echo "version_changed=false" >> $GITHUB_OUTPUT
fi
- name: Call Reusable Workflow to Build Backend for Linux
uses: mingi3314/PyRb/.github/workflows/build-backend-executable.yaml@main
with:
platform: linux

- name: Call Reusable Workflow to Build Backend for macOS
uses: mingi3314/PyRb/.github/workflows/build-backend-executable.yaml@main
with:
platform: macos

- name: Call Reusable Workflow to Build Backend for Windows
uses: mingi3314/PyRb/.github/workflows/build-backend-executable.yaml@main
with:
platform: windows

- name: Create Release
if: steps.version_check.outputs.version_changed == 'true'
uses: softprops/action-gh-release@v1
Expand All @@ -82,3 +67,30 @@ jobs:
run: |
poetry build
poetry publish
- name: Trigger Build Executables
if: steps.version_check.outputs.version_changed == 'true'
uses: actions/github-script@v6
with:
script: |
github.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'build-backend-executable.yaml',
ref: context.ref,
inputs: { platform: 'linux' }
})
github.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'build-backend-executable.yaml',
ref: context.ref,
inputs: { platform: 'macos' }
})
github.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'build-backend-executable.yaml',
ref: context.ref,
inputs: { platform: 'windows' }
})
9 changes: 6 additions & 3 deletions .github/workflows/build-backend-executable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ jobs:
apt-get install -y python3.11 python3.11-venv python3.11-dev && \
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11 && \
pip3.11 install pyinstaller && \
pyinstaller -c -F --clean --name run-server-x86_64-unknown-linux-gnu backend/pyrb/controllers/api/main.py && \
pyinstaller --clean -F --name run-server-x86_64-unknown-linux-gnu backend/pyrb/controllers/api/main.py && \
mkdir -p frontend/src-tauri/bin/ && \
cp backend/dist/run-server-x86_64-unknown-linux-gnu frontend/src-tauri/bin/"
build-backend-macos:
Expand All @@ -49,7 +50,8 @@ jobs:

- name: Build backend executable
run: |
pyinstaller -c -F --clean --name run-server-aarch64-apple-darwin backend/pyrb/controllers/api/main.py
pyinstaller --clean -F --name run-server-aarch64-apple-darwin backend/pyrb/controllers/api/main.py
mkdir -p frontend/src-tauri/bin/
cp backend/dist/run-server-aarch64-apple-darwin frontend/src-tauri/bin/
build-backend-windows:
Expand All @@ -70,5 +72,6 @@ jobs:

- name: Build backend executable
run: |
pyinstaller -c -F --clean --name run-server-x86_64-pc-windows-msvc backend/pyrb/controllers/api/main.py
pyinstaller --clean -F --name run-server-x86_64-pc-windows-msvc backend/pyrb/controllers/api/main.py
mkdir -p frontend/src-tauri/bin/
cp backend/dist/run-server-x86_64-pc-windows-msvc.exe frontend/src-tauri/bin/

0 comments on commit dc214d9

Please sign in to comment.