diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 437c405f08b26..d079549ec90db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ on: type: boolean default: false distribution: - description: '[ "tar", "rpm", "deb", "docker" ]' + description: '[ "tar", "rpm", "deb" ]' type: string default: '[ "rpm", "deb" ]' architecture: diff --git a/.github/workflows/build_on_push.yml b/.github/workflows/build_on_push.yml index 92094c3825222..2c0fbe4fc3ddb 100644 --- a/.github/workflows/build_on_push.yml +++ b/.github/workflows/build_on_push.yml @@ -1,4 +1,4 @@ -name: Build packages (on push ) +name: Build packages (on push) on: push: diff --git a/scripts/build.sh b/scripts/build.sh index f20ce15018f75..79c318d5241da 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -9,6 +9,9 @@ set -ex +# ==== +# Usage +# ==== function usage() { echo "Usage: $0 [args]" echo "" @@ -18,97 +21,67 @@ function usage() { echo -e "-p PLATFORM\t[Optional] Platform, default is 'uname -s'." echo -e "-a ARCHITECTURE\t[Optional] Build architecture, default is 'uname -m'." echo -e "-d DISTRIBUTION\t[Optional] Distribution, default is 'tar'." - echo -e "-r REVISION\t[Optional] Package revision, default is '0'." + echo -e "-b BRANCH\t[Optional] Branch from wazuh/wazuh to download the index template from, default is '"$OUTPUT/artifact_min_name.txt" + # Assemble distribution artifact + # see https://github.com/opensearch-project/OpenSearch/blob/main/settings.gradle#L34 for other distribution targets + ./gradlew ":distribution:$TYPE:$TARGET:assemble" -Dbuild.snapshot="$SNAPSHOT" -Dbuild.version_qualifier="$QUALIFIER" +} + +# ==== +# Main function +# ==== +function main() { + parse_args "${@}" + + echo "Building OpenSearch for $PLATFORM-$DISTRIBUTION-$ARCHITECTURE" + if ! download_template; then + exit 1 + fi + build + + # Copy artifact to dist folder in bundle build output + echo "Copying artifact to ${OUTPUT}/dist" + local build_name + build_name=$(ls "distribution/$TYPE/$TARGET/build/distributions/" | grep "wazuh-indexer-min.*$SUFFIX.$EXT") + local package_name=${NAME:-$build_name} + mkdir -p "${OUTPUT}/dist" + cp "distribution/$TYPE/$TARGET/build/distributions/$build_name" "${OUTPUT}/dist/$package_name" +} -mkdir -p "${OUTPUT}/dist" -cp "distribution/$TYPE/$TARGET/build/distributions/$ARTIFACT_BUILD_NAME" "${OUTPUT}/dist/$ARTIFACT_PACKAGE_NAME" +main "${@}"