127 lines
4.8 KiB
YAML
127 lines
4.8 KiB
YAML
name: Build Windows Packages
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- development
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- development
|
|
|
|
jobs:
|
|
build-windows:
|
|
name: Build Windows
|
|
runs-on: windows
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: 'npm'
|
|
|
|
- name: Install Rust stable
|
|
shell: powershell
|
|
run: |
|
|
if (!(Get-Command rustup -ErrorAction SilentlyContinue) -and !(Test-Path "$env:USERPROFILE\.cargo\bin\rustup.exe")) {
|
|
Write-Host "Downloading rustup-init.exe..."
|
|
Invoke-WebRequest -Uri "https://win.rustup.rs/x86_64" -OutFile "$env:TEMP\rustup-init.exe"
|
|
& "$env:TEMP\rustup-init.exe" -y --default-toolchain stable --profile minimal
|
|
}
|
|
"$env:USERPROFILE\.cargo\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
rustup default stable
|
|
rustup target add x86_64-pc-windows-msvc
|
|
|
|
- name: Rust Cache
|
|
uses: Swatinem/rust-cache@v2
|
|
continue-on-error: true
|
|
with:
|
|
workspaces: "src-tauri -> target"
|
|
|
|
- name: Check sidecar binaries
|
|
shell: powershell
|
|
run: |
|
|
if (!(Test-Path "src-tauri\argyll\windows-x86_64\argyll-instlist.exe")) {
|
|
Write-Host "Warning: Windows ArgyllCMS binaries not found. Please ensure they are downloaded/committed to src-tauri/argyll/windows-x86_64 before release."
|
|
}
|
|
|
|
- name: Install Node dependencies
|
|
run: npm ci
|
|
|
|
- name: Get App Version
|
|
id: get_version
|
|
shell: powershell
|
|
run: |
|
|
$VERSION = node -p "require('./package.json').version"
|
|
if ($env:GITHUB_REF -like "refs/tags/*") {
|
|
$TAG = $env:GITHUB_REF_NAME
|
|
"APP_VERSION=$($TAG.TrimStart('v'))" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
"RELEASE_TAG=$TAG" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
} elseif ($env:GITHUB_REF -eq "refs/heads/main") {
|
|
"APP_VERSION=$VERSION" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
"RELEASE_TAG=v$VERSION" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
} else {
|
|
"APP_VERSION=$VERSION-dev" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
}
|
|
|
|
- name: Prepare platform-specific resources
|
|
shell: powershell
|
|
run: |
|
|
if (Test-Path "src-tauri\argyll\linux-x86_64") {
|
|
Write-Host "Removing Linux ArgyllCMS binaries to avoid bundling them in Windows installer..."
|
|
Remove-Item -Recurse -Force "src-tauri\argyll\linux-x86_64"
|
|
}
|
|
|
|
- name: Build Tauri App
|
|
run: npm run tauri build -- -v
|
|
|
|
- name: Upload MSI Installer
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: iccery-windows-msi-${{ env.APP_VERSION }}
|
|
path: src-tauri/target/release/bundle/msi/*.msi
|
|
|
|
- name: Upload NSIS Installer
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: iccery-windows-exe-${{ env.APP_VERSION }}
|
|
path: src-tauri/target/release/bundle/nsis/*.exe
|
|
|
|
- name: Upload Release Assets to Gitea
|
|
if: (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && !cancelled()
|
|
shell: powershell
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
SERVER_URL: ${{ github.server_url }}
|
|
REPO: ${{ github.repository }}
|
|
run: |
|
|
$TAG = $env:RELEASE_TAG
|
|
if (-not $TAG) { $TAG = "v$env:APP_VERSION" }
|
|
Write-Host "Finding release for tag $TAG..."
|
|
$headers = @{ "Authorization" = "token $env:GITEA_TOKEN" }
|
|
try {
|
|
$release = Invoke-RestMethod -Uri "$env:SERVER_URL/api/v1/repos/$env:REPO/releases/tags/$TAG" -Headers $headers -Method Get
|
|
$releaseId = $release.id
|
|
if ($releaseId) {
|
|
Write-Host "Found Release ID: $releaseId. Uploading Windows assets..."
|
|
$files = Get-ChildItem -Path "src-tauri\target\release\bundle\msi\*.msi", "src-tauri\target\release\bundle\nsis\*.exe" -ErrorAction SilentlyContinue
|
|
foreach ($file in $files) {
|
|
Write-Host "Uploading $($file.Name)..."
|
|
curl.exe -s -X POST `
|
|
-H "Authorization: token $env:GITEA_TOKEN" `
|
|
-H "Content-Type: multipart/form-data" `
|
|
-F "attachment=@$($file.FullName)" `
|
|
"$env:SERVER_URL/api/v1/repos/$env:REPO/releases/$releaseId/assets?name=$($file.Name)"
|
|
}
|
|
}
|
|
} catch {
|
|
Write-Host "Skipping release asset upload: $_"
|
|
}
|