Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/jfrog/jfrog-cli into fix-table
Browse files Browse the repository at this point in the history
# Conflicts:
#	go.mod
#	go.sum
  • Loading branch information
sverdlov93 committed Jan 9, 2024
2 parents 91b8c95 + ae8e79e commit 3301a8b
Show file tree
Hide file tree
Showing 9 changed files with 199 additions and 71 deletions.
86 changes: 51 additions & 35 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ node("docker") {
identifier = 'v2-jf'
nodeVersion = 'v8.17.0'

masterBranch = 'v2'
devBranch = 'dev'
if (BRANCH?.trim() == 'v1') {
masterBranch = 'v1'
devBranch = 'dev-v1'
}

releaseVersion = ''

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

stage('synchronize branches') {
masterBranch = 'v2'
devBranch = 'dev'
if (BRANCH?.trim() == 'v1') {
masterBranch = 'v1'
devBranch = 'dev-v1'
}
synchronizeBranches(masterBranch, devBranch)
stage('Sync branches') {
setReleaseVersion()
validateReleaseVersion()
synchronizeBranches()
}

stage('install npm') {
stage('Install npm') {
installNpm(nodeVersion)
}

Expand All @@ -80,6 +85,11 @@ node("docker") {
}
}

def getCliVersion(exePath) {
version = sh(script: "$exePath -v | tr -d 'jfrog version' | tr -d '\n'", returnStdout: true)
return version
}

def runRelease(architectures) {
stage('Build JFrog CLI') {
sh "echo Running release for executable name: '$cliExecutableName'"
Expand All @@ -95,14 +105,13 @@ def runRelease(architectures) {
}

sh "mv $jfrogCliRepoDir/$cliExecutableName $builderDir"
// Extract CLI version
version = sh(script: "$builderPath -v | tr -d 'jfrog version' | tr -d '\n'", returnStdout: true)

version = getCliVersion(builderPath)
print "CLI version: $version"
}
configRepo21()

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

def synchronizeBranches(masterBranch, devBranch) {
def setReleaseVersion() {
dir("$cliWorkspace/$repo") {
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')]) {
stage("Merge to $masterBranch") {
sh """#!/bin/bash
git merge origin/$devBranch --no-edit
git push "https://$GITHUB_ACCESS_TOKEN@github.com/jfrog/jfrog-cli.git"
"""
}
stage("Merge to $devBranch") {
sh """#!/bin/bash
git checkout $devBranch
git merge origin/$masterBranch --no-edit
git push "https://$GITHUB_ACCESS_TOKEN@github.com/jfrog/jfrog-cli.git"
git checkout $masterBranch
"""
}
print "Merge to $masterBranch"
sh """#!/bin/bash
git checkout $masterBranch
git merge origin/$devBranch --no-edit
git push "https://$GITHUB_ACCESS_TOKEN@github.com/jfrog/jfrog-cli.git"
"""

print "Merge to $devBranch"
sh """#!/bin/bash
git checkout $devBranch
git merge origin/$masterBranch --no-edit
git push "https://$GITHUB_ACCESS_TOKEN@github.com/jfrog/jfrog-cli.git"
git checkout $masterBranch
"""
}
}
}

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 @@ -201,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
111 changes: 111 additions & 0 deletions build/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/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
validateArg() {
# Check if both arguments are provided
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

# Check if arguments are non-empty
if [ -z "$fromVersion" ] || [ -z "$toVersion" ]; then
echo "Error: Both fromVersion and toVersion must have non-empty values."
exit 1
fi

# Check if arguments are not identical
if [ "$fromVersion" = "$toVersion" ]; then
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
replaceVersion() {
local filePath=$1
local line=$2
local fromVersion=$3
local toVersion=$4

# Check if the file exists
if [ ! -e "$filePath" ]; then
echo "Error: File '$filePath' not found."
exit 1
fi

# Use awk to replace the value if the line is found
awk -v line="$line" -v from="$fromVersion" -v to="$toVersion" '
index($0, line) {
gsub(from, to);
found=1;
}
{ print }
END {
if (found != 1) {
print "Error: The specified line ('" line "') does not exist in the file ('" filePath "').";
exit 1;
}
}
' "$filePath" > "$filePath.tmp" && mv "$filePath.tmp" "$filePath"

# Validate if the file was modified using git
if git diff --exit-code "$filePath" > /dev/null; then
echo "Error: File '$filePath' was not modified."
exit 1
fi

git add "$filePath"
}

## Validate the argument was received.
validateArg

## 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
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
21 changes: 11 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,27 @@ require (
github.com/jfrog/gofrog v1.4.1
github.com/jfrog/jfrog-cli-core/v2 v2.47.10
github.com/jfrog/jfrog-client-go v1.35.6
github.com/jszwec/csvutil v1.9.0
github.com/jszwec/csvutil v1.8.0
github.com/mholt/archiver/v3 v3.5.1
github.com/stretchr/testify v1.8.4
github.com/testcontainers/testcontainers-go v0.23.0
github.com/urfave/cli v1.22.14
github.com/vbauerster/mpb/v7 v7.5.3
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc
golang.org/x/term v0.16.0
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b
golang.org/x/term v0.15.0
gopkg.in/yaml.v2 v2.4.0
)

require github.com/jedib0t/go-pretty/v6 v6.4.0 // indirect; Should not be updated to v6.4.1+ due to a bug (https://github.com/jfrog/jfrog-cli-core/pull/1045)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/CycloneDX/cyclonedx-go v0.7.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect
github.com/Microsoft/hcsshim v0.11.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
Expand All @@ -38,14 +40,14 @@ require (
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/containerd/containerd v1.7.11 // indirect
github.com/containerd/containerd v1.7.7 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v24.0.7+incompatible // indirect
github.com/docker/docker v24.0.6+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
Expand All @@ -63,7 +65,6 @@ require (
github.com/gookit/color v1.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jedib0t/go-pretty/v6 v6.5.0 // indirect
github.com/jfrog/archiver/v3 v3.5.3 // indirect
github.com/jfrog/jfrog-apps-config v1.0.1 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
Expand All @@ -90,7 +91,7 @@ require (
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pierrec/lz4/v4 v4.1.2 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/term v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
Expand Down Expand Up @@ -119,7 +120,7 @@ require (
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.16.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
Expand All @@ -130,7 +131,7 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240107151040-a15eecc3fe2d
// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240104095135-8e243b03531d

// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20231220105505-e62769dde9da

Expand Down
Loading

0 comments on commit 3301a8b

Please sign in to comment.