teamsiso/commit-and-push.ps1

46 lines
2 KiB
PowerShell
Raw Permalink Normal View History

# Build + test verification, then push the current branch to origin.
#
# Run from the repo root:
# pwsh -ExecutionPolicy Bypass -File .\commit-and-push.ps1
#
# This is the operator's "I'm done with this branch, ship it" helper. It
# runs build-and-test.ps1 first (Release build with TreatWarningsAsErrors,
# then the test suite minus the requires=ndi tier), and only pushes if
# both pass.
#
# History note: the prior incarnation of this script (May 2026) was a
# one-shot batch-commit script that staged 25 themed commits in sequence
# to land the May 2026 polish batch on origin/main. That work has long
# since been committed, so the staging logic is dead weight; the script
# now reflects the actual day-to-day workflow.
$ErrorActionPreference = 'Stop'
if (-not (Test-Path '.git') -or -not (Test-Path 'TeamsISO.sln')) {
throw "Run from the TeamsISO repo root."
}
# Step 1 — build + tests must be green before anything ships.
Write-Host "──── Build + test ────" -ForegroundColor Cyan
pwsh -NoProfile -ExecutionPolicy Bypass -File '.\build-and-test.ps1'
if ($LASTEXITCODE -ne 0) { throw "build-and-test.ps1 failed; aborting." }
# Step 2 — what are we pushing? Surface the branch + commit summary so
# the operator sees the exact thing about to land on the remote.
$branch = (git rev-parse --abbrev-ref HEAD).Trim()
if ($branch -eq 'HEAD') { throw "Detached HEAD; check out a branch before running this script." }
Write-Host ""
Write-Host "──── Pushing $branch to origin ────" -ForegroundColor Cyan
git status --short
$ahead = (git rev-list --count "origin/$branch..HEAD" 2>$null)
if (-not $ahead) { $ahead = (git rev-list --count HEAD).Trim() }
Write-Host " $ahead commit(s) to push." -ForegroundColor DarkGray
git push origin $branch
if ($LASTEXITCODE -ne 0) { throw "git push failed." }
Write-Host ""
Write-Host "Done. Pushed $branch to origin." -ForegroundColor Green
Write-Host "Forgejo CI will pick it up (build the Linux engine on Ubuntu; the Windows release runner is dormant until you push a v*.*.* tag)." -ForegroundColor DarkGray