From 4d6326f6bf4cdd7c60b31c409e3d24776a9a57a6 Mon Sep 17 00:00:00 2001 From: eyalbe4 Date: Thu, 28 Nov 2024 19:22:08 +0200 Subject: [PATCH] Bump version to 2.72.1 --- build/bump-version.ps1 | 132 ++++++++++++++++++++++++++++++ build/npm/v2-jf/package-lock.json | 2 +- build/npm/v2-jf/package.json | 2 +- build/npm/v2/package-lock.json | 2 +- build/npm/v2/package.json | 2 +- go.mod | 6 +- go.sum | 12 +-- utils/cliutils/cli_consts.go | 2 +- 8 files changed, 146 insertions(+), 14 deletions(-) create mode 100644 build/bump-version.ps1 diff --git a/build/bump-version.ps1 b/build/bump-version.ps1 new file mode 100644 index 000000000..c07ab50e5 --- /dev/null +++ b/build/bump-version.ps1 @@ -0,0 +1,132 @@ +# Check if exactly one argument is provided +if ($args.Count -ne 1) { + Write-Error "Error: Please provide exactly one argument - the version to bump." + exit 1 +} + +# Assign the argument to the toVersion variable +$toVersion = $args[0] + +# Debugging output for toVersion +Write-Host "Running bump-version.ps1 with toVersion: '$toVersion'" + +if (-not $toVersion) { + Write-Error "Error: toVersion is not set. Exiting." + exit 1 +} + +# Function to get fromVersion from a file +function Populate-FromVersion { + & build/build.bat + $versionString = & ./jf -v + Write-Host "Debug: versionString='$versionString'" + + # Extract the version from the output (e.g., 'jf version 2.71.5') + if ($versionString -match "jf version ([0-9]+\.[0-9]+\.[0-9]+)") { + $global:fromVersion = $matches[1] + } else { + Write-Error "Error: Failed to extract fromVersion. Unexpected format: '$versionString'." + exit 1 + } + + Write-Host "Debug: fromVersion='$global:fromVersion'" +} + +# Function to validate versions +function Validate-Versions { + param ( + [string]$fromVersion, + [string]$toVersion + ) + + Write-Host "Debug: Validating versions - fromVersion='$fromVersion', toVersion='$toVersion'" + + if (-not $fromVersion -or -not $toVersion) { + Write-Error "Error: Both fromVersion and toVersion must have non-empty values." + exit 1 + } + + if ($fromVersion -eq $toVersion) { + Write-Error "Error: fromVersion and toVersion must have different values." + exit 1 + } + + Write-Host "Bumping version from $fromVersion to $toVersion" +} + +# Function to create a new Git branch +function Create-Branch { + $branchName = "bump-ver-from-$fromVersion-to-$toVersion" + + Write-Host "Creating and switching to a new branch: $branchName" + git remote rm upstream 2>$null + git remote add upstream https://github.com/jfrog/jfrog-cli.git + git checkout dev + git fetch upstream dev + git reset --hard upstream/dev + git push origin dev + git checkout -b $branchName +} + +# Function to replace a version in a file +function Replace-Version { + param ( + [string]$filePath, + [string]$linePattern, + [string]$fromVersion, + [string]$toVersion + ) + + if (-not (Test-Path $filePath)) { + Write-Error "Error: File '$filePath' not found." + exit 1 + } + + Write-Host "Replacing version in file: $filePath" + Write-Host "Looking for pattern: $linePattern" + + # Read the content, replace the line, and write it back + $content = Get-Content -Path $filePath + $found = $false + $newContent = $content | ForEach-Object { + if ($_ -match $linePattern) { + $found = $true + $_ -replace [regex]::Escape($fromVersion), $toVersion + } else { + $_ + } + } + + if (-not $found) { + Write-Error "Error: Pattern '$linePattern' not found in file '$filePath'." + exit 1 + } + + Set-Content -Path $filePath -Value $newContent + git add $filePath +} + +# Main Script +Populate-FromVersion +Validate-Versions -fromVersion $fromVersion -toVersion $toVersion +Create-Branch + +# Replace versions in specified files +Replace-Version -filePath "utils/cliutils/cli_consts.go" -linePattern 'CliVersion = "' -fromVersion $fromVersion -toVersion $toVersion +Replace-Version -filePath "build/npm/v2/package-lock.json" -linePattern '"version": "' -fromVersion $fromVersion -toVersion $toVersion +Replace-Version -filePath "build/npm/v2/package.json" -linePattern '"version": "' -fromVersion $fromVersion -toVersion $toVersion +Replace-Version -filePath "build/npm/v2-jf/package-lock.json" -linePattern '"version": "' -fromVersion $fromVersion -toVersion $toVersion +Replace-Version -filePath "build/npm/v2-jf/package.json" -linePattern '"version": "' -fromVersion $fromVersion -toVersion $toVersion + +# Commit and push changes +Write-Host "Committing and pushing changes" + +# Commit the changes with a descriptive message +git commit -m "Bump version from $fromVersion to $toVersion" + +# Push the branch to the remote repository +$branchName = "bump-ver-from-$fromVersion-to-$toVersion" +git push --set-upstream origin $branchName + +# Success message +Write-Host ('Version bump successfully completed and pushed to branch: bump-ver-from-' + $fromVersion + '-to-' + $toVersion) diff --git a/build/npm/v2-jf/package-lock.json b/build/npm/v2-jf/package-lock.json index e37f0140c..ddaa76759 100644 --- a/build/npm/v2-jf/package-lock.json +++ b/build/npm/v2-jf/package-lock.json @@ -1,5 +1,5 @@ { "name": "jfrog-cli-v2-jf", - "version": "2.72.0", + "version": "2.72.1", "lockfileVersion": 1 } diff --git a/build/npm/v2-jf/package.json b/build/npm/v2-jf/package.json index a5c806754..2aaf3cff0 100644 --- a/build/npm/v2-jf/package.json +++ b/build/npm/v2-jf/package.json @@ -1,6 +1,6 @@ { "name": "jfrog-cli-v2-jf", - "version": "2.72.0", + "version": "2.72.1", "description": "🐸 Command-line interface for JFrog Artifactory, Xray, Distribution, Pipelines and Mission Control 🐸", "homepage": "https://github.com/jfrog/jfrog-cli", "preferGlobal": true, diff --git a/build/npm/v2/package-lock.json b/build/npm/v2/package-lock.json index 64a10c50e..b3079948f 100644 --- a/build/npm/v2/package-lock.json +++ b/build/npm/v2/package-lock.json @@ -1,5 +1,5 @@ { "name": "jfrog-cli-v2", - "version": "2.72.0", + "version": "2.72.1", "lockfileVersion": 2 } diff --git a/build/npm/v2/package.json b/build/npm/v2/package.json index c1e57fd4b..43794f8a1 100644 --- a/build/npm/v2/package.json +++ b/build/npm/v2/package.json @@ -1,6 +1,6 @@ { "name": "jfrog-cli-v2", - "version": "2.72.0", + "version": "2.72.1", "description": "🐸 Command-line interface for JFrog Artifactory, Xray, Distribution, Pipelines and Mission Control 🐸", "homepage": "https://github.com/jfrog/jfrog-cli", "preferGlobal": true, diff --git a/go.mod b/go.mod index ac55a1b44..12f4c87fa 100644 --- a/go.mod +++ b/go.mod @@ -19,10 +19,10 @@ require ( github.com/jfrog/build-info-go v1.10.6 github.com/jfrog/gofrog v1.7.6 github.com/jfrog/jfrog-cli-artifactory v0.1.7 - github.com/jfrog/jfrog-cli-core/v2 v2.57.0 + github.com/jfrog/jfrog-cli-core/v2 v2.57.1 github.com/jfrog/jfrog-cli-platform-services v1.4.0 - github.com/jfrog/jfrog-cli-security v1.13.2 - github.com/jfrog/jfrog-client-go v1.48.1 + github.com/jfrog/jfrog-cli-security v1.13.3 + github.com/jfrog/jfrog-client-go v1.48.3 github.com/jszwec/csvutil v1.10.0 github.com/manifoldco/promptui v0.9.0 github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index 379826f9b..9e78ec157 100644 --- a/go.sum +++ b/go.sum @@ -171,14 +171,14 @@ github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYL github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w= github.com/jfrog/jfrog-cli-artifactory v0.1.7 h1:/PBDO6nS6cf3PK+GRkd6BJtZnvYasi1PrQhRiayirso= github.com/jfrog/jfrog-cli-artifactory v0.1.7/go.mod h1:M5pZTHnsYNDmml/FAnoxxt4QiHOIUHPx91th30AtwfM= -github.com/jfrog/jfrog-cli-core/v2 v2.57.0 h1:3ON0J6Sjc2+4HZrzh4eSbdciXx3sJsJUIJ3TPQXh/5c= -github.com/jfrog/jfrog-cli-core/v2 v2.57.0/go.mod h1:SThaC/fniC96oN8YgCsHjvOxp5rBM7IppuIybn1oxT0= +github.com/jfrog/jfrog-cli-core/v2 v2.57.1 h1:YVuiSoavDisE8Dc9TOhYo5fE3d2C4/BrXuLDO/SZpJo= +github.com/jfrog/jfrog-cli-core/v2 v2.57.1/go.mod h1:e95/VWV6LL+UUxSNTJZ+sLmqJhCO5lDRhhLUQMV8WK4= github.com/jfrog/jfrog-cli-platform-services v1.4.0 h1:g6A30+tOfXd1h6VASeNwH+5mhs5bPQJ0MFzZs/4nlvs= github.com/jfrog/jfrog-cli-platform-services v1.4.0/go.mod h1:Ky4SDXuMeaiNP/5zMT1YSzIuXG+cNYYOl8BaEA7Awbc= -github.com/jfrog/jfrog-cli-security v1.13.2 h1:60WO6PjtIQz/21EzggDzUoeK6ScDrNAYXA0k1cqcZqQ= -github.com/jfrog/jfrog-cli-security v1.13.2/go.mod h1:0oEKO2/vVvBC3m9SSWcKx4tWG6sPmvy4Mn4RD2zlSEQ= -github.com/jfrog/jfrog-client-go v1.48.1 h1:R6x6gazy0F196XXDhDdRAxmNplSJ5SrJfEmmNBgks/8= -github.com/jfrog/jfrog-client-go v1.48.1/go.mod h1:1a7bmQHkRmPEza9wva2+WVrYzrGbosrMymq57kyG5gU= +github.com/jfrog/jfrog-cli-security v1.13.3 h1:eaZ3Os3bcho8Gm2Kw07xdKvmQLchSJljRqBtZ6iFmnw= +github.com/jfrog/jfrog-cli-security v1.13.3/go.mod h1:GNf/qXZuSsYXfGBH9qobE6Vz5glaGqNpRgU3LWnBrAQ= +github.com/jfrog/jfrog-client-go v1.48.3 h1:HJpKGul0f/S2i7Uf7K/GwS1EUGiirt1LWXL1lanKNhU= +github.com/jfrog/jfrog-client-go v1.48.3/go.mod h1:1a7bmQHkRmPEza9wva2+WVrYzrGbosrMymq57kyG5gU= github.com/jszwec/csvutil v1.10.0 h1:upMDUxhQKqZ5ZDCs/wy+8Kib8rZR8I8lOR34yJkdqhI= github.com/jszwec/csvutil v1.10.0/go.mod h1:/E4ONrmGkwmWsk9ae9jpXnv9QT8pLHEPcCirMFhxG9I= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= diff --git a/utils/cliutils/cli_consts.go b/utils/cliutils/cli_consts.go index 6ffb56a42..e606a9a03 100644 --- a/utils/cliutils/cli_consts.go +++ b/utils/cliutils/cli_consts.go @@ -4,7 +4,7 @@ import "time" const ( // General CLI constants - CliVersion = "2.72.0" + CliVersion = "2.72.1" ClientAgent = "jfrog-cli-go" // CLI base commands constants: