Updates to work with branch-specific maven deployments in/with circleci

This commit is contained in:
2023-05-09 13:00:49 -05:00
parent 2c7919abce
commit 88e24a08fc
3 changed files with 51 additions and 5 deletions

View File

@ -9,6 +9,34 @@ CURRENT_VERSION="$(cat $QQQ_DEV_TOOLS_DIR/CURRENT-SNAPSHOT-VERSION)"
MODULE_LIST_FILE=$QQQ_DEV_TOOLS_DIR/MODULE_LIST MODULE_LIST_FILE=$QQQ_DEV_TOOLS_DIR/MODULE_LIST
. $QQQ_DEV_TOOLS_DIR/.env . $QQQ_DEV_TOOLS_DIR/.env
BRANCH=$(git rev-parse --abbrev-ref HEAD)
SLUG=$(echo $BRANCH | sed 's/[^a-zA-Z0-9]/-/g')
function checkForBranchBuild
{
artifact=$1
#############################################################
## on standard branches, don't look for branch deployments ##
#############################################################
if [ "$BRANCH" == "dev" ] || [ "$BRANCH" == "staging" ] || [ "$BRANCH" == "main" ]; then
echo 0;
return;
fi
###################################################################
## else, do look for a branch deployment, and return accordingly ##
###################################################################
curl -s --user ${GITHUB_USER}:${GITHUB_TOKEN} https://maven.pkg.github.com/Kingsrook/qqq-maven-registry/com/kingsrook/qqq/${artifact}/${SLUG}-SNAPSHOT/maven-metadata.xml | grep unable.to.fetch
if [ "$?" == "1" ]; then
echo 1;
return;
fi
echo 0;
return;
}
function getLatestVersion function getLatestVersion
{ {
artifact=$1 artifact=$1
@ -23,10 +51,10 @@ function getLatestVersion
return return
fi fi
timetsamp=$(xpath -q -e '/metadata/versioning/snapshot/timestamp/text()' /tmp/metadata.xml) timestamp=$(xpath -q -e '/metadata/versioning/snapshot/timestamp/text()' /tmp/metadata.xml)
buildNumber=$(xpath -q -e '/metadata/versioning/snapshot/buildNumber/text()' /tmp/metadata.xml) buildNumber=$(xpath -q -e '/metadata/versioning/snapshot/buildNumber/text()' /tmp/metadata.xml)
echo "$version-$timetsamp-$buildNumber" echo "$version-$timestamp-$buildNumber"
} }
function promptForVersion function promptForVersion
@ -70,11 +98,18 @@ else
artifact=$1 artifact=$1
version=$2 version=$2
if [ "$version" == "-l" ]; then if [ "$version" == "-l" ]; then
version=$CURRENT_VERSION useSlug=$(checkForBranchBuild $artifact)
if [ "$useSlug" == "1" ]; then
version=$SLUG
else
version=$CURRENT_VERSION
fi
echo "Using $version for $artifact" >&2
fi fi
if [ -z "$artifact" -o -z "$version" ]; then if [ -z "$ar^tifact" -o -z "$version" ]; then
echo "Usage: $0 artifact snapshot-version-prefix" echo "Usage: $0 artifact snapshot-version-prefix"
echo " or: $0 artifact -l (latest of CURRENT_VERSION, or branch-slug, if it has been deployed)"
echo " or: $0 -i (interactive mode)" echo " or: $0 -i (interactive mode)"
echo " or: $0 -a [snapshot-version-prefix] (all mode)" echo " or: $0 -a [snapshot-version-prefix] (all mode)"
echo "Ex: $0 qqq-backend-core $CURRENT_VERSION" echo "Ex: $0 qqq-backend-core $CURRENT_VERSION"

View File

@ -3,6 +3,11 @@
############################################################################ ############################################################################
## git-tag ## git-tag
## Add (deleting, if it already exists) a git tag to a repo (both local & remote) ## Add (deleting, if it already exists) a git tag to a repo (both local & remote)
##
## Usage:
## git-tag tag-name - make/update/push the specified tag-name.
## git-tag -l - list tags.
## git-tag snapshot-BRANCH_SLUG - make the tag name "snapshot-" + current branch name, in "slug" form
############################################################################ ############################################################################
TAG=$1 TAG=$1
@ -16,6 +21,12 @@ if [ "$TAG" == "-l" ]; then
exit 0; exit 0;
fi fi
if [ "$TAG" == "snapshot-BRANCH_SLUG" ]; then
BRANCH=$(git rev-parse --abbrev-ref HEAD)
SLUG=$(echo $BRANCH | sed 's/[^a-zA-Z0-9]/-/g')
TAG="snapshot-$SLUG"
fi
echo echo
echo "== Deleting $TAG on local" echo "== Deleting $TAG on local"
git tag -d $TAG git tag -d $TAG

View File

@ -15,7 +15,7 @@ MODULE_LIST_FILE=$QQQ_DEV_TOOLS_DIR/MODULE_LIST
for module in $(cat $MODULE_LIST_FILE); do for module in $(cat $MODULE_LIST_FILE); do
echo "Updating $module..." echo "Updating $module..."
version=$(get-latest-snapshot.sh $module $CURRENT_VERSION) version=$(get-latest-snapshot.sh $module -l)
update-dep.sh $module $version -q update-dep.sh $module $version -q
done done