Skip to content

Panel build: skip auto-run via env var #55

Panel build: skip auto-run via env var

Panel build: skip auto-run via env var #55

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Existing tag to rebuild"
required: true
permissions:
contents: write
jobs:
build-and-release:
runs-on: windows-latest
steps:
- name: Resolve release ref
id: release_meta
shell: powershell
run: |
$event = "${{ github.event_name }}"
$refType = "${{ github.ref_type }}"
$ref = "${{ github.ref }}"
$tag = "${{ github.ref_name }}"
if ($event -eq "workflow_dispatch") {
$inputTag = "${{ inputs.tag }}".Trim()
if ([string]::IsNullOrWhiteSpace($inputTag)) {
throw 'workflow_dispatch requires the "tag" input'
}
$tag = $inputTag
$ref = "refs/tags/$inputTag"
} elseif ($refType -ne "tag") {
throw "Release workflow must run from a tag ref (current: $ref)"
}
"ref=$ref" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append
"tag=$tag" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ steps.release_meta.outputs.ref }}
- name: Download and setup AutoHotkey v2 + Ahk2Exe
id: setup-tools
shell: powershell
run: |
$headers = @{ 'User-Agent' = 'Lab-App-Control-Release' }
# Download AutoHotkey v2 portable
$ahkRelease = Invoke-RestMethod -Uri 'https://api.github.com/repos/AutoHotkey/AutoHotkey/releases/latest' -Headers $headers
$ahkAsset = $ahkRelease.assets | Where-Object { $_.name -like 'AutoHotkey_*.zip' } | Select-Object -First 1
if (-not $ahkAsset) {
throw 'Could not locate AutoHotkey portable zip'
}
$ahkZip = 'AutoHotkey.zip'
$ahkDir = 'AutoHotkey'
Write-Host "Downloading AutoHotkey from $($ahkAsset.browser_download_url)"
Invoke-WebRequest -Uri $ahkAsset.browser_download_url -OutFile $ahkZip -Headers $headers
Expand-Archive -Path $ahkZip -DestinationPath $ahkDir -Force
# Download Ahk2Exe
$compilerRelease = Invoke-RestMethod -Uri 'https://api.github.com/repos/AutoHotkey/Ahk2Exe/releases/latest' -Headers $headers
$compilerAsset = $compilerRelease.assets | Where-Object { $_.name -like 'Ahk2Exe*.zip' } | Select-Object -First 1
if (-not $compilerAsset) {
throw 'Could not locate Ahk2Exe zip'
}
$compilerZip = 'Ahk2Exe.zip'
$compilerDir = 'Ahk2Exe'
Write-Host "Downloading Ahk2Exe from $($compilerAsset.browser_download_url)"
Invoke-WebRequest -Uri $compilerAsset.browser_download_url -OutFile $compilerZip -Headers $headers
Expand-Archive -Path $compilerZip -DestinationPath $compilerDir -Force
# Locate compiler and base
$compiler = Get-ChildItem -Path $compilerDir -Filter 'Ahk2Exe.exe' -Recurse -File | Select-Object -ExpandProperty FullName -First 1
$base = (Resolve-Path (Join-Path $ahkDir 'AutoHotkey64.exe')).Path
if (-not $compiler -or -not (Test-Path $compiler)) {
throw "Ahk2Exe.exe not found in $compilerDir"
}
if (-not (Test-Path $base)) {
throw "AutoHotkey64.exe not found at $base"
}
# Copy Ahk2Exe dependencies from AutoHotkey
$compilerBinDir = Split-Path -Parent $compiler
Copy-Item -Path (Join-Path $ahkDir 'AutoHotkey32.exe') -Destination (Join-Path $compilerBinDir 'Unicode 32-bit.bin') -Force
Copy-Item -Path (Join-Path $ahkDir 'AutoHotkey64.exe') -Destination (Join-Path $compilerBinDir 'Unicode 64-bit.bin') -Force
Write-Host "Compiler: $compiler"
Write-Host "Base: $base"
"compiler=$compiler" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append
"autohotkey_base=$base" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append
# List compiler directory contents for debugging
Write-Host "Compiler directory contents:"
Get-ChildItem -Path (Split-Path -Parent $compiler) | Format-Table Name, Length
- name: Compile AppControl
shell: powershell
run: |
$compiler = "${{ steps.setup-tools.outputs.compiler }}"
if (-not $compiler -or -not (Test-Path $compiler)) {
throw "Ahk2Exe compiler path missing: $compiler"
}
$base = "${{ steps.setup-tools.outputs.autohotkey_base }}"
if (-not $base -or -not (Test-Path $base)) {
throw "AutoHotkey base path missing: $base"
}
$compilerDir = Split-Path -Parent $compiler
Copy-Item -Path (Join-Path (Split-Path -Parent $base) 'AutoHotkey32.exe') -Destination (Join-Path $compilerDir 'Unicode 32-bit.bin') -Force
Copy-Item -Path $base -Destination (Join-Path $compilerDir 'Unicode 64-bit.bin') -Force
$binPath = Join-Path $compilerDir 'Unicode 64-bit.bin'
$scriptPath = (Resolve-Path 'controller/AppControl.ahk').Path
$outDir = Join-Path $PWD 'dist'
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
$outFile = Join-Path $outDir 'AppControl.exe'
$iconPath = (Resolve-Path 'img/favicon.ico').Path
Write-Host "Compiler: $compiler"
Write-Host "Base: $base"
Write-Host "Bin: $binPath"
Write-Host "Icon: $iconPath"
Write-Host "Script: $scriptPath"
Write-Host "Output: $outFile"
# Verify script exists and is readable
if (-not (Test-Path $scriptPath)) {
throw "Script not found: $scriptPath"
}
Write-Host "Script verified, size: $((Get-Item $scriptPath).Length) bytes"
# Verify include files exist for LabStation
if ($scriptPath -like "*LabStation.ahk") {
Write-Host "Checking LabStation includes..."
$scriptDir = Split-Path -Parent $scriptPath
$includes = @(
"core\Config.ahk", "core\Logger.ahk", "core\Admin.ahk", "core\Shell.ahk", "core\Json.ahk",
"system\RegistryManager.ahk", "system\WakeOnLan.ahk", "system\Autostart.ahk",
"system\AccountManager.ahk", "system\EnergyAudit.ahk", "system\PowerManager.ahk",
"system\ServiceManager.ahk", "service\SessionManager.ahk", "service\SessionGuard.ahk",
"service\Telemetry.ahk", "service\Recovery.ahk", "diagnostics\Status.ahk",
"service\CommandQueue.ahk", "setup\Wizard.ahk", "ui\Tray.ahk"
)
foreach ($inc in $includes) {
$incPath = Join-Path $scriptDir $inc
if (-not (Test-Path $incPath)) {
throw "Missing include file: $incPath"
}
}
Write-Host "All include files verified"
}
# Change to script directory for compilation (required for relative includes)
$scriptDir = Split-Path -Parent $scriptPath
$scriptName = Split-Path -Leaf $scriptPath
Push-Location $scriptDir
Write-Host "Current directory: $(Get-Location)"
Write-Host "Files in current directory:"
Get-ChildItem | Select-Object -First 10 | Format-Table Name
# Use absolute paths for compilation
$absScript = Join-Path $scriptDir $scriptName
$arguments = @('/in', $absScript, '/out', $outFile, '/bin', $binPath, '/icon', $iconPath)
Write-Host "Running from: $scriptDir"
Write-Host "Running: $compiler $($arguments -join ' ')"
# Simple invocation without stream redirection to avoid hanging
$output = & $compiler @arguments 2>&1 | Out-String
$exitCode = $LASTEXITCODE
Pop-Location
Write-Host "Compiler output:"
Write-Host $output
Write-Host "Exit code: $exitCode"
if ($null -eq $exitCode) {
$exitCode = 0
}
if ($exitCode -ne 0) {
throw "Ahk2Exe exited with code $exitCode"
}
# Wait for file system to flush
Start-Sleep -Seconds 2
if (-not (Test-Path $outFile)) {
Write-Host "Listing dist directory:"
Get-ChildItem $outDir -Recurse
throw "Expected output missing: $outFile"
}
Write-Host "Successfully created: $outFile"
$fileInfo = Get-Item $outFile
Write-Host "Size: $($fileInfo.Length) bytes"
- name: Compile LabStation
shell: powershell
run: |
$compiler = "${{ steps.setup-tools.outputs.compiler }}"
if (-not $compiler -or -not (Test-Path $compiler)) {
throw "Ahk2Exe compiler path missing: $compiler"
}
$base = "${{ steps.setup-tools.outputs.autohotkey_base }}"
if (-not $base -or -not (Test-Path $base)) {
throw "AutoHotkey base path missing: $base"
}
$compilerDir = Split-Path -Parent $compiler
Copy-Item -Path (Join-Path (Split-Path -Parent $base) 'AutoHotkey32.exe') -Destination (Join-Path $compilerDir 'Unicode 32-bit.bin') -Force
Copy-Item -Path $base -Destination (Join-Path $compilerDir 'Unicode 64-bit.bin') -Force
$binPath = Join-Path $compilerDir 'Unicode 64-bit.bin'
$scriptPath = (Resolve-Path 'labstation/LabStation.ahk').Path
$outDir = Join-Path $PWD 'dist'
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
$outFile = Join-Path $outDir 'LabStation.exe'
$iconPath = (Resolve-Path 'img/favicon.ico').Path
Write-Host "Compiler: $compiler"
Write-Host "Base: $base"
Write-Host "Bin: $binPath"
Write-Host "Icon: $iconPath"
Write-Host "Script: $scriptPath"
Write-Host "Output: $outFile"
# Verify script exists and is readable
if (-not (Test-Path $scriptPath)) {
throw "Script not found: $scriptPath"
}
Write-Host "Script verified, size: $((Get-Item $scriptPath).Length) bytes"
# Change to script directory for compilation (required for relative includes)
$scriptDir = Split-Path -Parent $scriptPath
$scriptName = Split-Path -Leaf $scriptPath
Push-Location $scriptDir
Write-Host "Current directory: $(Get-Location)"
Write-Host "Files in current directory:"
Get-ChildItem | Select-Object -First 10 | Format-Table Name
# Use absolute paths for compilation
$absScript = Join-Path $scriptDir $scriptName
$arguments = @('/in', $absScript, '/out', $outFile, '/bin', $binPath, '/icon', $iconPath)
Write-Host "Running from: $scriptDir"
Write-Host "Running: $compiler $($arguments -join ' ')"
# Simple invocation without stream redirection to avoid hanging
$output = & $compiler @arguments 2>&1 | Out-String
$exitCode = $LASTEXITCODE
Pop-Location
Write-Host "Compiler output:"
Write-Host $output
Write-Host "Exit code: $exitCode"
if ($null -eq $exitCode) {
$exitCode = 0
}
if ($exitCode -ne 0) {
throw "Ahk2Exe exited with code $exitCode"
}
Start-Sleep -Seconds 2
if (-not (Test-Path $outFile)) {
Write-Host "Listing dist directory:"
Get-ChildItem $outDir -Recurse
throw "Expected output missing: $outFile"
}
Write-Host "Successfully created: $outFile"
$fileInfo = Get-Item $outFile
Write-Host "Size: $($fileInfo.Length) bytes"
- name: Compile LabStation Panel
shell: powershell
run: |
$compiler = "${{ steps.setup-tools.outputs.compiler }}"
if (-not $compiler -or -not (Test-Path $compiler)) {
throw "Ahk2Exe compiler path missing: $compiler"
}
$base = "${{ steps.setup-tools.outputs.autohotkey_base }}"
if (-not $base -or -not (Test-Path $base)) {
throw "AutoHotkey base path missing: $base"
}
$compilerDir = Split-Path -Parent $compiler
Copy-Item -Path (Join-Path (Split-Path -Parent $base) 'AutoHotkey32.exe') -Destination (Join-Path $compilerDir 'Unicode 32-bit.bin') -Force
Copy-Item -Path $base -Destination (Join-Path $compilerDir 'Unicode 64-bit.bin') -Force
$binPath = Join-Path $compilerDir 'Unicode 64-bit.bin'
$scriptPath = (Resolve-Path 'LabStationPanel.ahk').Path
$outDir = Join-Path $PWD 'dist'
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
$outFile = Join-Path $outDir 'LabStationPanel.exe'
$iconPath = (Resolve-Path 'img/favicon.ico').Path
Write-Host "Compiler: $compiler"
Write-Host "Base: $base"
Write-Host "Bin: $binPath"
Write-Host "Icon: $iconPath"
Write-Host "Script: $scriptPath"
Write-Host "Output: $outFile"
# Signal script to skip runtime launch during compilation/tests
$env:LABSTATION_PANEL_BUILD = "1"
# Verify script can be parsed by AutoHotkey
Write-Host "Testing script syntax..."
$testOutput = & $base '/ErrorStdOut' $scriptPath 2>&1
Write-Host "Syntax check output: $testOutput"
# Try running Ahk2Exe with full verbosity
Write-Host "Attempting compilation with verbose output..."
$arguments = @('/in', $scriptPath, '/out', $outFile, '/bin', $binPath, '/icon', $iconPath, '/cp', '0')
Write-Host "Running: $compiler $($arguments -join ' ')"
# Run compiler and capture all output
$process = Start-Process -FilePath $compiler -ArgumentList $arguments -NoNewWindow -Wait -PassThru -RedirectStandardOutput "$env:TEMP\ahk2exe_out.txt" -RedirectStandardError "$env:TEMP\ahk2exe_err.txt"
$exitCode = $process.ExitCode
$stdOut = Get-Content "$env:TEMP\ahk2exe_out.txt" -Raw -ErrorAction SilentlyContinue
$stdErr = Get-Content "$env:TEMP\ahk2exe_err.txt" -Raw -ErrorAction SilentlyContinue
Write-Host "Compiler stdout:"
Write-Host $stdOut
Write-Host "Compiler stderr:"
Write-Host $stdErr
Write-Host "Exit code: $exitCode"
if ($null -eq $exitCode) {
$exitCode = 0
}
if ($exitCode -ne 0) {
throw "Ahk2Exe exited with code $exitCode"
}
Start-Sleep -Seconds 2
if (-not (Test-Path $outFile)) {
Write-Host "Listing dist directory:"
Get-ChildItem $outDir -Recurse
throw "Expected output missing: $outFile"
}
Write-Host "Successfully created: $outFile"
$fileInfo = Get-Item $outFile
Write-Host "Size: $($fileInfo.Length) bytes"
- name: Stage WindowSpy helper
shell: powershell
run: |
$source = Join-Path $PWD 'WindowSpy.exe'
if (-not (Test-Path $source)) {
throw "WindowSpy.exe not found at $source"
}
$destDir = Join-Path $PWD 'dist'
New-Item -ItemType Directory -Force -Path $destDir | Out-Null
$destFile = Join-Path $destDir 'WindowSpy.exe'
Copy-Item -Path $source -Destination $destFile -Force
- name: Stage assets (logo)
shell: powershell
run: |
$destDir = Join-Path $PWD 'dist'
$logoDir = Join-Path $destDir 'img'
New-Item -ItemType Directory -Force -Path $logoDir | Out-Null
$logo = Join-Path $PWD 'img/DecentraLabs.png'
if (Test-Path $logo) {
Copy-Item -Path $logo -Destination (Join-Path $logoDir 'DecentraLabs.png') -Force
} else {
Write-Host "Logo not found at $logo; continuing without it."
}
- name: Upload AppControl artifact
uses: actions/upload-artifact@v4
with:
name: AppControl
path: dist/AppControl.exe
- name: Upload LabStation executable artifact
uses: actions/upload-artifact@v4
with:
name: LabStation-exe
path: dist/LabStation.exe
- name: Upload LabStation Panel artifact
uses: actions/upload-artifact@v4
with:
name: LabStationPanel
path: dist/LabStationPanel.exe
- name: Upload assets
uses: actions/upload-artifact@v4
with:
name: LabStation-assets
path: dist/img/DecentraLabs.png
- name: Upload WindowSpy artifact
uses: actions/upload-artifact@v4
with:
name: WindowSpy
path: dist/WindowSpy.exe
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/AppControl.exe
dist/LabStation.exe
dist/LabStationPanel.exe
dist/WindowSpy.exe
dist/img/DecentraLabs.png
tag_name: ${{ steps.release_meta.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}