Build and Release #1
This file contains hidden or 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: Build and Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Release version (e.g., v1.0.0)' | |
required: true | |
release_notes: | |
description: 'Release notes' | |
required: true | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest] | |
include: | |
- os: windows-latest | |
output_name: VoiceCommand.exe | |
asset_name: VoiceCommand-Windows.exe | |
data_separator: ";" | |
- os: ubuntu-latest | |
output_name: VoiceCommand | |
asset_name: VoiceCommand-Linux | |
data_separator: ":" | |
- os: macos-latest | |
output_name: VoiceCommand | |
asset_name: VoiceCommand-MacOS | |
data_separator: ":" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install pyinstaller | |
# Install system dependencies for Linux | |
- name: Install Linux system dependencies | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y portaudio19-dev python3-pyaudio | |
# Build with PyInstaller, using the appropriate data separator for each OS | |
- name: Build with PyInstaller | |
run: | | |
pyinstaller --onefile --add-data "public${{ matrix.data_separator }}public" --icon=public/favicon.ico --name VoiceCommand app.py | |
# Set executable permissions for Linux and macOS | |
- name: Set executable permissions | |
if: matrix.os != 'windows-latest' | |
run: | | |
chmod +x dist/${{ matrix.output_name }} | |
# Upload artifacts (separate from release for diagnostic purposes) | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.asset_name }} | |
path: dist/${{ matrix.output_name }} | |
# Create a release with all builds attached | |
create-release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ github.event.inputs.version }} | |
name: Release ${{ github.event.inputs.version }} | |
body: ${{ github.event.inputs.release_notes }} | |
draft: false | |
prerelease: false | |
files: | | |
artifacts/VoiceCommand-Windows.exe/VoiceCommand.exe | |
artifacts/VoiceCommand-Linux/VoiceCommand | |
artifacts/VoiceCommand-MacOS/VoiceCommand | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |