Skip to content

Commit 0d71fbf

Browse files
swallezl-trotta
authored andcommitted
Add release CI pipeline (#934)
* Add release CI pipeline * Rename DRA build pipeline to its original name --------- Co-authored-by: Laura Trotta <153528055+l-trotta@users.noreply.github.com> Fix action parameter name Update file extension Mount temp dir in build container (ci) Require Sonatype credentials fix fix
1 parent b2668d7 commit 0d71fbf

10 files changed

+163
-42
lines changed

.buildkite/configure_signing.sh

-25
This file was deleted.

.buildkite/pipeline.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
steps:
2-
- label: ":java: :elasticsearch: Elasticsearch Java API client - {{matrix.workflow}}"
2+
- label: ":java: :elasticsearch: Elasticsearch Java API client DRA - {{matrix.workflow}}"
33
agents:
44
provider: "gcp"
55
branches: [ "main", "7.17", "8.x", "8.17", "8.18", "9.0" ]
@@ -8,4 +8,4 @@ steps:
88
workflow:
99
- "snapshot"
1010
- "staging"
11-
command: ".ci/release.sh {{matrix.workflow}}"
11+
command: ".ci/release_dra.sh {{matrix.workflow}}"

.buildkite/release_central.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
agents:
2+
provider: "gcp"
3+
4+
steps:
5+
- label: ":java: :elasticsearch: Elasticsearch Java API client - Release"
6+
key: "release"
7+
command: ".ci/release_central.sh"
8+
artifact_paths:
9+
- ".ci/output/repository/**/*"
10+
11+
#notify:
12+
# - slack: "#devtools-notify"
13+
# # skip slack messages if no failures and dry-run mode
14+
# if: 'build.state != "passed" && build.env("dry_run") == "false"'

.ci/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ COPY --chown=$BUILDER_UID:$BUILDER_GID config ./config/
5050
COPY --chown=$BUILDER_UID:$BUILDER_GID java-client/build.gradle.kts ./java-client/
5151
RUN ./gradlew resolveDependencies
5252

53+
# Note: trailing '*' avoids failing if the file doesn't exist
54+
COPY --chown=$BUILDER_UID:$BUILDER_GID gradle.properties* ./
55+
5356
# Build artifacts. Expects these mounted directories:
5457
# /elasticsearch-java/.git - git index (read-only)
5558
# /elasticsearch-java/java-client/src - source files (read-only)

.ci/make.sh

+13-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
# Bootstrap
4343
# ------------------------------------------------------- #
4444

45-
script_path=$(dirname "$(realpath -s "$0")")
45+
set -euo pipefail
46+
47+
script_path=$(dirname "$(realpath "$0")")
4648
repo=$(realpath "$script_path/../")
4749

4850
# shellcheck disable=SC1090
@@ -51,7 +53,6 @@ TASK=$1
5153
TASK_ARGS=()
5254
VERSION=$2
5355
STACK_VERSION=$VERSION
54-
set -euo pipefail
5556

5657
product="elastic/elasticsearch-java"
5758
output_folder=".ci/output"
@@ -81,6 +82,15 @@ case $CMD in
8182
exit 1
8283
fi
8384
echo -e "\033[36;1mTARGET: assemble artefact $VERSION\033[0m"
85+
TASK=assemble
86+
TASK_ARGS=("$VERSION" "$output_folder")
87+
;;
88+
release)
89+
if [ -z "$VERSION" ]; then
90+
echo -e "\033[31;1mTARGET: release -> missing version parameter\033[0m"
91+
exit 1
92+
fi
93+
echo -e "\033[36;1mTARGET: release artefact $VERSION\033[0m"
8494
TASK=release
8595
TASK_ARGS=("$VERSION" "$output_folder")
8696
;;
@@ -159,7 +169,7 @@ if [[ "$CMD" == "assemble" ]]; then
159169
fi
160170

161171
build_image
162-
echo -e "\033[34;1mINFO:\033[0m Building version ${assemble_version}\033[0m"
172+
echo -e "\033[34;1mINFO:\033[0m Building version ${assemble_version}\033[0m"
163173
docker run --rm --env VERSION=$assemble_version -u "$(id -u)" \
164174
$git_mount $src_mount $output_mount \
165175
$docker_image \

.ci/release_central.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to Elasticsearch B.V. under one or more contributor
4+
# license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright
6+
# ownership. Elasticsearch B.V. licenses this file to you under
7+
# the Apache License, Version 2.0 (the "License"); you may
8+
# not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
21+
#see https://central.sonatype.org/publish/publish-gradle/#distributing-your-public-key
22+
23+
set -euo pipefail
24+
25+
.ci/configure_signing.sh
26+
27+
.ci/make.sh release $VERSION
File renamed without changes.

.github/workflows/release_central.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "Release to Maven Central"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: "Branch or tag ref to run the workflow on"
8+
required: true
9+
version:
10+
description: "The version to release. Must start with the one in config/version.txt"
11+
required: true
12+
dry_run:
13+
description: Used to test other workflow steps, does not publish to Maven Central.
14+
type: boolean
15+
required: true
16+
default: false
17+
18+
env:
19+
BRANCH: ${{ inputs.branch }}
20+
VERSION: ${{ inputs.version }}
21+
DRY_RUN: ${{ inputs.dry_run }}
22+
23+
jobs:
24+
validate-version:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
ref: ${{ inputs.branch }}
31+
fetch-depth: '1'
32+
- name: Validate version
33+
shell: bash
34+
run: |
35+
repo_version="$(cat config/version.txt)"
36+
if [[ ! "$VERSION" = $repo_version* ]]; then
37+
echo "Workflow version ($VERSION) and config/version.txt ($repo_version) do not match."
38+
exit 1
39+
fi
40+
41+
maven-central-deploy:
42+
name: "Deploy to Maven Central (Buildkite)"
43+
runs-on: ubuntu-latest
44+
needs:
45+
- validate-version
46+
steps:
47+
- id: buildkite-run
48+
uses: elastic/oblt-actions/buildkite/run@v1
49+
with:
50+
pipeline: "elasticsearch-java-release"
51+
wait-for: true
52+
token: ${{ secrets.BUILDKITE_TOKEN }}
53+
branch: ${{ inputs.branch }}
54+
env-vars: |
55+
DRY_RUN=${{ inputs.dry_run }}
56+
VERSION=${{ inputs.version }}

catalog-info.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,39 @@ spec:
2626
devtools-team: {}
2727
everyone:
2828
access_level: READ_ONLY
29+
30+
31+
---
32+
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json
33+
apiVersion: backstage.io/v1alpha1
34+
kind: Resource
35+
metadata:
36+
name: buildkite-pipeline-elasticsearch-java-release
37+
description: Buildkite Release pipeline for elasticsearch-java
38+
links:
39+
- title: Pipeline
40+
url: https://buildkite.com/elastic/elasticsearch-java-release
41+
tags:
42+
- buildkite
43+
- gpg-sign
44+
- maven-central
45+
spec:
46+
type: buildkite-pipeline
47+
owner: group:devtools-team
48+
system: buildkite
49+
implementation:
50+
apiVersion: buildkite.elastic.dev/v1
51+
kind: Pipeline
52+
metadata:
53+
description: Elasticsearch Java Client Release
54+
name: elasticsearch-java-release
55+
spec:
56+
repository: elastic/elasticsearch-java
57+
pipeline_file: ".buildkite/release_central.yml"
58+
provider_settings:
59+
trigger_mode: none
60+
teams:
61+
devtools-team:
62+
access_level: MANAGE_BUILD_AND_READ
63+
everyone:
64+
access_level: READ_ONLY

java-client/build.gradle.kts

+12-12
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ tasks.getByName<ProcessResources>("processResources") {
6565
if (name != "apis.json") {
6666
// Only process main source-set resources (test files are large)
6767
expand(
68-
"version" to version,
69-
"git_revision" to (if (rootProject.extra.has("gitHashFull")) rootProject.extra["gitHashFull"] else "unknown")
68+
"version" to version,
69+
"git_revision" to (if (rootProject.extra.has("gitHashFull")) rootProject.extra["gitHashFull"] else "unknown")
7070
)
7171
}
7272
}
@@ -166,7 +166,7 @@ publishing {
166166
// are the same as the one used in the dependency section below.
167167
val xPathFactory = javax.xml.xpath.XPathFactory.newInstance()
168168
val depSelector = xPathFactory.newXPath()
169-
.compile("/project/dependencies/dependency[groupId/text() = 'org.elasticsearch.client']")
169+
.compile("/project/dependencies/dependency[groupId/text() = 'org.elasticsearch.client']")
170170
val versionSelector = xPathFactory.newXPath().compile("version")
171171

172172
var foundVersion = false;
@@ -282,15 +282,15 @@ licenseReport {
282282
class SpdxReporter(val dest: File) : ReportRenderer {
283283
// License names to their SPDX identifier
284284
val spdxIds = mapOf(
285-
"The Apache License, Version 2.0" to "Apache-2.0",
286-
"Apache License, Version 2.0" to "Apache-2.0",
287-
"The Apache Software License, Version 2.0" to "Apache-2.0",
288-
"BSD Zero Clause License" to "0BSD",
289-
"Eclipse Public License 2.0" to "EPL-2.0",
290-
"Eclipse Public License v. 2.0" to "EPL-2.0",
291-
"Eclipse Public License - v 2.0" to "EPL-2.0",
292-
"GNU General Public License, version 2 with the GNU Classpath Exception" to "GPL-2.0 WITH Classpath-exception-2.0",
293-
"COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0" to "CDDL-1.0"
285+
"The Apache License, Version 2.0" to "Apache-2.0",
286+
"Apache License, Version 2.0" to "Apache-2.0",
287+
"The Apache Software License, Version 2.0" to "Apache-2.0",
288+
"BSD Zero Clause License" to "0BSD",
289+
"Eclipse Public License 2.0" to "EPL-2.0",
290+
"Eclipse Public License v. 2.0" to "EPL-2.0",
291+
"Eclipse Public License - v 2.0" to "EPL-2.0",
292+
"GNU General Public License, version 2 with the GNU Classpath Exception" to "GPL-2.0 WITH Classpath-exception-2.0",
293+
"COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0" to "CDDL-1.0"
294294
)
295295

296296
private fun quote(str: String): String {

0 commit comments

Comments
 (0)