|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -euo pipefail |
| 4 | + |
| 5 | +WORKFLOW="${DRA_WORKFLOW:-snapshot}" |
| 6 | +BRANCH="${BUILDKITE_BRANCH:-}" |
| 7 | + |
| 8 | +# Don't publish main branch to staging |
| 9 | +if [[ "$BRANCH" == "main" && "$WORKFLOW" == "staging" ]]; then |
| 10 | + exit 0 |
| 11 | +fi |
| 12 | + |
| 13 | +echo --- Preparing |
| 14 | + |
| 15 | +# TODO move this to image |
| 16 | +sudo apt-get update -y |
| 17 | +sudo apt-get install -y libxml2-utils python3.10-venv |
| 18 | + |
| 19 | +RM_BRANCH="$BRANCH" |
| 20 | +if [[ "$BRANCH" == "main" ]]; then |
| 21 | + RM_BRANCH=master |
| 22 | +fi |
| 23 | + |
| 24 | +ES_VERSION=$(grep elasticsearch build-tools-internal/version.properties | sed "s/elasticsearch *= *//g") |
| 25 | + |
| 26 | +VERSION_SUFFIX="" |
| 27 | +if [[ "$WORKFLOW" == "snapshot" ]]; then |
| 28 | + VERSION_SUFFIX="-SNAPSHOT" |
| 29 | +fi |
| 30 | + |
| 31 | +BEATS_BUILD_ID="$(./.ci/scripts/resolve-dra-manifest.sh beats "$RM_BRANCH" "$ES_VERSION" "$WORKFLOW")" |
| 32 | +ML_CPP_BUILD_ID="$(./.ci/scripts/resolve-dra-manifest.sh ml-cpp "$RM_BRANCH" "$ES_VERSION" "$WORKFLOW")" |
| 33 | + |
| 34 | +LICENSE_KEY_ARG="" |
| 35 | +BUILD_SNAPSHOT_ARG="" |
| 36 | + |
| 37 | +if [[ "$WORKFLOW" == "staging" ]]; then |
| 38 | + LICENSE_KEY=$(mktemp -d)/license.key |
| 39 | + # Notice that only the public key is being read here, which isn't really secret |
| 40 | + vault read -field pubkey secret/ci/elastic-elasticsearch/migrated/license | base64 --decode > "$LICENSE_KEY" |
| 41 | + LICENSE_KEY_ARG="-Dlicense.key=$LICENSE_KEY" |
| 42 | + |
| 43 | + BUILD_SNAPSHOT_ARG="-Dbuild.snapshot=false" |
| 44 | +fi |
| 45 | + |
| 46 | +echo --- Building release artifacts |
| 47 | + |
| 48 | +.ci/scripts/run-gradle.sh -Ddra.artifacts=true \ |
| 49 | + -Ddra.artifacts.dependency.beats="${BEATS_BUILD_ID}" \ |
| 50 | + -Ddra.artifacts.dependency.ml-cpp="${ML_CPP_BUILD_ID}" \ |
| 51 | + -Ddra.workflow="$WORKFLOW" \ |
| 52 | + -Dcsv="$WORKSPACE/build/distributions/dependencies-${ES_VERSION}${VERSION_SUFFIX}.csv" \ |
| 53 | + $LICENSE_KEY_ARG \ |
| 54 | + $BUILD_SNAPSHOT_ARG \ |
| 55 | + buildReleaseArtifacts \ |
| 56 | + exportCompressedDockerImages \ |
| 57 | + :distribution:generateDependenciesReport |
| 58 | + |
| 59 | +PATH="$PATH:${JAVA_HOME}/bin" # Required by the following script |
| 60 | +x-pack/plugin/sql/connectors/tableau/package.sh asm qualifier="$VERSION_SUFFIX" |
| 61 | + |
| 62 | +# we regenerate this file as part of the release manager invocation |
| 63 | +rm "build/distributions/elasticsearch-jdbc-${ES_VERSION}${VERSION_SUFFIX}.taco.sha512" |
| 64 | + |
| 65 | +# Allow other users access to read the artifacts so they are readable in the |
| 66 | +# container |
| 67 | +find "$WORKSPACE" -type f -path "*/build/distributions/*" -exec chmod a+r {} \; |
| 68 | + |
| 69 | +# Allow other users write access to create checksum files |
| 70 | +find "$WORKSPACE" -type d -path "*/build/distributions" -exec chmod a+w {} \; |
| 71 | + |
| 72 | +echo --- Running release-manager |
| 73 | + |
| 74 | +# Artifacts should be generated |
| 75 | +docker run --rm \ |
| 76 | + --name release-manager \ |
| 77 | + -e VAULT_ADDR="$DRA_VAULT_ADDR" \ |
| 78 | + -e VAULT_ROLE_ID="$DRA_VAULT_ROLE_ID_SECRET" \ |
| 79 | + -e VAULT_SECRET_ID="$DRA_VAULT_SECRET_ID_SECRET" \ |
| 80 | + --mount type=bind,readonly=false,src="$PWD",target=/artifacts \ |
| 81 | + docker.elastic.co/infra/release-manager:latest \ |
| 82 | + cli collect \ |
| 83 | + --project elasticsearch \ |
| 84 | + --branch "$RM_BRANCH" \ |
| 85 | + --commit "$BUILDKITE_COMMIT" \ |
| 86 | + --workflow "$WORKFLOW" \ |
| 87 | + --version "$ES_VERSION" \ |
| 88 | + --artifact-set main \ |
| 89 | + --dependency "beats:https://artifacts-${WORKFLOW}.elastic.co/beats/${BEATS_BUILD_ID}/manifest-${ES_VERSION}${VERSION_SUFFIX}.json" \ |
| 90 | + --dependency "ml-cpp:https://artifacts-${WORKFLOW}.elastic.co/ml-cpp/${ML_CPP_BUILD_ID}/manifest-${ES_VERSION}${VERSION_SUFFIX}.json" |
0 commit comments