Skip to content

Build Windows • v0.1.3 #4

Build Windows • v0.1.3

Build Windows • v0.1.3 #4

Workflow file for this run

name: Build Windows
run-name: Build Windows • ${{ github.ref_name }}
on:
workflow_dispatch:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
build-windows:
name: Build unsigned Windows app artifact
runs-on: windows-latest
env:
CLOUDSCOPE_NATIVE: '1'
CLOUDSCOPE_REMOTE: '0'
CLOUDSCOPE_RELOAD: '0'
CLOUDSCOPE_STORAGE_SECRET: cloudscope-packaged-app-secret
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: uv sync --frozen
- name: Install packaging tools
run: uv pip install pyinstaller
- name: Resolve project version
id: version
shell: pwsh
run: |
$version = uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])"
echo "version=$version" >> $env:GITHUB_OUTPUT
echo "artifact_name=CloudScope-v$version-windows-x64" >> $env:GITHUB_OUTPUT
- name: Validate tag/version consistency
if: startsWith(github.ref, 'refs/tags/')
shell: pwsh
run: |
$tag = "${{ github.ref_name }}"
$version = "${{ steps.version.outputs.version }}"
$expected = "v$version"
if ($tag -ne $expected) {
Write-Error "Tag '$tag' does not match pyproject.toml version '$version'. Expected '$expected'."
exit 1
}
Write-Host "OK: tag '$tag' matches pyproject.toml version '$version'."
- name: Write build metadata
shell: pwsh
run: |
$commit = git rev-parse --short HEAD
$date = Get-Date -AsUTC -Format "yyyy-MM-ddTHH:mm:ssZ"
$version = "${{ steps.version.outputs.version }}"
@"
APP_NAME = "CloudScope"
VERSION = "$version"
GIT_COMMIT = "$commit"
BUILD_DATE = "$date"
BUILD_PLATFORM = "windows-x64"
"@ | Set-Content -Encoding UTF8 src/cloudscope/_build_info.py
- name: Build Windows app
run: uv run nicegui-pack --windowed --clean --name CloudScope src/cloudscope/app.py
- name: Archive Windows app
shell: pwsh
run: |
$artifactName = "${{ steps.version.outputs.artifact_name }}"
New-Item -ItemType Directory -Force -Path package
Copy-Item -Path dist/CloudScope -Destination package/CloudScope -Recurse
Compress-Archive `
-Path package/CloudScope `
-DestinationPath "$artifactName.zip" `
-Force
- name: Upload Windows app artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.version.outputs.artifact_name }}
path: ${{ steps.version.outputs.artifact_name }}.zip
if-no-files-found: error
- name: Upload Windows app to GitHub Release
if: startsWith(github.ref, 'refs/tags/')
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
ASSET: ${{ steps.version.outputs.artifact_name }}.zip
shell: bash
run: |
for attempt in {1..30}; do
if gh release view "$TAG" >/dev/null 2>&1; then
gh release upload "$TAG" "$ASSET" --clobber
exit 0
fi
echo "Waiting for GitHub Release $TAG to exist..."
sleep 10
done
echo "ERROR: GitHub Release $TAG was not found after waiting." >&2
exit 1