Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrog-ecosystem committed Jan 7, 2024
2 parents d101242 + 98bc97c commit d6244ff
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 34 deletions.
37 changes: 15 additions & 22 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ node("docker") {
devBranch = 'dev-v1'
}

releaseVersion = ''

repo = 'jfrog-cli'
sh 'rm -rf temp'
sh 'mkdir temp'
Expand Down Expand Up @@ -61,11 +63,9 @@ node("docker") {
"""
}

stage('Bump version') {
bumpVersion()
}

stage('Sync branches') {
setReleaseVersion()
validateReleaseVersion()
synchronizeBranches()
}

Expand Down Expand Up @@ -112,7 +112,6 @@ def runRelease(architectures) {
configRepo21()

try {
validateReleaseVersion()
if (identifier != "v2") {
stage("Audit") {
dir("$jfrogCliRepoDir") {
Expand Down Expand Up @@ -174,22 +173,16 @@ def runRelease(architectures) {
}
}

def bumpVersion() {
def setReleaseVersion() {
dir("$cliWorkspace/$repo") {
withCredentials([string(credentialsId: 'ecosystem-github-automation', variable: 'GITHUB_ACCESS_TOKEN')]) {
sh "git checkout $devBranch"
sh "build/build.sh"
fromVersion = getCliVersion("./jf")
sh "build/bump-version.sh $fromVersion $RELEASE_VERSION"
sh "git commit -m \"Bump version from $fromVersion to $RELEASE_VERSION\""
sh "git push \"https://$GITHUB_ACCESS_TOKEN@github.com/jfrog/jfrog-cli.git\""
}
sh "git checkout $devBranch"
sh "build/build.sh"
releaseVersion = getCliVersion("./jf")
}
}

def synchronizeBranches() {
dir("$cliWorkspace/$repo") {
releaseTag = "v$RELEASE_VERSION"
withCredentials([string(credentialsId: 'ecosystem-github-automation', variable: 'GITHUB_ACCESS_TOKEN')]) {
print "Merge to $masterBranch"
sh """#!/bin/bash
Expand All @@ -212,7 +205,7 @@ def synchronizeBranches() {
def createTag() {
stage('Create a tag and a GitHub release') {
dir("$jfrogCliRepoDir") {
releaseTag = "v$RELEASE_VERSION"
releaseTag = "v$releaseVersion"
withCredentials([string(credentialsId: 'ecosystem-github-automation', variable: 'GITHUB_ACCESS_TOKEN')]) {
sh """#!/bin/bash
git tag $releaseTag
Expand All @@ -224,16 +217,16 @@ def createTag() {
}

def validateReleaseVersion() {
if (RELEASE_VERSION=="") {
error "RELEASE_VERSION parameter is mandatory on this execution mode"
if (releaseVersion=="") {
error "releaseVersion parameter is empty"
}
if (RELEASE_VERSION.startsWith("v")) {
error "RELEASE_VERSION parameter should not start with a preceding \"v\""
if (releaseVersion.startsWith("v")) {
error "releaseVersion parameter should not start with a preceding \"v\""
}
// Verify version stands in semantic versioning.
def pattern = /^2\.(\d+)\.(\d+)$/
if (!(RELEASE_VERSION =~ pattern)) {
error "RELEASE_VERSION is not a valid version"
if (!(releaseVersion =~ pattern)) {
error "releaseVersion is not a valid version"
}
}

Expand Down
49 changes: 42 additions & 7 deletions build/bump-version.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
#!/bin/bash

# Function to get fromVersion from a file
populateFromVersion() {
build/build.sh
fromVersion=$(./jf -v | tr -d 'jfrog version' | tr -d '\n')
}

# Function to validate arguments
validateArgs() {
validateArg() {
# Check if both arguments are provided
if [ $# -ne 2 ]; then
echo "Error: Please provide exactly two arguments - fromVersion and toVersion."
if [ $# -ne 1 ]; then
echo "Error: Please provide exactly one argument - the version to bump."
exit 1
fi
}

validateVersions() {
# Extract arguments
fromVersion=$1
toVersion=$2
Expand All @@ -23,6 +31,18 @@ validateArgs() {
echo "Error: fromVersion and toVersion must have different values."
exit 1
fi

echo Bumping version from $fromVersion to $toVersion
}

createBranch() {
branchName=bump-ver-from-$fromVersion-to-$toVersion
git remote add upstream https://github.com/jfrog/jfrog-cli.git
git checkout dev
git fetch upstream dev
git pull upstream dev
git push
git checkout -b $branchName
}

# Function to replace version in file
Expand Down Expand Up @@ -62,15 +82,30 @@ replaceVersion() {
git add "$filePath"
}

# Call the function to validate arguments
validateArgs "$@"
## Validate the argument was received.
validateArg

# Add calls to the function to replace version in file with specified filePath values
## Read the script argument into the toVersion variable
toVersion=$1

## Call the function to populate the fromVersion argument from the current version of the local JFrog CLI binary
populateFromVersion

## Call the function to validate arguments
validateVersions "$fromVersion" "$toVersion"

## Create a new branch
createBranch

## Add calls to the function to replace version in file with specified filePath values
replaceVersion "utils/cliutils/cli_consts.go" "CliVersion = \"$fromVersion\"" "$fromVersion" "$toVersion"
replaceVersion "build/npm/v2/package-lock.json" "\"version\": \"$fromVersion\"," "$fromVersion" "$toVersion"
replaceVersion "build/npm/v2/package.json" "\"version\": \"$fromVersion\"," "$fromVersion" "$toVersion"
replaceVersion "build/npm/v2-jf/package-lock.json" "\"version\": \"$fromVersion\"," "$fromVersion" "$toVersion"
replaceVersion "build/npm/v2-jf/package.json" "\"version\": \"$fromVersion\"," "$fromVersion" "$toVersion"

# Print success message if validation and replacement pass
## Print success message if validation and replacement pass
echo "Version bumped successfully."

## Push the new branch, with the version bump
git push --set-upstream origin $branchName
2 changes: 1 addition & 1 deletion build/npm/v2-jf/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/npm/v2-jf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jfrog-cli-v2-jf",
"version": "2.52.8",
"version": "2.52.9",
"description": "🐸 Command-line interface for JFrog Artifactory, Xray, Distribution, Pipelines and Mission Control 🐸",
"homepage": "https://github.com/jfrog/jfrog-cli",
"preferGlobal": true,
Expand Down
2 changes: 1 addition & 1 deletion build/npm/v2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/npm/v2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jfrog-cli-v2",
"version": "2.52.8",
"version": "2.52.9",
"description": "🐸 Command-line interface for JFrog Artifactory, Xray, Distribution, Pipelines and Mission Control 🐸",
"homepage": "https://github.com/jfrog/jfrog-cli",
"preferGlobal": true,
Expand Down
2 changes: 1 addition & 1 deletion utils/cliutils/cli_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "time"

const (
// General CLI constants
CliVersion = "2.52.8"
CliVersion = "2.52.9"
ClientAgent = "jfrog-cli-go"

// CLI base commands constants:
Expand Down

0 comments on commit d6244ff

Please sign in to comment.