Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/scripts/Get-Version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,26 @@
2. Strip control characters
3. Remove patch version when 0 (keep major.minor and label)

.PARAMETER AsTag
Optional. Returns the version as a git tag (e.g., "v13" instead of "13.0"). Default = false.

.PARAMETER AsDotNetVersion
Optional. Indicates that the returned version should be in the format "x.x.x.x". Otherwise, semantic versioning is used. Deafult = false.
Optional. Indicates that the returned version should be in the format "x.x.x.x". Otherwise, semantic versioning is used. Default = false.

Comment thread
flanakin marked this conversation as resolved.
.EXAMPLE
./Get-Version

Gets the current version number.

.EXAMPLE
./Get-Version -AsTag

Gets the version as a git tag (e.g., "v13" instead of "13.0").
#>
param(
[switch]
$AsTag,

[switch]
$AsDotNetVersion
)
Expand All @@ -32,6 +43,11 @@ $ver = (Get-Content (Join-Path $PSScriptRoot ../../package.json) | ConvertFrom-J
-replace '^(\d+\.\d+)(\.0)?(-[a-z]+)?(\.\d+)?$', '$1$3$4' `
-replace '(-[a-z]+)\.0$', '$1'

if ($AsTag)
{
return 'v' + ($ver -replace '\.0$', '')
}

if ($AsDotNetVersion -and $ver.Contains('-'))
{
$arr = (($ver -replace '-[^\.0-9]+', '') -split '\.') + @(0, 0)
Expand Down
5 changes: 3 additions & 2 deletions src/scripts/Package-Toolkit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ if ($Template -ne "*" -and -not (Test-Path $relDir))

function Copy-TemplateFiles()
{
Write-Host "Packaging $(if ($Template) { "$Template v$version template" } else { "v$version templates" })..."
Write-Host "Packaging $(if ($Template -ne "*") { "$Template $version template" } else { "$version templates" })..."

Write-Verbose "Removing existing ZIP files..."
Remove-Item "$relDir/*.zip" -Force
Expand Down Expand Up @@ -115,7 +115,7 @@ function Copy-TemplateFiles()
$zip = if ($unversionedZip) {
Join-Path (Get-Item $relDir) "$templateName.zip"
} else {
Join-Path (Get-Item $relDir) "$templateName-v$version.zip"
Join-Path (Get-Item $relDir) "$templateName-$tag.zip"
}

Write-Verbose "Checking for a nested version folder: $versionSubFolder"
Expand Down Expand Up @@ -201,6 +201,7 @@ function Copy-OpenDataFolders()
}

$version = & "$PSScriptRoot/Get-Version"
$tag = & "$PSScriptRoot/Get-Version" -AsTag

if ($CopyFiles -or $Build -or $Preview -or -not ($OpenPBI -or $ZipPBI))
{
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/Update-Version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ if ($update -or $Version)
{
# Update version files: ftkver.txt (major.minor) and ftktag.txt (git tag, e.g., "v13")
$repoRoot = (Resolve-Path "$PSScriptRoot/../..").Path
$tag = 'v' + ($ver -replace '\.0$', '')
$tag = & "$PSScriptRoot/Get-Version" -AsTag
foreach ($entry in @{ 'ftkver.txt' = $ver; 'ftktag.txt' = $tag }.GetEnumerator())
{
Write-Verbose "Updating $($entry.Key) files..."
Expand Down