-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (137 loc) · 5.18 KB
/
build-exe.yml
File metadata and controls
164 lines (137 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Build Whisper Transcription Tool
on:
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=Transcribe - Latest" >> $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: "./dist/Transcribe.exe"
overwrite: false