From 0dbcb0e2f073d3e64886c3cf0f4174db6c2fa070 Mon Sep 17 00:00:00 2001 From: Jeff Nelson Date: Sat, 31 Oct 2026 19:52:51 -0400 Subject: [PATCH] Use the shared semantic version tool --- .agents | 2 +- .circleci/config.yml | 7 ++- .circleci/init-agent-skills.sh | 29 ++++++++++ .github/workflows/agents.yml | 2 +- build.gradle | 29 +++++++--- version.sh | 101 --------------------------------- 6 files changed, 58 insertions(+), 112 deletions(-) create mode 100644 .circleci/init-agent-skills.sh delete mode 100755 version.sh diff --git a/.agents b/.agents index 31f89b3..60986ed 160000 --- a/.agents +++ b/.agents @@ -1 +1 @@ -Subproject commit 31f89b30ce3f75f4b381156bf6ee1ce9752de45a +Subproject commit 60986ed0018283a8978f2567e4babad1036fb0c7 diff --git a/.circleci/config.yml b/.circleci/config.yml index c1d6c07..8ed749b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,6 +10,11 @@ jobs: steps: - checkout: path: ~/$CIRCLE_PROJECT_REPONAME + - run: + name: Initialize shared build tools + command: | + cd ~/$CIRCLE_PROJECT_REPONAME + bash .circleci/init-agent-skills.sh - run: name: Build and Upload context: cloudsmith-creds @@ -32,4 +37,4 @@ jobs: mkdir -p ~/artifacts/ find . -type f -regex ".*/build/libs/.*jar" -exec cp {} ~/artifacts/ \; - store_artifacts: - path: ~/artifacts \ No newline at end of file + path: ~/artifacts diff --git a/.circleci/init-agent-skills.sh b/.circleci/init-agent-skills.sh new file mode 100644 index 0000000..034c8d3 --- /dev/null +++ b/.circleci/init-agent-skills.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Check out the pinned private build tools with the existing checkout identity +# or an optional read-only identity. Remove temporary key material on every +# exit. +set +x +set -euo pipefail +cd "$(dirname "$0")/.." + +if [ -n "${CINCHAPI_AGENT_SKILLS_READ_KEY:-}" ]; then + umask 077 + key_file=$(mktemp) + trap 'rm -f "$key_file"' EXIT + printf '%s\n' "$CINCHAPI_AGENT_SKILLS_READ_KEY" > "$key_file" + if GIT_SSH_COMMAND="ssh -i '$key_file' -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes" \ + git submodule update --init .agents; then + : + else + printf '%s\n' 'The configured read key cannot fetch the pinned agent tools.' >&2 + exit 1 + fi +else + if git submodule update --init .agents; then + : + else + printf '%s\n' 'The checkout identity needs read access to cinchapi-agent-skills.' \ + 'Set CINCHAPI_AGENT_SKILLS_READ_KEY to a dedicated read-only key if needed.' >&2 + exit 1 + fi +fi diff --git a/.github/workflows/agents.yml b/.github/workflows/agents.yml index 5563698..8f8e6a3 100644 --- a/.github/workflows/agents.yml +++ b/.github/workflows/agents.yml @@ -67,7 +67,7 @@ jobs: concurrency: group: agents-${{ github.event.pull_request.number || github.event.issue.number || github.event.inputs.number }} queue: max - uses: cinchapi/cinchapi-agent-skills/.github/workflows/router.yml@31f89b30ce3f75f4b381156bf6ee1ce9752de45a + uses: cinchapi/cinchapi-agent-skills/.github/workflows/router.yml@60986ed0018283a8978f2567e4babad1036fb0c7 permissions: contents: read id-token: write diff --git a/build.gradle b/build.gradle index 2832f06..6ced325 100644 --- a/build.gradle +++ b/build.gradle @@ -73,23 +73,36 @@ exclusions.each { exclusion -> group = 'com.cinchapi' -// The project version is controlled externally by the "version.sh" script. +/** + * Return the publication coordinate without advancing the build counter. Branch + * suffix digits remain part of the coordinate. + */ +def getPublishedVersion = { buildVersion -> + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'bash', rootProject.file('.agents/tools/version'), + '--published', buildVersion.toString() + standardOutput = stdout + } + return stdout.toString().trim() +} + +/** + * Return one semantic build version for this project and advance its counter. + * Fail if the shared tool cannot read the version or identify the branch. + */ def getVersion = { -> def stdout = new ByteArrayOutputStream() exec { - commandLine 'bash', 'version.sh' + commandLine 'bash', rootProject.file('.agents/tools/version'), + '--root', rootProject.projectDir.absolutePath standardOutput = stdout } return stdout.toString().trim() } version = getVersion() -// Drop the build component from version number and use that for -// publishing -ext.mavenVersion = version.split('\\.') -ext.mavenVersion[3] = ext.mavenVersion[3].replaceAll("[0-9]+-", "-") -ext.mavenVersion[3] = ext.mavenVersion[3].replaceAll("[0-9]+", "").trim() -ext.mavenVersion = ext.mavenVersion.join(".").replace(".-", "-").replaceAll('\\.$', "") +ext.mavenVersion = getPublishedVersion(version) sourceCompatibility = '1.8' targetCompatibility = '1.8' diff --git a/version.sh b/version.sh deleted file mode 100755 index 324626f..0000000 --- a/version.sh +++ /dev/null @@ -1,101 +0,0 @@ -# Cinchapi Inc. CONFIDENTIAL -# Copyright (c) 2016 Cinchapi Inc. All Rights Reserved. -# -# All information contained herein is, and remains the property of Cinchapi. -# The intellectual and technical concepts contained herein are proprietary to -# Cinchapi and may be covered by U.S. and Foreign Patents, patents in process, -# and are protected by trade secret or copyright law. Dissemination of this -# information or reproduction of this material is strictly forbidden unless -# prior written permission is obtained from Cinchapi. Access to the source code -# contained herein is hereby forbidden to anyone except current Cinchapi -# employees, managers or contractors who have executed Confidentiality and -# Non-disclosure agreements explicitly covering such access. -# -# The copyright notice above does not evidence any actual or intended -# publication or disclosure of this source code, which includes information -# that is confidential and/or proprietary, and is a trade secret, of Cinchapi. -# -# ANY REPRODUCTION, MODIFICATION, DISTRIBUTION, PUBLIC PERFORMANCE, OR PUBLIC -# DISPLAY OF OR THROUGH USE OF THIS SOURCE CODE WITHOUT THE EXPRESS WRITTEN -# CONSENT OF COMPANY IS STRICTLY PROHIBITED, AND IN VIOLATION OF APPLICABLE -# LAWS AND INTERNATIONAL TREATIES. THE RECEIPT OR POSSESSION OF THIS SOURCE -# CODE AND/OR RELATED INFORMATION DOES NOT CONVEY OR IMPLY ANY RIGHTS TO -# REPRODUCE, DISCLOSE OR DISTRIBUTE ITS CONTENTS, OR TO MANUFACTURE, USE, OR -# SELL ANYTHING THAT IT MAY DESCRIBE, IN WHOLE OR IN PART. - -################################################# -### Script to get or set the current version ### -################################################# - -#Ensure that this script operates from the directory in which it resides -cd "$(dirname "$0")" - -# Bootstrap Git's ability to give the branch, if necessary -git rev-parse --abbrev-ref HEAD > /dev/null 2>&1 -if [ $? -ne 0 ]; then - git commit --allow-empty -m "Bootstrapping version.sh" -fi - -BASE_VERSION_FILE=".version" -JENKINS_HOME="/opt/jenkins" -if [ -w $JENKINS_HOME ]; then - COUNTER_FILE="$JENKINS_HOME/.counter" -else - COUNTER_FILE=".counter" -fi - -if [ -z "$1" ] ; then - VERSION=`cat $BASE_VERSION_FILE` - BRANCH=`git rev-parse --abbrev-ref HEAD` - COMMIT=`git rev-parse HEAD | cut -c1-10` - - # Get counter value - if [ ! -f $COUNTER_FILE ] ; then - echo 0 > $COUNTER_FILE - fi - if [ -z ${CONTAINER_BUILD+x} ]; then - COUNTER=`cat $COUNTER_FILE` - ((COUNTER++)) - else - # If the build is run in a container, the COUNTER_FILE will be wiped - # away on each build, so we'll use the current unix timestamp for the - # counter. - COUNTER=`date +%s` - fi - echo $COUNTER > $COUNTER_FILE - VERSION=$VERSION.$COUNTER - case $BRANCH in - develop ) - EXTRA="-SNAPSHOT" - ;; - feature* ) - IFS='/' - PARTS=( $BRANCH ) - EXTRA="-${PARTS[1]}" - EXTRA=`echo $EXTRA | tr '[:lower:]' '[:upper:]'` - ;; - release* ) - EXTRA="" - ;; - * ) - # At this point we do not need to refer - # to any commit hash since we'll have a - # tag that represents the overall release - EXTRA="" - ;; - esac - echo $VERSION$EXTRA -else - NEW_VERSION=$1 - if [[ $NEW_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then - echo $NEW_VERSION > $BASE_VERSION_FILE - rm $COUNTER_FILE 2>/dev/null - sed -i '' -E "s/[0-9]+\.[0-9]+\.[0-9]+/$NEW_VERSION/g" README.md - - echo "The version has been set to $NEW_VERSION" - else - echo "Please specify a valid version .." - exit 1 - fi -fi -exit 0