Create-Release.ps1

# Create GitHub Release for v2.1.0
param(
    [Parameter(Mandatory=$true)]
    [string]$GitHubToken
)

$owner = "markorr321"
$repo = "Entra-PIM"
$tag = "v2.1.0"
$releaseName = "v2.1.0"

$releaseBody = @"
## What's New in v2.1.0
 
### New Commands
- **Configure-EntraPIM**: Set up persistent custom app registration via environment variables - configure once, use everywhere
- **Clear-EntraPIMConfig**: Remove saved configuration and return to default authentication
- **Get-EntraPIMHelp**: Comprehensive built-in help and command reference
 
### Improvements
- Visual confirmation of which app registration is being used during authentication
- macOS: Automatic PowerShell profile integration for persistent configuration
 
### Bug Fixes
- Fixed Windows terminal exit behavior - Ctrl+Q now properly closes the terminal in Entra workflow
- Fixed MSAL assembly conflict when multiple Microsoft modules are loaded
 
### Installation
Download the .nupkg file below and install with:
``````powershell
Install-PSResource -Path .\Entra-PIM.2.1.0.nupkg
``````
 
Or install directly from PSGallery:
``````powershell
Install-PSResource -Name Entra-PIM
``````
"@


# Create the release
$headers = @{
    "Authorization" = "token $GitHubToken"
    "Accept" = "application/vnd.github.v3+json"
}

$body = @{
    tag_name = $tag
    name = $releaseName
    body = $releaseBody
    draft = $false
    prerelease = $false
} | ConvertTo-Json

$response = Invoke-RestMethod -Uri "https://api.github.com/repos/$owner/$repo/releases" -Method Post -Headers $headers -Body $body -ContentType "application/json"

Write-Host "Release created successfully!" -ForegroundColor Green
Write-Host "Release URL: $($response.html_url)" -ForegroundColor Cyan

# Upload the .nupkg asset
$assetPath = "c:\Projects\Entra-PIM\release\Entra-PIM.2.1.0.nupkg"
$assetName = "Entra-PIM.2.1.0.nupkg"
$uploadUrl = $response.upload_url -replace '\{\?name,label\}', "?name=$assetName"

$assetHeaders = @{
    "Authorization" = "token $GitHubToken"
    "Content-Type" = "application/octet-stream"
}

Write-Host "Uploading .nupkg file..." -ForegroundColor Yellow
Invoke-RestMethod -Uri $uploadUrl -Method Post -Headers $assetHeaders -InFile $assetPath | Out-Null
Write-Host "Asset uploaded successfully!" -ForegroundColor Green