Skip to content

Commit

Permalink
Setup BuildKite pipeline (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
swallez committed Sep 28, 2023
1 parent 14c20bd commit 1619418
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
12 changes: 10 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
steps:
- label: ":java: Greetings"
command: "echo 'Hello, world!'"
- label: ":java: :elasticsearch: Elasticsearch Java API client - {{matrix.workflow}}"
agents:
provider: "gcp"
branches: [ "main", "8.10" ]
matrix:
setup:
workflow:
- "snapshot"
- "staging"
command: ".ci/release.sh {{matrix.workflow}}"
61 changes: 61 additions & 0 deletions .ci/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env bash
#
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

set -euo pipefail

WORKFLOW=$1
STACK_VERSION=$(cat config/version.txt)

# Branch: BRANCH env var > Buildkite's BUILDKITE_BRANCH var > minor version
BRANCH=${BRANCH:-${BUILDKITE_BRANCH:-${STACK_VERSION%.*}}}

if [[ "$BRANCH" = "main" && "$WORKFLOW" = "staging" ]]; then
echo "No staging build for the main branch - skipping"
exit 0
fi

# Add snapshot suffix if needed
BUILD_VERSION=$STACK_VERSION
[ "$WORKFLOW" = "snapshot" ] && BUILD_VERSION="${BUILD_VERSION}-SNAPSHOT"

echo "Releasing version $STACK_VERSION, branch: $BRANCH, workflow: $WORKFLOW"

DRA_CREDS=$(vault kv get -field=data -format=json kv/ci-shared/release/dra-role)

.ci/make.sh assemble "$BUILD_VERSION"

# set required permissions on artifacts and directory
chmod -R a+r $PWD/.ci/output/*
chmod -R a+w $PWD/.ci/output
# Artifacts should be generated
docker run --rm \
--name release-manager \
-e VAULT_ADDR="$(echo "$DRA_CREDS" | jq -r '.vault_addr')" \
-e VAULT_ROLE_ID="$(echo "$DRA_CREDS" | jq -r '.role_id')" \
-e VAULT_SECRET_ID="$(echo "$DRA_CREDS" | jq -r '.secret_id')" \
--mount type=bind,readonly=false,src="$PWD",target=/artifacts \
docker.elastic.co/infra/release-manager:latest \
cli collect \
--project elasticsearch-java \
--branch "$BRANCH" \
--commit "$(git rev-parse HEAD)" \
--workflow "$WORKFLOW" \
--version "$STACK_VERSION" \
--artifact-set main

0 comments on commit 1619418

Please sign in to comment.