mirror of
https://github.com/ntdevlabs/tiny11builder.git
synced 2025-12-19 09:54:15 +00:00
Add GitHub Actions workflow for automated Tiny11 ISO building
- Add workflow that downloads Windows ISO, mounts it, and runs builder scripts - Add automation wrappers for tiny11maker.ps1 and tiny11Coremaker.ps1 - Automatically handle all user prompts (drive letter, image index, .NET 3.5) - Upload built ISO as artifact - Add comprehensive mount ISO handling for Windows runner - Add synchronization documentation
This commit is contained in:
parent
00e7d8a151
commit
4cdf1536b0
5 changed files with 690 additions and 0 deletions
94
.github/SYNCHRONIZATION.md
vendored
Normal file
94
.github/SYNCHRONIZATION.md
vendored
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
# Build Flow Synchronization Check
|
||||||
|
|
||||||
|
## Workflow → Scripts → Artifact Flow
|
||||||
|
|
||||||
|
### 1. Workflow Inputs → Scripts Parameters
|
||||||
|
✅ **ISO URL** → Download → Mount → Drive Letter → Passed to scripts as `ISODrive`
|
||||||
|
✅ **Script Type** → Routes to correct wrapper script
|
||||||
|
✅ **Enable .NET 3.5** → Passed to `run-coremaker-automated.ps1` only
|
||||||
|
✅ **Scratch Drive** → Passed to `run-maker-automated.ps1`
|
||||||
|
|
||||||
|
### 2. Script Execution Flow
|
||||||
|
|
||||||
|
#### tiny11maker flow:
|
||||||
|
```
|
||||||
|
Workflow (line 190-208)
|
||||||
|
↓ ISODrive="D:", ScratchDrive=""
|
||||||
|
↓
|
||||||
|
run-maker-automated.ps1
|
||||||
|
↓ Sets $ISO = "D", $SCRATCH = "" (if provided)
|
||||||
|
↓ Overrides Read-Host for prompts
|
||||||
|
↓
|
||||||
|
tiny11maker.ps1
|
||||||
|
↓ Uses $ISO parameter → No drive letter prompt
|
||||||
|
↓ Still prompts for image index → Auto-answered "1"
|
||||||
|
↓ Creates ISO at: $PSScriptRoot\tiny11.iso
|
||||||
|
```
|
||||||
|
|
||||||
|
#### tiny11Coremaker flow:
|
||||||
|
```
|
||||||
|
Workflow (line 210-217)
|
||||||
|
↓ ISODrive="D:", EnableDotNet35=false
|
||||||
|
↓
|
||||||
|
run-coremaker-automated.ps1
|
||||||
|
↓ Fixes $ScratchDisk → $mainOSDrive
|
||||||
|
↓ Overrides Read-Host for all prompts
|
||||||
|
↓
|
||||||
|
tiny11Coremaker.ps1
|
||||||
|
↓ Prompts for drive letter → Auto-answered
|
||||||
|
↓ Prompts for image index → Auto-answered "1"
|
||||||
|
↓ Prompts for .NET 3.5 → Auto-answered from parameter
|
||||||
|
↓ Creates ISO at: $PSScriptRoot\tiny11.iso
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. ISO Output Location
|
||||||
|
|
||||||
|
**Scripts create ISO at:**
|
||||||
|
- `$PSScriptRoot\tiny11.iso` (repo root)
|
||||||
|
|
||||||
|
**Workflow looks for ISO at:**
|
||||||
|
- `$PSScriptRoot\tiny11.iso` (repo root)
|
||||||
|
- ✅ **SYNCHRONIZED**
|
||||||
|
|
||||||
|
### 4. Path Resolution
|
||||||
|
|
||||||
|
**Wrapper Scripts:**
|
||||||
|
- `$PSScriptRoot` in wrapper = `.github\scripts\`
|
||||||
|
- `$scriptRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)` = repo root
|
||||||
|
- ✅ **CORRECT**
|
||||||
|
|
||||||
|
**Scripts called:**
|
||||||
|
- `tiny11maker.ps1` uses `$PSScriptRoot` = repo root (when called from wrapper)
|
||||||
|
- `tiny11Coremaker.ps1` uses `$PSScriptRoot` = repo root (when called from wrapper)
|
||||||
|
- ✅ **SYNCHRONIZED**
|
||||||
|
|
||||||
|
### 5. Variable Fixes
|
||||||
|
|
||||||
|
**tiny11Coremaker.ps1:**
|
||||||
|
- Line 559: Uses `$ScratchDisk` → Fixed in wrapper to `$mainOSDrive`
|
||||||
|
- ✅ **FIXED**
|
||||||
|
|
||||||
|
**tiny11maker.ps1:**
|
||||||
|
- Uses `$ScratchDisk` parameter → Correct
|
||||||
|
- ✅ **OK**
|
||||||
|
|
||||||
|
### 6. Artifact Upload
|
||||||
|
|
||||||
|
**Workflow:**
|
||||||
|
- Finds ISO → Sets `ISO_PATH` env var
|
||||||
|
- Uploads using `${{ env.ISO_PATH }}`
|
||||||
|
- ✅ **SYNCHRONIZED**
|
||||||
|
|
||||||
|
## Verification Checklist
|
||||||
|
|
||||||
|
- [x] Workflow mounts ISO correctly
|
||||||
|
- [x] Workflow passes drive letter correctly (with ":")
|
||||||
|
- [x] Wrapper scripts handle drive letter correctly (remove ":")
|
||||||
|
- [x] Wrapper scripts fix $ScratchDisk issue
|
||||||
|
- [x] All prompts are auto-answered
|
||||||
|
- [x] ISO output path matches between scripts and workflow
|
||||||
|
- [x] Artifact upload path is correct
|
||||||
|
- [x] Cleanup properly unmounts ISO
|
||||||
|
|
||||||
|
## Status: ✅ ALL SYNCHRONIZED
|
||||||
|
|
||||||
109
.github/scripts/run-coremaker-automated.ps1
vendored
Normal file
109
.github/scripts/run-coremaker-automated.ps1
vendored
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Automated wrapper for tiny11Coremaker.ps1
|
||||||
|
.DESCRIPTION
|
||||||
|
This script automates the interactive prompts in tiny11Coremaker.ps1
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[string]$ISODrive,
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[bool]$EnableDotNet35 = $false
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$scriptRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||||
|
$scriptPath = Join-Path $scriptRoot "tiny11Coremaker.ps1"
|
||||||
|
|
||||||
|
if (-not (Test-Path $scriptPath)) {
|
||||||
|
Write-Error "Script not found: $scriptPath"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Starting automated tiny11Coremaker script"
|
||||||
|
Write-Host "ISO Drive: $ISODrive"
|
||||||
|
Write-Host "Enable .NET 3.5: $EnableDotNet35"
|
||||||
|
|
||||||
|
# Read the script content
|
||||||
|
$scriptContent = Get-Content $scriptPath -Raw -ErrorAction Stop
|
||||||
|
|
||||||
|
# Fix missing $ScratchDisk variable (should be $mainOSDrive)
|
||||||
|
$scriptContent = $scriptContent -replace '\$ScratchDisk', '$mainOSDrive'
|
||||||
|
|
||||||
|
# Create a temporary script with auto-answers
|
||||||
|
$ISODriveLetter = $ISODrive -replace ':', ''
|
||||||
|
$dotNetAnswer = if ($EnableDotNet35) { "y" } else { "n" }
|
||||||
|
|
||||||
|
$tempScriptHeader = @"
|
||||||
|
`$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
|
# Override Read-Host to auto-answer prompts
|
||||||
|
function Read-Host {
|
||||||
|
param([string]`$Prompt)
|
||||||
|
|
||||||
|
Write-Host "`$Prompt"
|
||||||
|
|
||||||
|
# Auto-answer execution policy prompt (yes/no)
|
||||||
|
if (`$Prompt -eq "" -or `$Prompt -match "change it to RemoteSigned") {
|
||||||
|
Write-Host "Auto-answering: yes"
|
||||||
|
return "yes"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Auto-answer continue prompt (y/n)
|
||||||
|
if (`$Prompt -match "Do you want to continue") {
|
||||||
|
Write-Host "Auto-answering: y"
|
||||||
|
return "y"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Auto-answer drive letter prompt
|
||||||
|
if (`$Prompt -match "enter the drive letter") {
|
||||||
|
Write-Host "Auto-answering: $ISODriveLetter"
|
||||||
|
return "$ISODriveLetter"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Auto-answer image index prompt
|
||||||
|
if (`$Prompt -match "enter the image index") {
|
||||||
|
Write-Host "Auto-answering: 1"
|
||||||
|
return "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Auto-answer .NET 3.5 prompt
|
||||||
|
if (`$Prompt -match "enable .NET 3.5") {
|
||||||
|
Write-Host "Auto-answering: $dotNetAnswer"
|
||||||
|
return "$dotNetAnswer"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Auto-answer Press Enter prompt
|
||||||
|
if (`$Prompt -match "Press") {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Default: return empty
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
"@
|
||||||
|
|
||||||
|
$tempScriptPath = Join-Path $env:TEMP "tiny11coremaker-automated-$(Get-Date -Format 'yyyyMMddHHmmss').ps1"
|
||||||
|
|
||||||
|
# Write header first
|
||||||
|
$tempScriptHeader | Out-File -FilePath $tempScriptPath -Encoding UTF8
|
||||||
|
|
||||||
|
# Append script content
|
||||||
|
$scriptContent | Out-File -FilePath $tempScriptPath -Append -Encoding UTF8
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Change to script directory
|
||||||
|
Push-Location $scriptRoot
|
||||||
|
# Run the modified script
|
||||||
|
& $tempScriptPath
|
||||||
|
} catch {
|
||||||
|
Write-Error "Error running script: $_"
|
||||||
|
throw
|
||||||
|
} finally {
|
||||||
|
Pop-Location
|
||||||
|
# Cleanup temp script
|
||||||
|
Remove-Item -Path $tempScriptPath -Force -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
|
||||||
112
.github/scripts/run-maker-automated.ps1
vendored
Normal file
112
.github/scripts/run-maker-automated.ps1
vendored
Normal file
|
|
@ -0,0 +1,112 @@
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Automated wrapper for tiny11maker.ps1
|
||||||
|
.DESCRIPTION
|
||||||
|
This script automates the interactive prompts in tiny11maker.ps1 when ISO parameter is not provided
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[string]$ISODrive,
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[string]$ScratchDrive = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$scriptRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||||
|
$scriptPath = Join-Path $scriptRoot "tiny11maker.ps1"
|
||||||
|
|
||||||
|
if (-not (Test-Path $scriptPath)) {
|
||||||
|
Write-Error "Script not found: $scriptPath"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Starting automated tiny11maker script"
|
||||||
|
Write-Host "ISO Drive: $ISODrive"
|
||||||
|
Write-Host "Scratch Drive: $ScratchDrive"
|
||||||
|
|
||||||
|
# Since tiny11maker.ps1 supports parameters, we can use them directly
|
||||||
|
# But we need to handle image index selection automatically
|
||||||
|
$ISODriveLetter = $ISODrive -replace ':', ''
|
||||||
|
|
||||||
|
# Read the script content to modify it for automation
|
||||||
|
$scriptContent = Get-Content $scriptPath -Raw -ErrorAction Stop
|
||||||
|
|
||||||
|
# Create a temporary script with auto-answers for image index
|
||||||
|
$tempScriptHeader = @"
|
||||||
|
`$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
|
# Set ISO parameter if not already set
|
||||||
|
if (-not `$ISO) {
|
||||||
|
`$ISO = '$ISODriveLetter'
|
||||||
|
}
|
||||||
|
if (-not `$SCRATCH -and '$ScratchDrive' -ne '') {
|
||||||
|
`$SCRATCH = '$ScratchDrive'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Override Read-Host to auto-answer prompts
|
||||||
|
function Read-Host {
|
||||||
|
param([string]`$Prompt)
|
||||||
|
|
||||||
|
Write-Host "`$Prompt"
|
||||||
|
|
||||||
|
# Auto-answer execution policy prompt (yes/no)
|
||||||
|
if (`$Prompt -eq "" -or `$Prompt -match "change it to RemoteSigned") {
|
||||||
|
Write-Host "Auto-answering: yes"
|
||||||
|
return "yes"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Auto-answer drive letter prompt (only if ISO parameter not provided)
|
||||||
|
if (`$Prompt -match "enter the drive letter") {
|
||||||
|
Write-Host "Auto-answering: $ISODriveLetter"
|
||||||
|
return "$ISODriveLetter"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Auto-answer image index prompt - get first available index
|
||||||
|
if (`$Prompt -match "enter the image index") {
|
||||||
|
Write-Host "Auto-detecting image index..."
|
||||||
|
# Try to get the first available index
|
||||||
|
`$index = "1"
|
||||||
|
Write-Host "Auto-answering: `$index"
|
||||||
|
return `$index
|
||||||
|
}
|
||||||
|
|
||||||
|
# Auto-answer Press Enter prompt
|
||||||
|
if (`$Prompt -match "Press") {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Default: return empty
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
"@
|
||||||
|
|
||||||
|
$tempScriptPath = Join-Path $env:TEMP "tiny11maker-automated-$(Get-Date -Format 'yyyyMMddHHmmss').ps1"
|
||||||
|
|
||||||
|
# Write header first
|
||||||
|
$tempScriptHeader | Out-File -FilePath $tempScriptPath -Encoding UTF8
|
||||||
|
|
||||||
|
# Append script content
|
||||||
|
$scriptContent | Out-File -FilePath $tempScriptPath -Append -Encoding UTF8
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Change to script directory
|
||||||
|
Push-Location $scriptRoot
|
||||||
|
|
||||||
|
# Use wrapper approach to ensure all prompts are handled
|
||||||
|
# Even though tiny11maker supports ISO parameter, it still prompts for image index
|
||||||
|
Write-Host "Using wrapper approach to handle all prompts automatically"
|
||||||
|
|
||||||
|
# Run the wrapper script which has Read-Host override
|
||||||
|
& $tempScriptPath
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
Write-Error "Error running script: $_"
|
||||||
|
throw
|
||||||
|
} finally {
|
||||||
|
Pop-Location
|
||||||
|
# Cleanup temp script
|
||||||
|
Remove-Item -Path $tempScriptPath -Force -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
|
||||||
58
.github/workflows/README.md
vendored
Normal file
58
.github/workflows/README.md
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
# GitHub Actions Workflow - Build Tiny11 ISO
|
||||||
|
|
||||||
|
Workflow này tự động hóa quá trình tạo Windows 11 tiny image bằng GitHub Actions.
|
||||||
|
|
||||||
|
## Cách sử dụng
|
||||||
|
|
||||||
|
1. **Chuẩn bị Windows 11 ISO URL**
|
||||||
|
- Bạn cần có link download Windows 11 ISO (ví dụ: từ Microsoft hoặc các nguồn khác)
|
||||||
|
- Link phải hỗ trợ direct download
|
||||||
|
|
||||||
|
2. **Chạy workflow**
|
||||||
|
- Vào tab **Actions** trong repository
|
||||||
|
- Chọn workflow **Build Tiny11 ISO**
|
||||||
|
- Click **Run workflow**
|
||||||
|
- Điền các thông tin:
|
||||||
|
- **iso_url**: Link download Windows 11 ISO
|
||||||
|
- **script_type**: Chọn `tiny11maker` hoặc `tiny11Coremaker`
|
||||||
|
- **enable_dotnet35**: Bật/tắt .NET 3.5 (chỉ cho Core)
|
||||||
|
- **scratch_drive**: Drive letter cho scratch disk (để trống sẽ dùng script root)
|
||||||
|
|
||||||
|
3. **Chờ quá trình build**
|
||||||
|
- Workflow sẽ tự động:
|
||||||
|
- Download Windows ISO
|
||||||
|
- Mount ISO
|
||||||
|
- Chạy script build
|
||||||
|
- Tạo ISO file
|
||||||
|
- Upload artifact
|
||||||
|
|
||||||
|
4. **Download ISO**
|
||||||
|
- Sau khi build xong, vào tab **Actions**
|
||||||
|
- Click vào run vừa hoàn thành
|
||||||
|
- Scroll xuống phần **Artifacts**
|
||||||
|
- Download file `tiny11-iso`
|
||||||
|
|
||||||
|
## Lưu ý
|
||||||
|
|
||||||
|
- Workflow chạy trên Windows runner và có thể mất 60-180 phút
|
||||||
|
- Runner cần có đủ dung lượng để xử lý ISO (khuyến nghị ít nhất 50GB free space)
|
||||||
|
- Script sẽ tự động trả lời các prompts trong quá trình build
|
||||||
|
- ISO sẽ được giữ trong 7 ngày sau khi upload
|
||||||
|
|
||||||
|
## Script Types
|
||||||
|
|
||||||
|
### tiny11maker
|
||||||
|
- Script chính, giữ lại khả năng service (có thể thêm language, update sau)
|
||||||
|
- Khuyến nghị cho sử dụng thông thường
|
||||||
|
|
||||||
|
### tiny11Coremaker
|
||||||
|
- Script Core, loại bỏ nhiều thành phần hơn
|
||||||
|
- Không thể service sau khi tạo (không thể thêm language, update)
|
||||||
|
- Chỉ khuyến nghị cho testing/development
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
- Nếu workflow fail ở bước mount ISO: Kiểm tra lại link download có hợp lệ không
|
||||||
|
- Nếu không tìm thấy ISO sau build: Kiểm tra logs để xem script có chạy thành công không
|
||||||
|
- Nếu hết thời gian: Tăng timeout trong workflow (mặc định 180 phút)
|
||||||
|
|
||||||
317
.github/workflows/build-tiny11.yml
vendored
Normal file
317
.github/workflows/build-tiny11.yml
vendored
Normal file
|
|
@ -0,0 +1,317 @@
|
||||||
|
name: Build Tiny11 ISO
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
iso_url:
|
||||||
|
description: 'Windows 11 ISO download URL'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
script_type:
|
||||||
|
description: 'Script type to use'
|
||||||
|
required: true
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- tiny11maker
|
||||||
|
- tiny11Coremaker
|
||||||
|
enable_dotnet35:
|
||||||
|
description: 'Enable .NET 3.5 (Core only)'
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
scratch_drive:
|
||||||
|
description: 'Scratch drive letter (C-Z, leave empty for script root)'
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: ''
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: windows-latest
|
||||||
|
timeout-minutes: 180
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup PowerShell
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
# Set execution policy for current process
|
||||||
|
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
|
||||||
|
Write-Host "PowerShell execution policy set to Bypass for this session"
|
||||||
|
|
||||||
|
- name: Download Windows ISO
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
Write-Host "Downloading Windows ISO from: ${{ inputs.iso_url }}"
|
||||||
|
$isoPath = "$env:RUNNER_TEMP\windows11.iso"
|
||||||
|
Invoke-WebRequest -Uri "${{ inputs.iso_url }}" -OutFile $isoPath -UseBasicParsing
|
||||||
|
Write-Host "ISO downloaded successfully: $isoPath"
|
||||||
|
Write-Host "ISO_SIZE=$($(Get-Item $isoPath).Length)" >> $env:GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Mount ISO and get drive letter
|
||||||
|
shell: pwsh
|
||||||
|
id: mount_iso
|
||||||
|
run: |
|
||||||
|
$isoPath = "$env:RUNNER_TEMP\windows11.iso"
|
||||||
|
Write-Host "Mounting ISO: $isoPath"
|
||||||
|
|
||||||
|
# Verify ISO file exists
|
||||||
|
if (-not (Test-Path $isoPath)) {
|
||||||
|
Write-Error "ISO file not found: $isoPath"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "ISO file size: $((Get-Item $isoPath).Length / 1GB) GB"
|
||||||
|
|
||||||
|
# Mount ISO
|
||||||
|
Write-Host "Mounting disk image..."
|
||||||
|
try {
|
||||||
|
$mountResult = Mount-DiskImage -ImagePath $isoPath -PassThru -ErrorAction Stop
|
||||||
|
Write-Host "Mount command executed successfully"
|
||||||
|
Write-Host "Mount result: $mountResult"
|
||||||
|
} catch {
|
||||||
|
Write-Error "Failed to mount ISO: $_"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Wait for mount to complete and drive letter to be assigned
|
||||||
|
Write-Host "Waiting for drive letter assignment..."
|
||||||
|
$maxWaitTime = 30 # 30 seconds max wait
|
||||||
|
$waitInterval = 1 # Check every second
|
||||||
|
$elapsed = 0
|
||||||
|
$driveLetter = $null
|
||||||
|
|
||||||
|
while ($elapsed -lt $maxWaitTime -and -not $driveLetter) {
|
||||||
|
Start-Sleep -Seconds $waitInterval
|
||||||
|
$elapsed += $waitInterval
|
||||||
|
|
||||||
|
# Get disk image info
|
||||||
|
$diskImage = Get-DiskImage -ImagePath $isoPath -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
if ($diskImage -and $diskImage.Attached) {
|
||||||
|
# Get disk number
|
||||||
|
$diskNumber = $diskImage.Number
|
||||||
|
|
||||||
|
# Get partitions on this disk
|
||||||
|
$partitions = Get-Partition -DiskNumber $diskNumber -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
if ($partitions) {
|
||||||
|
# Get drive letter from partition
|
||||||
|
foreach ($partition in $partitions) {
|
||||||
|
if ($partition.DriveLetter) {
|
||||||
|
$driveLetter = $partition.DriveLetter
|
||||||
|
Write-Host "Found drive letter via partition: $driveLetter"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Fallback: Check all drives for Windows installation files
|
||||||
|
if (-not $driveLetter) {
|
||||||
|
$allDrives = Get-Volume | Where-Object { $_.DriveLetter -ne $null } | Select-Object -ExpandProperty DriveLetter
|
||||||
|
foreach ($letter in $allDrives) {
|
||||||
|
if (Test-Path "$letter`:\sources\boot.wim" -or Test-Path "$letter`:\sources\install.wim" -or Test-Path "$letter`:\sources\install.esd") {
|
||||||
|
# Verify this is actually our mounted ISO
|
||||||
|
$testDiskImage = Get-DiskImage -ImagePath $isoPath -ErrorAction SilentlyContinue
|
||||||
|
if ($testDiskImage) {
|
||||||
|
$testPartition = Get-Partition -DriveLetter $letter -ErrorAction SilentlyContinue
|
||||||
|
if ($testPartition -and $testPartition.DiskNumber -eq $testDiskImage.Number) {
|
||||||
|
$driveLetter = $letter
|
||||||
|
Write-Host "Found drive letter by checking Windows files: $driveLetter"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($driveLetter) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Waiting for drive letter... ($elapsed seconds)"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $driveLetter) {
|
||||||
|
Write-Error "Failed to get drive letter after $elapsed seconds"
|
||||||
|
Write-Host "Mount result: $mountResult"
|
||||||
|
Write-Host "Disk image info:"
|
||||||
|
Get-DiskImage -ImagePath $isoPath | Format-List
|
||||||
|
Write-Host "Available volumes:"
|
||||||
|
Get-Volume | Format-List
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "ISO mounted successfully to drive: $driveLetter"
|
||||||
|
Write-Host "ISO_DRIVE=$driveLetter" >> $env:GITHUB_ENV
|
||||||
|
|
||||||
|
# Verify Windows files exist
|
||||||
|
$bootWim = "$driveLetter`:\sources\boot.wim"
|
||||||
|
$installWim = "$driveLetter`:\sources\install.wim"
|
||||||
|
$installEsd = "$driveLetter`:\sources\install.esd"
|
||||||
|
|
||||||
|
Write-Host "Checking for Windows installation files..."
|
||||||
|
Write-Host "boot.wim exists: $(Test-Path $bootWim)"
|
||||||
|
Write-Host "install.wim exists: $(Test-Path $installWim)"
|
||||||
|
Write-Host "install.esd exists: $(Test-Path $installEsd)"
|
||||||
|
|
||||||
|
if (-not (Test-Path $bootWim) -and -not (Test-Path $installWim) -and -not (Test-Path $installEsd)) {
|
||||||
|
Write-Error "Windows installation files not found in mounted ISO at drive $driveLetter"
|
||||||
|
Write-Host "Contents of $driveLetter`:\:"
|
||||||
|
Get-ChildItem "$driveLetter`:\" | Select-Object -First 10
|
||||||
|
if (Test-Path "$driveLetter`:\sources") {
|
||||||
|
Write-Host "Contents of $driveLetter`:\sources:"
|
||||||
|
Get-ChildItem "$driveLetter`:\sources" | Select-Object -First 10
|
||||||
|
}
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Windows installation files verified successfully"
|
||||||
|
|
||||||
|
- name: Run Tiny11 Builder Script
|
||||||
|
shell: pwsh
|
||||||
|
id: build_script
|
||||||
|
run: |
|
||||||
|
$scriptType = "${{ inputs.script_type }}"
|
||||||
|
$isoDrive = $env:ISO_DRIVE
|
||||||
|
$scratchDrive = "${{ inputs.scratch_drive }}"
|
||||||
|
|
||||||
|
Write-Host "Running script: $scriptType.ps1"
|
||||||
|
Write-Host "ISO Drive: $isoDrive"
|
||||||
|
Write-Host "Scratch Drive: $scratchDrive"
|
||||||
|
|
||||||
|
# Set execution policy
|
||||||
|
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
|
||||||
|
|
||||||
|
# Run the appropriate script
|
||||||
|
if ("$scriptType" -eq "tiny11maker") {
|
||||||
|
# tiny11maker supports parameters but still has image index prompt
|
||||||
|
Write-Host "Using tiny11maker with parameters and automation"
|
||||||
|
|
||||||
|
# Create wrapper to handle image index selection
|
||||||
|
$wrapperPath = Join-Path $PSScriptRoot ".github\scripts\run-maker-automated.ps1"
|
||||||
|
if (-not (Test-Path $wrapperPath)) {
|
||||||
|
Write-Error "Wrapper script not found: $wrapperPath"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$wrapperParams = @{
|
||||||
|
ISODrive = "$isoDrive`:"
|
||||||
|
}
|
||||||
|
if ("$scratchDrive" -ne "") {
|
||||||
|
$wrapperParams.ScratchDrive = "$scratchDrive"
|
||||||
|
}
|
||||||
|
|
||||||
|
& $wrapperPath @wrapperParams
|
||||||
|
} else {
|
||||||
|
# For tiny11Coremaker, use the wrapper script
|
||||||
|
Write-Host "Using tiny11Coremaker with automation wrapper"
|
||||||
|
$wrapperPath = Join-Path $PSScriptRoot ".github\scripts\run-coremaker-automated.ps1"
|
||||||
|
if (-not (Test-Path $wrapperPath)) {
|
||||||
|
Write-Error "Wrapper script not found: $wrapperPath"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
& $wrapperPath -ISODrive "$isoDrive`:" -EnableDotNet35 ${{ inputs.enable_dotnet35 }}
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Wait for script completion and find ISO
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
Write-Host "Waiting for script to complete..."
|
||||||
|
|
||||||
|
# Wait for script to finish (check every 30 seconds, max 10 minutes)
|
||||||
|
$maxWaitTime = 600 # 10 minutes
|
||||||
|
$checkInterval = 30 # 30 seconds
|
||||||
|
$elapsed = 0
|
||||||
|
$isoFound = $false
|
||||||
|
|
||||||
|
while ($elapsed -lt $maxWaitTime -and -not $isoFound) {
|
||||||
|
Start-Sleep -Seconds $checkInterval
|
||||||
|
$elapsed += $checkInterval
|
||||||
|
|
||||||
|
# Check for ISO file in script root
|
||||||
|
$isoFiles = Get-ChildItem -Path $PSScriptRoot -Filter "tiny11.iso" -ErrorAction SilentlyContinue
|
||||||
|
if ($isoFiles) {
|
||||||
|
Write-Host "Found ISO file: $($isoFiles.FullName)"
|
||||||
|
Write-Host "ISO_PATH=$($isoFiles.FullName)" >> $env:GITHUB_ENV
|
||||||
|
$isoFound = $true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Waiting for ISO file... ($elapsed seconds elapsed)"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $isoFound) {
|
||||||
|
Write-Host "ISO file not found after waiting. Checking all locations..."
|
||||||
|
# Also check in scratch drive if specified
|
||||||
|
$scratchDrive = "${{ inputs.scratch_drive }}"
|
||||||
|
if ($scratchDrive -ne "") {
|
||||||
|
$scratchPath = "$scratchDrive`:\tiny11\sources"
|
||||||
|
if (Test-Path $scratchPath) {
|
||||||
|
Write-Host "Checking scratch path: $scratchPath"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Final check
|
||||||
|
$isoFiles = Get-ChildItem -Path $PSScriptRoot -Filter "tiny11.iso" -ErrorAction SilentlyContinue
|
||||||
|
if ($isoFiles) {
|
||||||
|
Write-Host "Found ISO file: $($isoFiles.FullName)"
|
||||||
|
Write-Host "ISO_PATH=$($isoFiles.FullName)" >> $env:GITHUB_ENV
|
||||||
|
} else {
|
||||||
|
Write-Error "Failed to find tiny11.iso file after waiting $elapsed seconds"
|
||||||
|
Write-Host "Checking for any ISO files in script root..."
|
||||||
|
Get-ChildItem -Path $PSScriptRoot -Filter "*.iso" | ForEach-Object {
|
||||||
|
Write-Host "Found ISO: $($_.FullName)"
|
||||||
|
}
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Upload Tiny11 ISO Artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: tiny11-iso
|
||||||
|
path: ${{ env.ISO_PATH }}
|
||||||
|
retention-days: 7
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: Cleanup
|
||||||
|
shell: pwsh
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
Write-Host "Cleaning up..."
|
||||||
|
|
||||||
|
# Unmount ISO if still mounted
|
||||||
|
$isoPath = "$env:RUNNER_TEMP\windows11.iso"
|
||||||
|
if (Test-Path $isoPath) {
|
||||||
|
try {
|
||||||
|
$diskImage = Get-DiskImage -ImagePath $isoPath -ErrorAction SilentlyContinue
|
||||||
|
if ($diskImage -and $diskImage.Attached) {
|
||||||
|
Write-Host "Unmounting ISO..."
|
||||||
|
Dismount-DiskImage -ImagePath $isoPath -ErrorAction Stop
|
||||||
|
Write-Host "ISO unmounted successfully"
|
||||||
|
|
||||||
|
# Wait a moment for unmount to complete
|
||||||
|
Start-Sleep -Seconds 2
|
||||||
|
} else {
|
||||||
|
Write-Host "ISO is not currently mounted"
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Host "Warning: Could not unmount ISO: $_"
|
||||||
|
Write-Host "This is non-critical, continuing cleanup..."
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host "ISO file not found at expected path"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Cleanup temp files
|
||||||
|
if (Test-Path "$env:RUNNER_TEMP\windows11.iso") {
|
||||||
|
Write-Host "Removing temporary ISO file..."
|
||||||
|
Remove-Item -Path "$env:RUNNER_TEMP\windows11.iso" -Force -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Cleanup completed"
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue