Skip to content

Commit

Permalink
Improve build.sh script
Browse files Browse the repository at this point in the history
Apply suggestions from ShellCheck
  • Loading branch information
AlexRuiz7 committed Dec 5, 2023
1 parent 98fe3be commit 9362211
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ fi
[ -z "$OUTPUT" ] && OUTPUT=artifacts

echo "Creating output directory $OUTPUT/maven/org/opensearch if it doesn't already exist"
mkdir -p $OUTPUT/maven/org/opensearch
mkdir -p "$OUTPUT/maven/org/opensearch"

# Build project and publish to maven local.
echo "Building and publishing OpenSearch project to Maven Local"
./gradlew publishToMavenLocal -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
./gradlew publishToMavenLocal -Dbuild.snapshot="$SNAPSHOT" -Dbuild.version_qualifier="$QUALIFIER"

# Publish to existing test repo, using this to stage release versions of the artifacts that can be released from the same build.
echo "Publishing OpenSearch to Test Repository"
./gradlew publishNebulaPublicationToTestRepository -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
./gradlew publishNebulaPublicationToTestRepository -Dbuild.snapshot="$SNAPSHOT" -Dbuild.version_qualifier="$QUALIFIER"

# Copy maven publications to be promoted
echo "Copying Maven publications to $OUTPUT/maven/org"
Expand All @@ -89,7 +89,7 @@ cp -r ./build/local-test-repo/org/opensearch "${OUTPUT}"/maven/org
# see https://github.com/opensearch-project/OpenSearch/blob/main/settings.gradle#L34 for other distribution targets

[ -z "$PLATFORM" ] && PLATFORM=$(uname -s | awk '{print tolower($0)}')
[ -z "$ARCHITECTURE" ] && ARCHITECTURE=`uname -m`
[ -z "$ARCHITECTURE" ] && ARCHITECTURE=$(uname -m)
[ -z "$DISTRIBUTION" ] && DISTRIBUTION="tar"

case $PLATFORM-$DISTRIBUTION-$ARCHITECTURE in
Expand Down Expand Up @@ -157,13 +157,13 @@ esac

echo "Building OpenSearch for $PLATFORM-$DISTRIBUTION-$ARCHITECTURE"

./gradlew :distribution:$TYPE:$TARGET:assemble -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
./gradlew ":distribution:$TYPE:$TARGET:assemble" -Dbuild.snapshot="$SNAPSHOT" -Dbuild.version_qualifier="$QUALIFIER"

# Copy artifact to dist folder in bundle build output
echo "Copying artifact to ${OUTPUT}/dist"
[[ "$SNAPSHOT" == "true" ]] && IDENTIFIER="-SNAPSHOT"
ARTIFACT_BUILD_NAME=`ls distribution/$TYPE/$TARGET/build/distributions/ | grep "wazuh-indexer-min.*$SUFFIX.$EXT"`
# [[ "$SNAPSHOT" == "true" ]] && IDENTIFIER="-SNAPSHOT"
ARTIFACT_BUILD_NAME=$(ls "distribution/$TYPE/$TARGET/build/distributions/" | grep "wazuh-indexer-min.*$SUFFIX.$EXT")
# [WAZUH] Used by the GH workflow to upload the artifact
echo "$ARTIFACT_BUILD_NAME" > "$OUTPUT/artifact_name.txt"
mkdir -p "${OUTPUT}/dist"
cp distribution/$TYPE/$TARGET/build/distributions/$ARTIFACT_BUILD_NAME "${OUTPUT}"/dist/$ARTIFACT_BUILD_NAME
cp "distribution/$TYPE/$TARGET/build/distributions/$ARTIFACT_BUILD_NAME" "${OUTPUT}/dist/$ARTIFACT_BUILD_NAME"

0 comments on commit 9362211

Please sign in to comment.