-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPublish.ps1
More file actions
50 lines (41 loc) · 1.38 KB
/
Publish.ps1
File metadata and controls
50 lines (41 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Panoramic Data NuGet Publish Script (Standard)
# Tags the current commit with the NBGV version and pushes to trigger CI/CD publishing.
# Usage: .\Publish.ps1
$ErrorActionPreference = 'Stop'
# Check for clean working tree
$status = git status --porcelain
if ($status) {
Write-Error "Working tree is not clean. Commit or stash changes before publishing.`n$status"
exit 1
}
# Ensure we are on the main branch
$branch = git rev-parse --abbrev-ref HEAD
if ($branch -ne 'main') {
Write-Error "Publishing is only supported from the 'main' branch (currently on '$branch')."
exit 1
}
# Ensure local main is up to date with remote
git fetch origin main --quiet
$localHead = git rev-parse HEAD
$remoteHead = git rev-parse origin/main
if ($localHead -ne $remoteHead) {
Write-Error "Local branch is not up to date with origin/main. Pull or push first."
exit 1
}
# Get version from NBGV
$versionJson = nbgv get-version -f json | ConvertFrom-Json
$version = $versionJson.SimpleVersion
if (-not $version) {
Write-Error "Failed to determine version from nbgv."
exit 1
}
# Check tag doesn't already exist
$existingTag = git tag -l $version
if ($existingTag) {
Write-Error "Tag '$version' already exists."
exit 1
}
Write-Information "Tagging as $version ..."
git tag $version
git push origin $version
Write-Information "Published tag $version - CI will build and push to NuGet."