Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions .buildkite/hooks/prepare-common.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail

echo "--- Install JDK17 :java:"
# JDK version is defined in two different locations, here and .github/workflows/maven-goal/action.yml
JAVA_URL=https://jvm-catalog.elastic.co/jdk
JAVA_HOME=$(pwd)/.openjdk17
JAVA_PKG="$JAVA_URL/latest_openjdk_17_linux.tar.gz"
curl -L --output /tmp/jdk.tar.gz "$JAVA_PKG"
mkdir -p "$JAVA_HOME"
tar --extract --file /tmp/jdk.tar.gz --directory "$JAVA_HOME" --strip-components 1

# Configure the java version
JAVA_VERSION=$(cat .java-version | xargs | tr -dc '[:print:]')
JAVA_HOME="${HOME}/.java/openjdk${JAVA_VERSION}"
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
PATH="${JAVA_HOME}/bin:$PATH"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PATH="${JAVA_HOME}/bin:$PATH"
PATH="${JAVA_HOME}/bin:${PATH}"

export PATH

java -version || true
# Fallback to install at runtime
if [ ! -d "${JAVA_HOME}" ] ; then
# This should not be the case normally untless the .java-version file has been changed
# and the VM Image is not yet available with the latest version.
echo "--- Install JDK${JAVA_VERSION} :java:"
JAVA_URL=https://jvm-catalog.elastic.co/jdk
JAVA_PKG="${JAVA_URL}/latest_openjdk_${JAVA_VERSION}_linux.tar.gz"
curl -L --output /tmp/jdk.tar.gz "$JAVA_PKG"
mkdir -p "$JAVA_HOME"
tar --extract --file /tmp/jdk.tar.gz --directory "$JAVA_HOME" --strip-components 1
Comment on lines +18 to +20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
curl -L --output /tmp/jdk.tar.gz "$JAVA_PKG"
mkdir -p "$JAVA_HOME"
tar --extract --file /tmp/jdk.tar.gz --directory "$JAVA_HOME" --strip-components 1
curl -L --output /tmp/jdk.tar.gz "${JAVA_PKG}"
mkdir -p "${JAVA_HOME}"
tar --extract --file /tmp/jdk.tar.gz --directory "${JAVA_HOME}" --strip-components 1

fi

java -version
4 changes: 3 additions & 1 deletion .buildkite/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
agents:
provider: "gcp"
#image: "family/apm-agent-java-ubuntu-2204"

steps:
- label: "Run the release"
Expand All @@ -11,4 +12,5 @@ steps:

notify:
- slack: "#apm-agent-java"
if: 'build.state != "passed"'
# skip slack messages if no failures and dry-run mode
if: 'build.state != "passed" && build.env("dry_run") == "false"'
4 changes: 3 additions & 1 deletion .buildkite/snapshot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
agents:
provider: "gcp"
#image: "family/apm-agent-java-ubuntu-2204"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up


steps:
- label: "Run the snapshot"
Expand All @@ -11,4 +12,5 @@ steps:

notify:
- slack: "#apm-agent-java"
if: 'build.state != "passed"'
# skip slack messages if no failures and dry-run mode
if: 'build.state != "passed" && build.env("dry_run") == "false"'
13 changes: 11 additions & 2 deletions .ci/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,14 @@ echo $PATH
java -version

set +x
echo "--- Deploy the release :package:"
./mvnw -V -s .ci/settings.xml -Pgpg clean deploy -DskipTests --batch-mode | tee release.txt
# Default in dry-run mode
GOAL="install"
DRY_RUN_MSG="(dry-run)"
# Otherwise, a RELEASE
if [[ "$dry_run" == "false" ]] ; then
GOAL="deploy"
DRY_RUN_MSG=""
fi

echo "--- Deploy the release :package: [./mvnw $GOAL)] $DRY_RUN_MSG"
./mvnw -V -s .ci/settings.xml -Pgpg clean $GOAL -DskipTests --batch-mode | tee release.txt
Comment on lines +33 to +34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "--- Deploy the release :package: [./mvnw $GOAL)] $DRY_RUN_MSG"
./mvnw -V -s .ci/settings.xml -Pgpg clean $GOAL -DskipTests --batch-mode | tee release.txt
echo "--- Deploy the release :package: [./mvnw ${GOAL})] ${DRY_RUN_MSG}"
./mvnw -V -s .ci/settings.xml -Pgpg clean ${GOAL} -DskipTests --batch-mode | tee release.txt

15 changes: 10 additions & 5 deletions .ci/snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ echo $PATH
java -version

set +x
echo "--- Deploy the snapshot :package:"
if [[ "$dry_run" == "true" ]] ; then
echo './mvnw -V -s .ci/settings.xml -Pgpg clean deploy -DskipTests --batch-mode'
else
./mvnw -V -s .ci/settings.xml -Pgpg clean deploy -DskipTests --batch-mode | tee snapshot.txt
# Default in dry-run mode
GOAL="install"
DRY_RUN_MSG="(dry-run)"
# Otherwise, a snapshot
if [[ "$dry_run" == "false" ]] ; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [[ "$dry_run" == "false" ]] ; then
if [[ "${dry_run}" == "false" ]] ; then

GOAL="deploy"
DRY_RUN_MSG=""
fi

echo "--- Deploy the snapshot :package: [./mvnw $GOAL)] $DRY_RUN_MSG"
./mvnw -V -s .ci/settings.xml -Pgpg clean $GOAL -DskipTests --batch-mode | tee snapshot.txt
Comment on lines +35 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "--- Deploy the snapshot :package: [./mvnw $GOAL)] $DRY_RUN_MSG"
./mvnw -V -s .ci/settings.xml -Pgpg clean $GOAL -DskipTests --batch-mode | tee snapshot.txt
echo "--- Deploy the snapshot :package: [./mvnw ${GOAL})] ${DRY_RUN_MSG}"
./mvnw -V -s .ci/settings.xml -Pgpg clean ${GOAL} -DskipTests --batch-mode | tee snapshot.txt

2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ jobs:
distribution: 'temurin'
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/maven-goal
- uses: ./.github/workflows/maven-goal-jdk
with:
test-java-version: ${{ matrix.version }}
test-java-distribution: ${{ matrix.distribution }}
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/maven-goal-jdk/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---

name: common build tasks
description: Install specific JDK and run a command

inputs:
test-java-version:
description: 'Testing Java version'
required: true
default: '17'
test-java-distribution:
description: 'Testing Java distribution'
required: true
default: 'temurin'
command:
description: 'Command to execute'
required: true
shell:
description: 'Default shell'
default: 'bash'
required: false

runs:
using: "composite"
steps:
- name: Set up testing JDK
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.test-java-version}}
distribution: ${{ inputs.test-java-distribution}}

- name: Set up TEST_JAVA_BINARY environment variable
shell: bash
run: |
major_version="$(echo '${{ inputs.test-java-version }}' | sed 's/\([0-9]*\).*/\1/')"
java_home_var=JAVA_HOME_${major_version}_${{ runner.arch }}
echo "TEST_JAVA_BINARY=${!java_home_var}/bin/java" >> $GITHUB_ENV

- uses: ./.github/workflows/maven-goal
with:
command: ${{ inputs.command }}
shell: ${{ inputs.shell }}
env:
TEST_JAVA_BINARY: ${{ env.TEST_JAVA_BINARY }}
22 changes: 1 addition & 21 deletions .github/workflows/maven-goal/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ name: common build tasks
description: Install specific JDK and run a command

inputs:
test-java-version:
description: 'Testing Java version'
required: true
default: '17'
test-java-distribution:
description: 'Testing Java distribution'
required: true
default: 'temurin'
command:
description: 'Command to execute'
required: true
Expand All @@ -23,23 +15,11 @@ inputs:
runs:
using: "composite"
steps:
- name: Set up testing JDK
if: ${{ inputs.test-java-version != '17' }}
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.test-java-version}}
distribution: ${{ inputs.test-java-distribution}}
- name: Set up build JDK
uses: actions/setup-java@v4
with:
java-version: 17 # NOTE: This version is also defined in .buildkite/hooks/pre-command
java-version-file: .java-version
distribution: temurin
cache: 'maven'
- name: Set up TEST_JAVA_BINARY environment variable
shell: bash
run: |
major_version="$(echo '${{ inputs.test-java-version }}' | sed 's/\([0-9]*\).*/\1/')"
java_home_var=JAVA_HOME_${major_version}_${{ runner.arch }}
echo "TEST_JAVA_BINARY=${!java_home_var}/bin/java" >> $GITHUB_ENV
- run: ${{ inputs.command }}
shell: ${{ inputs.shell }}
67 changes: 35 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ on:
type: boolean
required: true
default: false
dry_run:
description: If set, run a dry-run release
default: false
type: boolean

env:
JAVA_VERSION: 17
JAVA_DIST: temurin
TAG_NAME: v${{ inputs.version }}

permissions:
Expand Down Expand Up @@ -68,21 +70,21 @@ jobs:
with:
ref: ${{ inputs.branch }}
token: ${{ env.GITHUB_TOKEN }}
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
- name: Install JDK and mvn clean
uses: ./.github/workflows/maven-goal
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DIST }}
cache: 'maven'
command: ./mvnw clean
- name: Prepare changelog for release
if: ${{ inputs.update_changelog }}
if: ${{ inputs.update_changelog && ! inputs.dry_run }}
run: |
java .ci/ReleaseChangelog.java CHANGELOG.asciidoc ${{ inputs.version }}
git commit -m "Prepare changelog for release ${{ inputs.version }}" CHANGELOG.asciidoc
- name: Bump version and add git tag
if: ${{ ! inputs.dry_run }}
run: ./mvnw release:prepare -B -DpushChanges=false "-Darguments=-DskipTests -Dmaven.javadoc.skip=true" -DreleaseVersion=${{ inputs.version }}
- run: git push --atomic origin ${{ inputs.branch }} ${{ env.TAG_NAME }}

- name: Push changes
if: ${{ ! inputs.dry_run }}
run: git push --atomic origin ${{ inputs.branch }} ${{ env.TAG_NAME }}

maven_central_deploy:
name: "Deploy to Maven Central (Buildkite)"
Expand All @@ -103,19 +105,16 @@ jobs:
pipelineCommit: ${{ env.TAG_NAME }}
waitFor: true
printBuildLogs: false
# The action fails with .github/actions/buildkite/run.sh: line 24: 3: parameter missing.
# Which is an unexpected bug.
# Adding a random buildEnvVar to circumvent the behaviour.
buildEnvVars: |
something_something=true

dry_run=${{ inputs.dry_run || 'false' }}

await_artifact_on_maven_central:
name: "Wait for artifacts to be available on maven central"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Await artifacts published in maven central
if: ${{ ! inputs.dry_run }}
shell: bash
timeout-minutes: 120
run: |
Expand Down Expand Up @@ -147,8 +146,11 @@ jobs:
with:
ref: ${{ env.TAG_NAME }}
token: ${{ env.GITHUB_TOKEN }}
- run: .ci/release/update_major_branch.sh ${{ inputs.version }}
- run: git push -f origin "$(echo '${{ inputs.version }}' | sed -E 's/\..+/.x/')"
- name: Update major branch
run: .ci/release/update_major_branch.sh ${{ inputs.version }}
- name: Push changes
if: ${{ ! inputs.dry_run }}
run: git push -f origin "$(echo '${{ inputs.version }}' | sed -E 's/\..+/.x/')"

update_cloudfoundry:
name: "Update Cloudfoundry"
Expand All @@ -175,8 +177,9 @@ jobs:
- name: "Update Cloudfoundry index.yml file"
shell: bash
run: .ci/release/update_cloudfoundry.sh ${{ inputs.version }}
- run: git push origin ${{ inputs.branch }}

- name: Push changes
if: ${{ ! inputs.dry_run }}
run: git push origin ${{ inputs.branch }}

build_and_push_docker_images:
name: "Build and push docker images"
Expand All @@ -199,9 +202,11 @@ jobs:
secretId: ${{ secrets.VAULT_SECRET_ID }}
- name: "Build docker image"
shell: bash
run: |
./scripts/docker-release/build_docker.sh
./scripts/docker-release/push_docker.sh
run: ./scripts/docker-release/build_docker.sh
- name: "Push docker image"
if: ${{ ! inputs.dry_run }}
shell: bash
run: ./scripts/docker-release/push_docker.sh

publish_aws_lambda:
name: "Publish AWS Lambda"
Expand All @@ -218,14 +223,10 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ env.TAG_NAME }}
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DIST }}
cache: 'maven'
- name: Build Lambda-layer zip using agent from maven-central
run: ./mvnw dependency:purge-local-repository package -pl apm-agent-lambda-layer
uses: ./.github/workflows/maven-goal
with:
command: ./mvnw dependency:purge-local-repository package -pl apm-agent-lambda-layer
- uses: hashicorp/vault-action@v3.0.0
with:
url: ${{ secrets.VAULT_ADDR }}
Expand All @@ -236,30 +237,33 @@ jobs:
secret/observability-team/ci/service-account/apm-aws-lambda access_key_id | AWS_ACCESS_KEY_ID ;
secret/observability-team/ci/service-account/apm-aws-lambda secret_access_key | AWS_SECRET_ACCESS_KEY
- name: Publish
if: ${{ ! inputs.dry_run }}
run: |
# Convert v1.2.3 to ver-1-2-3
VERSION=${TAG_NAME/v/ver-}
VERSION=${VERSION//./-}

ELASTIC_LAYER_NAME="elastic-apm-java-${VERSION}" .ci/publish-aws.sh
- uses: actions/upload-artifact@v4
if: ${{ ! inputs.dry_run }}
with:
name: arn-file
path: .ci/.arn-file.md
- name: Add ARN file to output
if: ${{ ! inputs.dry_run }}
id: arn_output
run: |
echo 'arn_content<<ARN_CONTENT_EOF' >> $GITHUB_OUTPUT
cat .ci/.arn-file.md >> $GITHUB_OUTPUT
echo 'ARN_CONTENT_EOF' >> $GITHUB_OUTPUT


create_github_release:
name: "Create GitHub Release"
needs:
- publish_aws_lambda
- update_major_branch
runs-on: ubuntu-latest
if: ${{ ! inputs.dry_run }}
permissions:
contents: write
steps:
Expand All @@ -286,10 +290,9 @@ jobs:
--title="Release ${{ inputs.version }}" \
--notes="[Release Notes for ${{ inputs.version }}](https://www.elastic.co/guide/en/apm/agent/java/current/release-notes-${{ steps.get_dotx_branch.outputs.dotx_branch }}.html#release-notes-${{ inputs.version }})
${{ needs.publish_aws_lambda.outputs.arn_content }}"


notify:
if: always()
if: ${{ always() && ! inputs.dry_run }}
needs:
- prepare_release
- maven_central_deploy
Expand Down
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17