Skip to content

Build Whisper Transcription Tool #11

Build Whisper Transcription Tool

Build Whisper Transcription Tool #11

Workflow file for this run

name: Build Whisper Transcription Tool
on:
push:
tags: ['v*'] # Trigger on version tags
workflow_dispatch: # Manual trigger
env:
# ===== CORE CONFIGURATION =====
APP_NAME: "SoundTranscriber"
PYTHON_VERSION: "3.11.9"
BUILD_ROOT: "exe_build" # Root directory for build resources
# MAIN_SCRIPT will be defined in jobs context
# ===== BUILD CONFIGURATION =====
# OUTPUT_EXE will be defined in jobs context
# ICON_FILE will be defined in jobs context
# ADDITIONAL_FILES will be defined in jobs context
CONSOLE_APP: "false" # Set to "true" for console apps
# ===== DEPENDENCY CONFIGURATION =====
USE_CHOCO_FFMPEG: "true"
WHISPER_MODEL: "small" # tiny, base, small, medium, large
jobs:
build-windows-exe:
name: Build Windows EXE
runs-on: windows-latest
env:
# Define these here where we can reference the global env vars
MAIN_SCRIPT: "main.py"
OUTPUT_EXE: "Transcribe.exe"
ICON_FILE: "app.ico"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Verify build directory structure
run: |
if (-not (Test-Path "./exe_build")) {
Write-Error "Build root directory './exe_build' not found!"
exit 1
}
if (-not (Test-Path "./exe_build/main.py")) {
Write-Error "Main script './exe_build/main.py' not found!"
exit 1
}
- name: Get latest release and compute next version
id: version
run: |
$headers = @{
"Accept" = "application/vnd.github+json"
"Authorization" = "Bearer ${{ secrets.UPLOAD_TOKEN }}"
"X-GitHub-Api-Version" = "2022-11-28"
}
try {
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/${{ github.repository }}/releases/latest" -Headers $headers
$LATEST = $response.tag_name
Write-Host "Latest release tag: $LATEST"
if ($LATEST -match '^v([0-9]+)\.([0-9]+)\.([0-9]+)$') {
$MAJOR = [int]$Matches[1]
$MINOR = [int]$Matches[2]
$PATCH = [int]$Matches[3]
} else {
$MAJOR = 0
$MINOR = 0
$PATCH = 0
}
# Increment version numbers
$PATCH++
if ($PATCH -ge 10) {
$PATCH = 0
$MINOR++
}
if ($MINOR -ge 10) {
$MINOR = 0
$MAJOR++
}
$VERSION = "v${MAJOR}.${MINOR}.${PATCH}"
$NAME = "Transcribe - ${VERSION}"
Write-Host "Next version: $VERSION"
# Set outputs using proper PowerShell syntax
"tag_name=$VERSION" >> $env:GITHUB_OUTPUT
"version_name=$NAME" >> $env:GITHUB_OUTPUT
} catch {
Write-Host "Error getting latest release: $_"
# Fallback to v0.0.1 if no releases exist
"tag_name=v0.0.1" >> $env:GITHUB_OUTPUT
"version_name=CopperOS - v0.0.1" >> $env:GITHUB_OUTPUT
}
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: "3.11.9"
- name: Install Chocolatey (if needed)
run: |
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
- name: Install FFmpeg via Chocolatey
run: choco install ffmpeg -y --no-progress
- name: Install Python dependencies
working-directory: "./exe_build"
run: |
python -m pip install --upgrade pip
pip install pyinstaller
pip install git+https://github.com/openai/whisper.git
if (Test-Path "requirements.txt") {
pip install -r requirements.txt
}
- name: Generate PyInstaller command
id: pyinstaller
run: |
$command = "pyinstaller --noconfirm --clean --onefile"
$command += " --name Transcribe"
$command += " --distpath ../dist"
$command += " --workpath ../build"
$command += " --specpath ../build"
$command += " --windowed"
if ("${{ env.ICON_FILE }}" -ne "" -and (Test-Path "${{ env.ICON_FILE }}")) {
$command += " --icon ${{ env.ICON_FILE }}"
}
$command += " ${{ env.MAIN_SCRIPT }}"
echo "command=$command" >> $env:GITHUB_OUTPUT
- name: Run PyInstaller
working-directory: "./exe_build"
run: |
${{ steps.pyinstaller.outputs.command }}
dir ../dist
- name: Github Actions Create Release
uses: idev-coder/github-actions-release@v1.0.0
with:
github_token: ${{ secrets.UPLOAD_TOKEN }}
tag: ${{ steps.version.outputs.tag_name }}
body: "Release made by GitHub Actions..."
name: ${{ steps.version.outputs.version_name }}
env:
RELEASE_TOKEN: ${{ secrets.UPLOAD_TOKEN }}
- name: Publish Release Assets
uses: vinayaja/publish-release-assets@v1.1.0
with:
gh-token: ${{ secrets.UPLOAD_TOKEN }}
release-tag: ${{ steps.version.outputs.tag_name }}
asset-names: "Transcribe.exe"
overwrite: false