forked from lmm713281/etlbox
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbump-version.ps1
38 lines (29 loc) · 1.13 KB
/
bump-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
param (
[string]$branch
)
# Read the .version.yml file
$versionFile = ".version.yml"
$versionContent = Get-Content $versionFile -Raw
# Extract the current version numbers
$currentRelease = [regex]::Match($versionContent, 'PACKAGE_RELEASE:\s*(\d+\.\d+\.\d+)').Groups[1].Value
# Split the version into its components
$versionParts = $currentRelease -split '\.'
$major = [int]$versionParts[0]
$minor = [int]$versionParts[1]
$build = [int]$versionParts[2]
# Update the version based on the branch
if ($branch -eq "develop") {
$build++
} elseif ($branch -eq "master") {
$minor++
$build = 0
}
# Construct the new version
$newRelease = "$major.$minor.$build"
# Update the version in the YAML content
$newVersionContent = [regex]::Replace($versionContent, 'PACKAGE_RELEASE:\s*\d+\.\d+\.\d+', "PACKAGE_RELEASE: $newRelease")
# Write the updated content back to the .version.yml file
Set-Content -Path $versionFile -Value $newVersionContent
Write-Output "Version updated to $newRelease"
# Output the environment variable in a format that can be sourced by bash
"PACKAGE_RELEASE=$newRelease" | Out-File -FilePath /tmp/env-vars.sh -Encoding ascii