Skip to content

Cross-Platform Build and Release #6

Cross-Platform Build and Release

Cross-Platform Build and Release #6

Workflow file for this run

name: Cross-Platform Build and Release
on:
workflow_dispatch:
inputs:
release_version:
description: "Enter the release version (e.g., v1.0.0)"
required: true
type: string
jobs:
build:
# Define matrix for Operating Systems
strategy:
fail-fast: false
matrix:
# os: [windows-latest, macos-latest, ubuntu-latest]
os: [windows-latest, ubuntu-latest]
python-version: ['3.13']
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install PyInstaller and dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build executable
run: pyinstaller main.spec
- name: Archive the release package (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
mv dist/PyPSADiag/PyPSADiag.exe dist/PyPSADiag/PyPSADiag-windows.exe
cd dist
tar -a -c -f ../PyPSADiag-Windows.zip PyPSADiag
- name: Archive the release package (macOS)
if: ${{ matrix.os == 'macos-latest' }}
run: |
mv dist/PyPSADiag/PyPSADiag dist/PyPSADiag/PyPSADiag-macos
chmod +x dist/PyPSADiag/PyPSADiag-macos || true
cd dist
tar -a -c -f ../PyPSADiag-macOS.zip PyPSADiag
- name: Archive the release package (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
mv dist/PyPSADiag/PyPSADiag dist/PyPSADiag/PyPSADiag-linux
chmod +x dist/PyPSADiag/PyPSADiag-linux || true
cd dist
tar -czf ../PyPSADiag-Linux.tar.gz PyPSADiag
- name: Upload release artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-build
path: |
PyPSADiag-Windows.zip
PyPSADiag-macOS.zip
PyPSADiag-Linux.tar.gz
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.release_version }}
release_name: Release ${{ github.event.inputs.release_version }}
draft: false
prerelease: false
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Upload Windows Asset to Release
if: ${{ hashFiles('artifacts/windows-latest-build/PyPSADiag-Windows.zip') != '' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/windows-latest-build/PyPSADiag-Windows.zip
asset_name: PyPSADiag-Windows.zip
asset_content_type: application/zip
- name: Upload macOS Asset to Release
if: ${{ hashFiles('artifacts/macos-latest-build/PyPSADiag-macOS.zip') != '' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/macos-latest-build/PyPSADiag-macOS.zip
asset_name: PyPSADiag-macOS.zip
asset_content_type: application/zip
- name: Upload Linux Asset to Release
if: ${{ hashFiles('artifacts/ubuntu-latest-build/PyPSADiag-Linux.tar.gz') != '' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/ubuntu-latest-build/PyPSADiag-Linux.tar.gz
asset_name: PyPSADiag-Linux.tar.gz
asset_content_type: application/gzip