This is an automated email from the ASF dual-hosted git repository.

houston pushed a commit to branch add-pki-caching
in repository https://gitbox.apache.org/repos/asf/solr.git

commit f3d86b1741d9cba1deb11ba10de15ed1776cc927
Author: rio <[email protected]>
AuthorDate: Mon Sep 9 19:37:24 2024 +0000

    Initialize Rio Build and Apple Solr Version for 9.7.0-apple
---
 build.gradle                          |   2 +
 rio.yaml                              | 368 ++++++++++++++++++++++++++++++++++
 rio/fix-solr-dockerfiles.sh           |  11 +
 rio/generate-apple-branch.sh          |  37 ++++
 rio/generate-solr-release-branches.sh |  25 +++
 rio/get-apple-solr-version.sh         |   9 +
 rio/increment-apple-solr-version.sh   |  10 +
 rio/set-git-push-trigger-to-false.sh  |   6 +
 rio/setup-apple-solr-branch.sh        |  24 +++
 9 files changed, 492 insertions(+)

diff --git a/build.gradle b/build.gradle
index 910714b7736..b479a807482 100644
--- a/build.gradle
+++ b/build.gradle
@@ -36,8 +36,10 @@ apply from: file('gradle/globals.gradle')
 
 // Calculate project version:
 version = {
+  String appleSolrVersionSuffix = '0'
   // Release manager: update base version here after release:
   String baseVersion = '9.7.0'
+  baseVersion = baseVersion + '.' + appleSolrVersionSuffix + '-apple'
 
   // On a release explicitly set release version in one go:
   //  -Dversion.release=x.y.z
diff --git a/rio.yaml b/rio.yaml
new file mode 100644
index 00000000000..335eedca4ab
--- /dev/null
+++ b/rio.yaml
@@ -0,0 +1,368 @@
+schemaVersion: 2.0
+timeout: 240
+
+### Globals
+security:
+  # Twistlock scan results will be uploaded to quality.aci but we don't want 
to fail the build
+  scanReports:
+    dockerfile:
+      continueOnFail: true
+    dockerload:
+      continueOnFail: true
+package:
+  dockerfile:
+    perApplication: false
+
+machine:
+  # When we want to bifrucate with java 11 and java 17 builders, then we need 
multiple pipelines
+  baseImage: docker.apple.com/base-images/ubi9/java11-builder
+  env: &git_env
+    # Our pipelines get triggered from multiple branches so HEAD appears to 
move around a lot
+    # Rio tries to be helpful and give us a list of all the changes, but it 
ends up being noisy
+    # So we blank everything out via these variables.  See rdar://100290418
+    GIT_AUTHOR_EMAILS: ''
+    GIT_AUTHOR_NAMES: ''
+    GIT_COMMITTER_EMAILS: ''
+    GIT_COMMITTER_NAMES: ''
+
+
+# This pipeline chain is split into 4 stages: 
+# 1. Generate pipelines for branches of interest
+# 2. Fan out execute unit tests, builds for each branch
+# 3. Perform kube deployed ITs for built images
+# 4. Promote passing ITs from verification to snapshot
+#
+# For stable nightly builds, we would need to leverage Rio's finally:merge: 
feature
+# and trigger a @daily build on yet another distinct branch. This is not 
implemented
+# due to the fear of spiraling complexity. However snapshot maven artifacts 
are only
+# published with passing unit tests and snapshot docker images with passing 
ITs, so
+# that may provide enough confidence for consumers to use them when needed.
+pipelines:
+
+# This pipeline will add all of our internal apple build decorators to the 
other branches.
+# The most important piece is committing rio.yaml files to each branch we are 
interested in
+# because Rio is designed to only build when it sees configuration on a given 
branch. There
+# is no elegant method to configure builds on one branch and trigger them on 
another.
+#
+# We will take the upstream branches such as main, prefix them as apple-main, 
and after
+# adding our build information and optional downstream forking patches, commit 
back to the
+# IPR repo. There may be a desire to separate the upstream mirror pieces of 
IPR from the
+# downstream build branches, in which case we would move this logic to a new 
repository.
+- name: 01-generate-rio-pipelines
+  branchName: apple-rio
+  machine:
+    baseImage: docker.apple.com/base-images/ubi9-minimal/ubi-minimal
+  trigger:
+    # Run once an hour, at a random but consistent offset.
+    timer: '@hourly'
+    # ... but also run if the build has changed
+    gitPush: true
+  build:
+    template: freestyle:v4:build
+    steps:
+      # This doesn't work when set in machine:env: anymore, but still seems to 
work here
+      # 
https://docs.aci.apple.com/rio/guide-to-rio/build-and-test/ssh-keys.html#rio-deploy-ssh-key
+      # We can expect to need to migrate to a different approach sometime soon
+      - export SSH_AUTH_SOCK=${SSH_AUTH_SOCK_DEPLOY_KEY}
+
+      # This provides git
+      - microdnf install -y git
+
+      # Set up variables for the helper script
+      - export GIT_COMMIT
+      - export GIT_PREVIOUS_SUCCESSFUL_COMMIT
+
+      # Track non-release upstream branches
+      - ./rio/generate-apple-branch.sh main
+      - ./rio/generate-apple-branch.sh branch_9x
+        # We only care about the latest stable branch. There is no reason to 
track old ones
+      - LATEST_STABLE_BRANCH="$(git ls-remote --heads origin 
"branch_*[0-9]_*[0-9]" | grep -o -E "branch_[0-9_]+$" | sort -r -V | head -n 1)"
+      - ./rio/generate-apple-branch.sh "${LATEST_STABLE_BRANCH}"
+
+      # Create Apple Solr release branches for upstream release tags
+      - ./rio/generate-solr-release-branches.sh
+
+# The main workhorse of the build. For each branch that this has been declared 
in, we will do a
+# full gradle build and generate a container image. It will be regenerate and 
trigger whenever
+# pushed by phase one of the pipeline chain. This is inefficient, but it's 
what we have.
+#
+# This works with gradle, if we want to extend it to work with ant, the best 
strategy is a
+# new pipeline that produces similarly shaped jars and container images.
+#
+# Another option would be to attempt to merge upstream changes into an 
existing apple branch,
+# that way rio doesn't have to regenerate the pipeline each time, but it 
requires investigation.
+- group: '02-snapshot'
+  branchRules:
+    includePatterns:
+    # Apple Release Branches
+    - '.*-apple'
+    # Upstream tracking - created by 01-generate-rio-pipelines
+    - 'apple-.*'
+    excludePatterns:
+    - 'apple-rio' # No solr here
+  trigger:
+    gitPush: true
+  machine:
+    env:
+      <<: *git_env
+      RUNTIME_JDK_VERSION: 11
+      ORG_GRADLE_PROJECT_validation.git.failOnModified: false
+      ORG_GRADLE_PROJECT_validation.rat.failOnError: false
+      ORG_GRADLE_PROJECT_validation.sourcePatterns.failOnError: false
+      ORG_GRADLE_PROJECT_sign: false
+      ORG_GRADLE_PROJECT_signing.gnupg.keyName: NOT-USED
+      SOLR_REF_GUIDE_INCLUDE: false
+      SOLR_DOCKER_BASE_IMAGE: docker.apple.com/apple-solr/base-solr:java17-ubi9
+      GRADLE_USER_HOME: $(mktemp -d)
+  build:
+    template: freestyle:v4:publish
+    steps:
+      - trap 'rm -rf $GRADLE_USER_HOME' EXIT
+      # Properties in gradle user home have higher precedence than project 
properties
+      # We need to unset the Rio defaults so that we can add our module opens 
statements
+      # After rdar://100283844 is addressed, remove GRADLE_USER_HOME from 
machine:env
+      - cp -R ~/.gradle/ $GRADLE_USER_HOME
+      - sed -i -e '/org.gradle.jvmargs/d' $GRADLE_USER_HOME/gradle.properties
+      # Now generate the local settings that Solr expects
+      - ./gradlew localSettings --no-daemon
+      - SOLR_VERSION=$(./gradlew properties | grep "version:" | cut -d " " -f2)
+      # Used for finally blocks - as they don't have access to the envVar
+      - echo "${SOLR_VERSION}" > .solrVersion
+      - echo "${SOLR_VERSION%"-apple"}" > .solrVersion-noApple
+      - ./gradlew assembleRelease
+      - dnf install -y -q fontconfig # Required for Tika tests
+      - ./gradlew check
+      # This alternative to the publish command is why we need freestyle 
instead of buildozer template
+      # Maven checksums (shas) are handled by artifactory, do not upload them
+      - ci stage-lib --label jar --many-many-artifacts --allow-external 
"solr/distribution/build/release/maven/**/*.jar"
+      - ci stage-lib --label pom --many-many-artifacts --allow-external 
"solr/distribution/build/release/maven/**/*.pom"
+      - ci stage-lib --label tgz --allow-external 
"solr/distribution/build/release/solr-*.tgz*,snapshot/org/apache/solr/${SOLR_VERSION}"
+      # This creates directories to use as Docker contexts
+      - rm -rf build/release-docker-contexts
+      - mkdir -p build/release-docker-contexts/full
+      - tar -xzf solr/distribution/build/release/solr-${SOLR_VERSION}.tgz -C 
build/release-docker-contexts/full
+      - mkdir -p build/release-docker-contexts/slim
+      - tar -xzf solr/distribution/build/release/solr-${SOLR_VERSION}-slim.tgz 
-C build/release-docker-contexts/slim
+  reports:
+    junit:
+      trim: true
+      paths:
+        - "**/build/test-results/**/*.xml"
+  package:
+    release: false
+    freeform:
+      # 
https://docs.aci.apple.com/artifactory/faq.html#deploying-patched-open-source-packages
+      - publish:
+        - packageFilters: [jar, pom]
+          repo: oss-patched-snapshot-local
+        - packageFilters: [tgz]
+          repo: oss-patched-binaries-local
+    dockerfile:
+      - version: $(cat .solrVersion)
+        publish:
+          - repo: 'docker.apple.com/apple-solr/solr-nightly'
+        context: build/release-docker-contexts/full
+        dockerfilePath: build/release-docker-contexts/full/solr-$(cat 
.solrVersion)/docker/Dockerfile
+      - version: $(cat .solrVersion)-slim
+        publish:
+          - repo: 'docker.apple.com/apple-solr/solr-nightly'
+        context: build/release-docker-contexts/slim
+        dockerfilePath: build/release-docker-contexts/slim/solr-$(cat 
.solrVersion)-slim/docker/Dockerfile
+#  finally:
+#    pipelineChain:
+#    - pipeline: 03-integration-test
+#      buildArguments:
+#      - name: IMAGE_SOURCE
+#        # This needs to match dockerfile:publish:repo
+#        value: 
"docker.apple.com/aci-oss/solr/verification:${GIT_COMMIT_SHORT}"
+#      - name: PROMOTED_VERSION
+#        value: '$PROMOTED_SUB' # The quoting is required when the tag appears 
numeric
+
+# The manually triggered release pipeline. This is on an existing Apple Solr 
release branch
+- group: '03-release'
+  branchRules:
+    includePatterns:
+      - '.*-apple'
+  trigger:
+    # This starts off as true for the first push. Then during the job it will 
be set to false.
+    # This way we auto-release the first Apple release, then we can manually 
release afterwards.
+    gitPush: true # GIT_PUSH_RELEASE_TRIGGER_LINE -- do not change this
+  machine:
+    env:
+      <<: *git_env
+      SSH_AUTH_SOCK: ${SSH_AUTH_SOCK_DEPLOY_KEY}
+      RUNTIME_JDK_VERSION: 11
+      ORG_GRADLE_PROJECT_validation.git.failOnModified: false
+      ORG_GRADLE_PROJECT_validation.rat.failOnError: false
+      ORG_GRADLE_PROJECT_validation.sourcePatterns.failOnError: false
+      ORG_GRADLE_PROJECT_version.suffix: ""
+      ORG_GRADLE_PROJECT_sign: false
+      ORG_GRADLE_PROJECT_signing.gnupg.keyName: NOT-USED
+      SOLR_REF_GUIDE_INCLUDE: false
+      SOLR_DOCKER_BASE_IMAGE: docker.apple.com/apple-solr/base-solr:java17-ubi9
+      GRADLE_USER_HOME: $(mktemp -d)
+  build:
+    template: freestyle:v4:publish
+    steps:
+      - dnf install -y -q fontconfig
+      - trap 'rm -rf $GRADLE_USER_HOME' EXIT
+      # Properties in gradle user home have higher precedence than project 
properties
+      # We need to unset the Rio defaults so that we can add our module opens 
statements
+      # After rdar://100283844 is addressed, remove GRADLE_USER_HOME from 
machine:env
+      - cp -R ~/.gradle/ $GRADLE_USER_HOME
+      - sed -i -e '/org.gradle.jvmargs/d' $GRADLE_USER_HOME/gradle.properties
+      # Now generate the local settings that Solr expects
+      - ./gradlew localSettings --no-daemon
+      - SOLR_VERSION=$(./gradlew properties | grep "version:" | cut -d " " -f2)
+      # Used for finally blocks - as they don't have access to the envVar
+      - echo "${SOLR_VERSION}" > .solrVersion
+      - echo "${SOLR_VERSION%"-apple"}" > .solrVersion-noApple
+      - ./gradlew assembleRelease
+      - dnf install -y -q fontconfig # Required for Tika tests
+      - ./gradlew check
+      # This alternative to the publish command is why we need freestyle 
instead of buildozer template
+      # Maven checksums (shas) are handled by artifactory, do not upload them
+      - ci stage-lib --label jar --many-many-artifacts --allow-external 
"solr/distribution/build/release/maven/**/*.jar"
+      - ci stage-lib --label pom --many-many-artifacts --allow-external 
"solr/distribution/build/release/maven/**/*.pom"
+      - ci stage-lib --label tgz --allow-external 
"solr/distribution/build/release/solr-*.tgz*,org/apache/solr/${SOLR_VERSION}"
+        # This is the only way to pass dockerfiles to the pipeline-chain
+      - export DOCKERFILES_BUILD_DIR="solr/distribution/build/release/docker"
+        # Fix the dockerfiles so that they have the correct (Apple 
Artifactory) download server
+      - ./rio/fix-solr-dockerfiles.sh "${DOCKERFILES_BUILD_DIR}" 
'https://artifacts.apple.com/artifactory/oss-patched-binaries-local/org/apache/solr'
+      - mkdir -p solr/distribution/build/rio/
+      - tar -czvf 
"solr/distribution/build/rio/solr-docker-${SOLR_VERSION}.tgz" -C 
"${DOCKERFILES_BUILD_DIR}" .
+      - ci stage-lib --label docker --allow-external 
"solr/distribution/build/rio/solr-docker-*,org/apache/solr-docker/${SOLR_VERSION}"
+      # Tag the current revision for the release
+      - git tag "${SOLR_VERSION}"
+      - git push origin "${SOLR_VERSION}"
+      # Increment the Apple Solr patch version
+      - ./rio/increment-apple-solr-version.sh
+      - git add build.gradle
+      - ./rio/set-git-push-trigger-to-false.sh
+      - git add rio.yaml
+      - git commit -m "Increment Apple Solr Version to $(./gradlew properties 
| grep "version:" | cut -d " " -f2)"
+      - git push origin "${RIO_BRANCH_NAME}"
+  package:
+    release: true
+    dockerfile: false # We will use the release-images repo for releases
+    freeform:
+      # 
https://docs.aci.apple.com/artifactory/faq.html#deploying-patched-open-source-packages
+      - publish:
+          - packageFilters: [jar, pom]
+            repo: oss-patched-release-local
+          - packageFilters: [tgz, docker]
+            repo: oss-patched-binaries-local
+  finally:
+    pipelineChain:
+    # Add a docker image for this Solr release
+    # Dockerfiles are passed via the Rio Context file which will be found at 
$RIO_CONTEXT_FILE
+    - project: aci-solr-dev-solr-release-images
+      pipeline: add-solr-release
+      buildArguments:
+        - name: FULL_SOLR_VERSION
+          value: "$(cat .solrVersion)"
+    # Create an Apple extended distribution for this Solr release
+    - project: ase-aci-solr-dev-apple-solr-distribution
+      pipeline: cut-new-solr-release
+      buildArguments:
+        - name: APPLE_SOLR_VERSION
+          value: "$(cat .solrVersion-noApple)"
+
+#  # We can only declare a single named pipeline to use for chained triggers, 
so we need to make sure that
+#  # we can run with the same skeleton of steps each time. However, this 
pipeline repository state will be
+#  # consistent with the triggering commit - we are abusing a Rio feature 
related to delayed job launches
+#  # in the case of multiple rapid-succession commits.
+#  #
+#  # In practical terms, what this means is that the steps executed will be 
the same each time, but the
+#  # outcomes may vary due to different sets of files, e.g. kube resource 
specifications. We have the
+#  # option to leverage this for branch-specific logic, although that is not 
necessary yet. The other
+#  # complication is that when launched manually, the job _does_ execute from 
the tip of the generating
+#  # branch, but that is also ok in our case.
+#  #
+#  # Easiest way to be consistent about it is to declare this pipeline on our 
special rio branch
+#  # See https://stackoverflow.apple.com/questions/27383 for some alternatives
+#- branchName: apple-rio
+#  name: 03-integration-test
+#  trigger:
+#    gitPush: false
+#  machine:
+#    baseImage: docker.apple.com/privatecloud/k8s-kubectl:v1.21.9
+#    env:
+#      <<: *git_env
+#
+#  secrets:
+#    # https://kube.apple.com/docs/ci-cd-with-rio/#set-up-kubeconfig
+#    names:
+#      - kubeconfig
+#  build:
+#    template: freestyle:v4:build
+#    buildParameters:
+#      # We could pull this from GIT_COMMIT_SHORT locally, but better to be 
explicit for now
+#      - parameter: IMAGE_SOURCE
+#        description: "The image to test"
+#      - parameter: PROMOTED_REPO
+#        description: "The namespace under aci-oss/solr to promote to"
+#        defaultValue: snapshot
+#      - parameter: PROMOTED_VERSION
+#        description: "The version for the promoted image (to pass to the next 
step in the chain)"
+#    steps:
+#      # All of these steps should probably go into a shell script,
+#      # so we don't regenerate rio pipelines whenever there are edits
+#      - sed -i -e "s#\$IMAGE_NAME#$BUILD_PARAM_IMAGE_SOURCE#" -e 
"s/\$TEST/$RIO_BUILD_NUMBER/" apple-kube/*
+#      - tail -n +1 apple-kube/* # write a separator between files instead of 
using cat
+#      - K="kubectl --kubeconfig $BUILD_SECRETS_PATH/kubeconfig"
+#      - trap '$K delete -f apple-kube/' EXIT
+#      - $K apply -f apple-kube/deploy.yaml -f apple-kube/service.yaml
+#      - $K wait --for condition=Available=True -f apple-kube/deploy.yaml 
--timeout=10m
+#      # TODO Wait for service also...
+#      - $K apply -f apple-kube/validate.yaml
+#      - ( trap '$K logs "job.batch/solr-verify-${RIO_BUILD_NUMBER}"' EXIT ; 
$K wait --for condition=Complete -f apple-kube/validate.yaml --timeout=10m )
+#  finally:
+#    pipelineChain:
+#      - pipeline: 04-promote
+#        buildArguments:
+#          - name: IMAGE_NAME
+#            value: '${BUILD_PARAM_IMAGE_SOURCE}'
+#          - name: PROMOTED_REPO
+#            value: '${BUILD_PARAM_PROMOTED_REPO}'
+#          - name: PROMOTED_VERSION
+#            value: '${BUILD_PARAM_PROMOTED_VERSION}'
+#
+#  # This pipeline will promote (i.e. re-tag) an existing image. It's a bit 
kludgey because Rio
+#  # will apply a brand new set of build labels to it, but the underlying 
layers we care about will
+#  # remain unchanged.
+#  #
+#  # Can be used across namespaces as well, such as promoting snapshot to 
nightly to release
+#- branchName: apple-rio
+#  name: 04-promote
+#  trigger:
+#    gitPush: false # only triggered by upstream pipeline
+#  machine:
+#    # We need an image that has skopeo and this is convenient enough
+#    baseImage: docker.apple.com/base-images-builder/rio-builder:latest
+#    env:
+#      <<: *git_env
+#  build:
+#    template: freestyle:v4:publish
+#    buildParameters:
+#      - parameter: IMAGE_NAME
+#        description: "The image coordinates to promote"
+#      - parameter: PROMOTED_REPO
+#        description: "The namespace under aci-oss/solr to promote to"
+#      - parameter: PROMOTED_VERSION
+#        description: "The version for the promoted image (i.e. latest, 9.0)"
+#    steps:
+#      - 
TAG=docker.apple.com/aci-oss/solr/${BUILD_PARAM_PROMOTED_REPO}:${BUILD_PARAM_PROMOTED_VERSION}
+#      - skopeo copy --insecure-policy "docker://${BUILD_PARAM_IMAGE_NAME}" 
"docker-archive:image.tar" --additional-tag "$TAG"
+#      - ci stage-docker "./image.tar"
+#  package:
+#    dockerLoad:
+#      - version: ${BUILD_PARAM_PROMOTED_VERSION}
+#        publish:
+#          # This needs to match the additional tag specified above
+#          - repo: 'docker.apple.com/aci-oss/solr/${BUILD_PARAM_PROMOTED_REPO}'
+#        # Rio has an extraTags feature that supports dynamic values, so we 
could fill that in from build params
+#        # similar to how we do the main version. Unfortunately, it doesn't 
work with a dynamic length of tags.
+#        # We can probably set something up with the dynamic length arrays by 
stamping it on the branch specific
+#        # rio.yaml using yq or kustomize.
+
diff --git a/rio/fix-solr-dockerfiles.sh b/rio/fix-solr-dockerfiles.sh
new file mode 100755
index 00000000000..16a1439d506
--- /dev/null
+++ b/rio/fix-solr-dockerfiles.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+set -e
+
+DOCKERFILES_DIR="${1}"
+ARTIFACTORY_LOCATION="${2}"
+
+for DOCKERFILE in "${DOCKERFILES_DIR}"/Dockerfile.*; do
+  sed -e "s|ARG SOLR_DOWNLOAD_SERVER=.*|ARG 
SOLR_DOWNLOAD_SERVER=\"${ARTIFACTORY_LOCATION}\"|g" "${DOCKERFILE}" > 
"${DOCKERFILE}.tmp"
+  mv "${DOCKERFILE}.tmp" "${DOCKERFILE}"
+done
diff --git a/rio/generate-apple-branch.sh b/rio/generate-apple-branch.sh
new file mode 100755
index 00000000000..31c2f05f90a
--- /dev/null
+++ b/rio/generate-apple-branch.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+set -x
+set -e
+
+SOURCE_BRANCH=$1
+git fetch -q origin "$SOURCE_BRANCH"
+
+export GIT_COMMIT="${GIT_COMMIT:-apple-rio}"
+
+SOURCE_COMMIT=$(git rev-parse origin/"$SOURCE_BRANCH")
+TARGET_BRANCH=apple-${SOURCE_BRANCH}
+git fetch -q origin "$TARGET_BRANCH" || :
+
+# Check if there is any point in continuing.  If this build hasn't
+# changed since the last successful build AND the code hasn't changed,
+# then we don't want to introduce unnecessary commits.  This allows
+# frequent scheduled checking to occur without causing builds.
+if [ "$GIT_COMMIT" = "$GIT_PREVIOUS_SUCCESSFUL_COMMIT" ] && [ -n "$(git branch 
-r --contains "$SOURCE_COMMIT" | grep "$TARGET_BRANCH")" ] ; then
+  exit 0;
+fi
+
+# Reset state for next branch
+trap 'git checkout $GIT_COMMIT' EXIT
+
+# Create or update the Apple target branch
+git checkout -B "${TARGET_BRANCH}" "${SOURCE_COMMIT}"
+
+git checkout "${GIT_COMMIT}" -- ./rio/setup-apple-solr-branch.sh
+./rio/setup-apple-solr-branch.sh
+
+# Apply patches
+# PATCH_BRANCH_PREFIX=patch-${TARGET_VERSION}
+# grep '^[A-Za-z0-9]' ${WORKSPACE}/patchList.txt | xargs -I '{}' git rebase 
HEAD "$GIT_REPO/{}"
+
+# Push branch
+git push -f origin "${TARGET_BRANCH}"
diff --git a/rio/generate-solr-release-branches.sh 
b/rio/generate-solr-release-branches.sh
new file mode 100755
index 00000000000..1c107517a22
--- /dev/null
+++ b/rio/generate-solr-release-branches.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+
+set -x
+set -e
+
+ALL_RELEASES=($(git ls-remote --tags origin "releases/solr/*[0-9]" | grep -v 
"/1\." | grep -o -E "[0-9.]+$"))
+
+export GIT_COMMIT="${GIT_COMMIT:-apple-rio}"
+
+# Reset state for next branch
+trap 'git checkout $GIT_COMMIT' EXIT
+
+for RELEASE_VERSION in "${ALL_RELEASES[@]}"; do
+  echo "Checking branch for Solr release ${RELEASE_VERSION}"
+  export APPLE_BRANCH="${RELEASE_VERSION}-apple"
+  if ! (git ls-remote --exit-code --heads origin "${APPLE_BRANCH}"); then
+    echo "Creating branch ${APPLE_BRANCH}"
+    git fetch origin tag "releases/solr/${RELEASE_VERSION}"
+    git checkout -B "${APPLE_BRANCH}" "releases/solr/${RELEASE_VERSION}"
+    git checkout "${GIT_COMMIT}" -- ./rio/setup-apple-solr-branch.sh
+    ./rio/setup-apple-solr-branch.sh
+
+    git push origin "${APPLE_BRANCH}"
+  fi
+done
diff --git a/rio/get-apple-solr-version.sh b/rio/get-apple-solr-version.sh
new file mode 100755
index 00000000000..585251d3069
--- /dev/null
+++ b/rio/get-apple-solr-version.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+set -e
+
+APPLE_VERSION_SUFFIX="$(grep "  String appleSolrVersionSuffix = '" 
build.gradle)"
+APPLE_VERSION_SUFFIX="${APPLE_VERSION_SUFFIX##"  String appleSolrVersionSuffix 
= '"}"
+APPLE_VERSION_SUFFIX="${APPLE_VERSION_SUFFIX%"'"}"
+
+echo "${APPLE_VERSION_SUFFIX}"
diff --git a/rio/increment-apple-solr-version.sh 
b/rio/increment-apple-solr-version.sh
new file mode 100755
index 00000000000..9bcda6c93a1
--- /dev/null
+++ b/rio/increment-apple-solr-version.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+set -e
+
+APPLE_VERSION_SUFFIX="$(grep "  String appleSolrVersionSuffix = '" 
build.gradle)"
+APPLE_VERSION_SUFFIX="${APPLE_VERSION_SUFFIX##"  String appleSolrVersionSuffix 
= '"}"
+APPLE_VERSION_SUFFIX="${APPLE_VERSION_SUFFIX%"'"}"
+
+sed -e "s/String appleSolrVersionSuffix = '${APPLE_VERSION_SUFFIX}'/String 
appleSolrVersionSuffix = '$((APPLE_VERSION_SUFFIX+1))'/g" build.gradle > 
build.gradle.tmp
+mv build.gradle.tmp build.gradle
diff --git a/rio/set-git-push-trigger-to-false.sh 
b/rio/set-git-push-trigger-to-false.sh
new file mode 100755
index 00000000000..a8ae199c862
--- /dev/null
+++ b/rio/set-git-push-trigger-to-false.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+set -e
+
+sed -e "s/true .* GIT_PUSH_RELEASE_TRIGGER_LINE.*/false # First release 
complete - all further releases will be triggered manually/g" rio.yaml > 
rio.yaml.tmp
+mv rio.yaml.tmp rio.yaml
diff --git a/rio/setup-apple-solr-branch.sh b/rio/setup-apple-solr-branch.sh
new file mode 100755
index 00000000000..afcb17245de
--- /dev/null
+++ b/rio/setup-apple-solr-branch.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+set -e
+
+export GIT_COMMIT="${GIT_COMMIT:-apple-rio}"
+
+# Add rio files so that pipelines can run on this branch
+git checkout "$GIT_COMMIT" -- rio.yaml rio
+# sed -i -e "s#\$PROMOTED_SUB#$PROMOTED_SUB#g" rio.yaml
+git add rio.yaml
+git add rio
+
+# Update the build.gradle to use an Apple Solr Version
+sed -e "s/\(version = {\)/\1\n  String appleSolrVersionSuffix = '0'/g" 
build.gradle > build.gradle.tmp
+mv build.gradle.tmp build.gradle
+sed -e "s/\(.*String baseVersion =.*\)/\1\n  baseVersion = baseVersion + '.' + 
appleSolrVersionSuffix + '-apple'/g" build.gradle > build.gradle.tmp
+mv build.gradle.tmp build.gradle
+
+git add build.gradle
+
+git commit --author 'rio <[email protected]>' \
+  -m "Initialize Rio Build and Apple Solr Version for $(git symbolic-ref 
--short HEAD)" \
+  --untracked-files=no \
+  rio.yaml rio build.gradle

Reply via email to