Run Tests and Publish Desktop App #28
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: Run Tests and Publish Desktop App | |
on: | |
push: | |
tags: | |
- 'v*' # Trigger only when pushing a version tag (e.g., v1.0.0) | |
release: | |
types: [created] # Also trigger if a release is created manually | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set Up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install Dependencies | |
run: pip install -r requirements.txt | |
- name: Set Matplotlib Backend | |
run: echo "MPLBACKEND=TkAgg" >> $GITHUB_ENV | |
- name: Debug Matplotlib Backend | |
run: python -c "import matplotlib; print(matplotlib.get_backend())" | |
- name: Run Tests | |
run: pytest --cov=solver --cov=parser --cov=plotter | |
build: | |
needs: test | |
strategy: | |
matrix: | |
os: [ubuntu-22.04, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set Up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install Dependencies | |
run: pip install -r requirements.prod.txt pyinstaller | |
- name: Build Executable | |
run: | | |
pyinstaller --onefile --name equation-solver app.py | |
shell: bash | |
- name: Rename Executables for OS Compatibility | |
run: | | |
if [[ "$RUNNER_OS" == "Windows" ]]; then | |
mv dist/equation-solver.exe equation-solver-windows.exe | |
else | |
mv dist/equation-solver equation-solver-ubuntu-22.04 | |
fi | |
shell: bash | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: equation-solver-${{ runner.os }} | |
path: equation-solver-* | |
release: | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist | |
- name: List Downloaded Files | |
run: ls -R dist | |
- name: Publish Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ github.ref_name }} | |
name: Release ${{ github.ref_name }} | |
draft: false | |
prerelease: false | |
files: | | |
dist/equation-solver-Linux/equation-solver-ubuntu-22.04 | |
dist/equation-solver-Windows/equation-solver-windows.exe | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_PAT }} |