Merge branch 'main' of https://git.azuze.fr/kawa/Sharepoint-Toolbox
Cleaned the repo
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,6 +7,8 @@ publish/
|
|||||||
.vs/
|
.vs/
|
||||||
*.user
|
*.user
|
||||||
*.suo
|
*.suo
|
||||||
|
release.ps1
|
||||||
|
Sharepoint_ToolBox.ps1
|
||||||
|
|
||||||
# Claude Code
|
# Claude Code
|
||||||
.claude/
|
.claude/
|
||||||
|
|||||||
BIN
SharePoint_Toolbox_2.3.1.zip
Normal file
BIN
SharePoint_Toolbox_2.3.1.zip
Normal file
Binary file not shown.
@@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"dataFolder": "C:\\Users\\SebastienQUEROL\\Documents\\SPToolbox",
|
|
||||||
"lang": "en"
|
|
||||||
}
|
|
||||||
94
release.ps1
94
release.ps1
@@ -1,19 +1,10 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Build, tag, and publish a release to Gitea.
|
Build, tag, and publish a release to Gitea.
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
1. Builds a self-contained single-file EXE
|
|
||||||
2. Packages it with example CSVs into a zip
|
|
||||||
3. Creates a git tag and pushes it
|
|
||||||
4. Creates a Gitea Release and uploads the zip
|
|
||||||
|
|
||||||
.PARAMETER Version
|
.PARAMETER Version
|
||||||
Version tag (e.g. "v2.0.0"). Required.
|
Version tag (e.g. "v2.0.0"). Required.
|
||||||
|
|
||||||
.PARAMETER Token
|
.PARAMETER Token
|
||||||
Gitea API token. If not provided, reads from GITEA_TOKEN env var.
|
Gitea API token. If not provided, reads from GITEA_TOKEN env var.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
.\release.ps1 -Version v2.0.0
|
.\release.ps1 -Version v2.0.0
|
||||||
.\release.ps1 -Version v2.1.0 -Token "your_token_here"
|
.\release.ps1 -Version v2.1.0 -Token "your_token_here"
|
||||||
@@ -31,7 +22,7 @@ $Project = "SharepointToolbox/SharepointToolbox.csproj"
|
|||||||
$PublishDir = "publish"
|
$PublishDir = "publish"
|
||||||
$ZipName = "SharePoint_Toolbox_$Version.zip"
|
$ZipName = "SharePoint_Toolbox_$Version.zip"
|
||||||
|
|
||||||
# ── Validate ──────────────────────────────────────────────────────────────────
|
# -- Validate --
|
||||||
if (-not $Token) {
|
if (-not $Token) {
|
||||||
Write-Error "No token provided. Pass -Token or set GITEA_TOKEN env var."
|
Write-Error "No token provided. Pass -Token or set GITEA_TOKEN env var."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -42,13 +33,15 @@ if (git tag -l $Version) {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# ── Build ─────────────────────────────────────────────────────────────────────
|
# -- Build --
|
||||||
Write-Host "`n>> Building Release..." -ForegroundColor Cyan
|
Write-Host ""
|
||||||
|
Write-Host ">> Building Release..." -ForegroundColor Cyan
|
||||||
dotnet publish $Project -c Release -p:PublishSingleFile=true -o $PublishDir
|
dotnet publish $Project -c Release -p:PublishSingleFile=true -o $PublishDir
|
||||||
if ($LASTEXITCODE -ne 0) { exit 1 }
|
if ($LASTEXITCODE -ne 0) { exit 1 }
|
||||||
|
|
||||||
# ── Package ───────────────────────────────────────────────────────────────────
|
# -- Package --
|
||||||
Write-Host "`n>> Packaging $ZipName..." -ForegroundColor Cyan
|
Write-Host ""
|
||||||
|
Write-Host ">> Packaging $ZipName..." -ForegroundColor Cyan
|
||||||
$staging = "release_staging"
|
$staging = "release_staging"
|
||||||
if (Test-Path $staging) { Remove-Item $staging -Recurse -Force }
|
if (Test-Path $staging) { Remove-Item $staging -Recurse -Force }
|
||||||
New-Item -ItemType Directory -Path $staging | Out-Null
|
New-Item -ItemType Directory -Path $staging | Out-Null
|
||||||
@@ -64,62 +57,55 @@ Remove-Item $staging -Recurse -Force
|
|||||||
$zipSize = [math]::Round((Get-Item $ZipName).Length / 1MB, 1)
|
$zipSize = [math]::Round((Get-Item $ZipName).Length / 1MB, 1)
|
||||||
Write-Host " Created $ZipName ($zipSize MB)" -ForegroundColor Green
|
Write-Host " Created $ZipName ($zipSize MB)" -ForegroundColor Green
|
||||||
|
|
||||||
# ── Tag & Push ────────────────────────────────────────────────────────────────
|
# -- Tag and Push --
|
||||||
Write-Host "`n>> Tagging $Version and pushing..." -ForegroundColor Cyan
|
Write-Host ""
|
||||||
|
Write-Host ">> Tagging $Version and pushing..." -ForegroundColor Cyan
|
||||||
git tag $Version
|
git tag $Version
|
||||||
git push kawa main --tags
|
git push kawa main --tags
|
||||||
|
|
||||||
# ── Create Release ────────────────────────────────────────────────────────────
|
# -- Create Release --
|
||||||
Write-Host "`n>> Creating Gitea release..." -ForegroundColor Cyan
|
Write-Host ""
|
||||||
$headers = @{
|
Write-Host ">> Creating Gitea release..." -ForegroundColor Cyan
|
||||||
"Authorization" = "token $Token"
|
|
||||||
"Content-Type" = "application/json"
|
$releaseBody = ""
|
||||||
|
|
||||||
|
$jsonObj = @{ tag_name = $Version; name = "SharePoint Toolbox $Version"; body = $releaseBody }
|
||||||
|
$jsonPath = [System.IO.Path]::GetTempFileName()
|
||||||
|
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
|
||||||
|
[System.IO.File]::WriteAllText($jsonPath, ($jsonObj | ConvertTo-Json -Depth 3), $utf8NoBom)
|
||||||
|
|
||||||
|
$releaseJson = curl.exe -s -w "`n%{http_code}" -X POST "$GiteaUrl/api/v1/repos/$Repo/releases" -H "Authorization: token $Token" -H "Content-Type: application/json" -d "@$jsonPath"
|
||||||
|
Remove-Item $jsonPath
|
||||||
|
|
||||||
|
$lines = $releaseJson -split "`n"
|
||||||
|
$httpCode = $lines[-1]
|
||||||
|
$responseBody = ($lines[0..($lines.Length-2)] -join "`n")
|
||||||
|
|
||||||
|
if ($httpCode -ne "201") {
|
||||||
|
Write-Host " HTTP $httpCode - $responseBody" -ForegroundColor Red
|
||||||
|
Write-Error "Release creation failed."
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
$body = @{
|
$releaseId = ($responseBody | ConvertFrom-Json).id
|
||||||
tag_name = $Version
|
|
||||||
name = "SharePoint Toolbox $Version"
|
|
||||||
body = @"
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
1. Download **$ZipName** below
|
|
||||||
2. Extract the archive
|
|
||||||
3. Launch **SharepointToolbox.exe** (requires .NET 10 runtime)
|
|
||||||
|
|
||||||
## Included
|
|
||||||
|
|
||||||
- ``SharepointToolbox.exe`` — desktop application
|
|
||||||
- ``examples/`` — sample CSV templates for bulk operations
|
|
||||||
"@
|
|
||||||
} | ConvertTo-Json -Compress
|
|
||||||
|
|
||||||
$release = Invoke-RestMethod `
|
|
||||||
-Uri "$GiteaUrl/api/v1/repos/$Repo/releases" `
|
|
||||||
-Method Post `
|
|
||||||
-Headers $headers `
|
|
||||||
-Body $body
|
|
||||||
|
|
||||||
$releaseId = $release.id
|
|
||||||
Write-Host " Release created (ID: $releaseId)" -ForegroundColor Green
|
Write-Host " Release created (ID: $releaseId)" -ForegroundColor Green
|
||||||
|
|
||||||
# ── Upload Asset ──────────────────────────────────────────────────────────────
|
# -- Upload Asset --
|
||||||
Write-Host "`n>> Uploading $ZipName..." -ForegroundColor Cyan
|
Write-Host ""
|
||||||
|
Write-Host ">> Uploading $ZipName..." -ForegroundColor Cyan
|
||||||
$uploadUrl = "$GiteaUrl/api/v1/repos/$Repo/releases/$releaseId/assets"
|
$uploadUrl = "$GiteaUrl/api/v1/repos/$Repo/releases/$releaseId/assets"
|
||||||
|
|
||||||
# Use curl for multipart upload (Invoke-RestMethod multipart is clunky)
|
curl.exe -sf -X POST $uploadUrl -H "Authorization: token $Token" -F "attachment=@$ZipName" | Out-Null
|
||||||
curl.exe -sf `
|
|
||||||
-X POST $uploadUrl `
|
|
||||||
-H "Authorization: token $Token" `
|
|
||||||
-F "attachment=@$ZipName" | Out-Null
|
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Write-Error "Asset upload failed."
|
Write-Error "Asset upload failed."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# ── Cleanup ───────────────────────────────────────────────────────────────────
|
# -- Cleanup --
|
||||||
Remove-Item $ZipName
|
Remove-Item $ZipName
|
||||||
Remove-Item $PublishDir -Recurse -Force
|
Remove-Item $PublishDir -Recurse -Force
|
||||||
|
|
||||||
Write-Host "`n>> Done! Release published at:" -ForegroundColor Green
|
Write-Host ""
|
||||||
|
Write-Host ">> Done! Release published at:" -ForegroundColor Green
|
||||||
Write-Host " $GiteaUrl/$Repo/releases/tag/$Version" -ForegroundColor Yellow
|
Write-Host " $GiteaUrl/$Repo/releases/tag/$Version" -ForegroundColor Yellow
|
||||||
|
|||||||
Reference in New Issue
Block a user