Files
documentdb/scripts/generate_extension_version.sh
T
Vinod Sridharan b685862864 Merged PR 1552485: [OSS] Move most of helio_api out of OSS
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactor
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Are you introducing any new config? If yes, do you have tests with and without them being set?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Move most of helio_api out of OSS into internal.
Keep internal/pg_helio_distributed/src/test/regress for now until we port distributed tests over.

----
#### AI description  (iteration 1)
#### PR Classification
Code reorganization to move most of `helio_api` out of the OSS directory.

#### PR Summary
This pull request reorganizes the project structure by moving the `helio_api` components out of the OSS directory to a new `helio_api` directory.
- Deleted files `diff-filter`, `diff`, `normalize.sed`, and `expect_normalize.sed` from `oss/internal/pg_helio_distributed/src/test/regress/bin`.
- Updated paths in `.pipelines/templates/oss_build.yml` and `.pipelines/templates/oss_documentdb_build.yml` to reflect the new `helio_api` directory structure.
- Modified `Makefile` and `oss/Makefile` to update paths and add new targets for `helio_api`.
- Moved `pg_helio_api`, `pg_helio_core`, and `pg_helio_distributed` directories from `oss` to `helio_api`.
- Added new `helio_api/Makefile` and `helio_api/Makefile.inc` to manage the build process for the moved components.
2025-01-17 15:14:59 +08:00

60 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# fail if trying to reference a variable that is not set.
set -u
set -e
outputFile=$1
extensionName=${2:-""}
extensionDir=${3:-$extensionName}
source="${BASH_SOURCE[0]}"
while [[ -h $source ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"
# if $source was a relative symlink, we need to resolve it relative to the path where the
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done
repoScriptDir="$( cd -P "$( dirname "$source" )" && pwd )"
if [ ${BUILD_SOURCEBRANCH:-""} != "" ]; then
# devops branches are of the form refs/heads/foo
echo "Using DevopsBranch ${BUILD_SOURCEBRANCH} and version ${BUILD_SOURCEVERSION}"
GIT_VERSION=$(echo ${BUILD_SOURCEBRANCH} | sed -E "s/refs\/heads\/(.+)/\1/i" | sed -E "s/refs\/(.+)\/merge/\1/i" | sed -E "s/\//_/")
GIT_SHA=${BUILD_SOURCEVERSION:0:7}
else
# set GIT_VERSION with current branch's name and the short sha of the HEAD
GIT_VERSION=$(git rev-parse --abbrev-ref HEAD)
GIT_SHA=$(git rev-parse --short HEAD)
fi
if [[ "$GIT_VERSION" == "" ]] || [[ "$GIT_SHA" == "" ]]; then
echo "Unable to get git version. Bailing"
exit 1
fi
BUILD_VER=" buildId:${BUILD_BUILDID:-"0"}"
GIT_SHA=" sha:${GIT_SHA}"
controlFile="$extensionName.control"
versionStringOutput=$(sed -n "s/^default_version = '\(.*\)'$/\1/p" $controlFile)
EXTENSION_VERSION_STR=${versionStringOutput/-/.}
echo "Using GitVersion '$GIT_VERSION' with SHA '$GIT_SHA' and $extensionName Version '$EXTENSION_VERSION_STR' and Build '$BUILD_VER'"
# Write the header file (Create a new one in the first line and then append to it)
# An example of what's generated
###############################################
# #define EXTENSION_VERSION_STR "1.0.0"
# #define GIT_VERSION "main sha:123defa"
#########################################
echo "// Autogenerated header for versioning" > $outputFile
echo "#define EXTENSION_VERSION_STR \"${EXTENSION_VERSION_STR}\"" >> $outputFile
echo "#define GIT_VERSION \"${GIT_VERSION}${GIT_SHA}${BUILD_VER}\"" >> $outputFile