forked from embryonik-io/kubeadm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.ps1
53 lines (43 loc) · 1.37 KB
/
version.ps1
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
51
52
53
$ErrorActionPreference = 'Stop'
Import-Module -WarningAction Ignore -Name "$PSScriptRoot\utils.psm1"
$DIRTY = ""
if ("$(git status --porcelain --untracked-files=no)") {
$DIRTY = "-dirty"
}
$COMMIT = $(git rev-parse --short HEAD)
$GIT_TAG = $env:BUILD_TAG
if (-not $GIT_TAG) {
$GIT_TAG = $(git tag -l --contains HEAD | Select-Object -First 1)
}
$env:COMMIT = $COMMIT
$VERSION = "${env:COMMIT}${DIRTY}"
if ((-not $DIRTY) -and ($GIT_TAG)) {
$VERSION = "${GIT_TAG}"
}
$env:VERSION = $VERSION
$TAG = ('{0}{1}' -f $env:VERSION, $env:SUFFIX)
if ($TAG | Select-String -Pattern 'dirty') {
$TAG = "dev"
}
if (-not $env:REPO) {
$env:REPO = "embryonik-io"
}
if (($env:BUILD_TAG) -and (-Not ($TAG).Contains("dev") -or -Not ($TAG).Contains("dirty"))){
$TAG = $env:BUILD_TAG
$env:TAG = $TAG
} else {
$env:TAG = $TAG
}
if (-not $env:ARCH) {
$env:ARCH = "amd64"
}
$buildTags = @{ "17763" = "1809"; "20348" = "ltsc2022";}
$buildNumber = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\' -ErrorAction Ignore).CurrentBuildNumber
$env:SERVERCORE_VERSION = $buildTags[$buildNumber]
if (-not $env:SERVERCORE_VERSION) {
$env:SERVERCORE_VERSION = "1809"
}
Write-Host "ARCH: $env:ARCH"
Write-Host "VERSION: $env:VERSION"
Write-Host "TAG: $env:TAG"
Write-Host "SERVERCORE_VERSION: $env:SERVERCORE_VERSION"