diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index d5ee33e..5debc14 100755 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -45,16 +45,23 @@ echo "--- Configure git context :git:" git config --global user.email "infra-root+apmmachine@elastic.co" git config --global user.name "apmmachine" -echo "--- Install JDK17 :java:" -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}" 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 +fi + +java -version \ No newline at end of file diff --git a/.buildkite/release.yml b/.buildkite/release.yml index 1b8638b..e486e89 100644 --- a/.buildkite/release.yml +++ b/.buildkite/release.yml @@ -1,5 +1,6 @@ agents: provider: "gcp" + #image: "family/ecs-logging-java-ubuntu-2204" steps: - label: "Run the release" @@ -8,6 +9,6 @@ steps: artifact_paths: "release.txt" notify: - - slack: - channels: - - "#apm-agent-java" + - slack: "#apm-agent-java" + # skip slack messages if no failures and dry-run mode + if: 'build.state != "passed" && build.env("dry_run") == "false"' diff --git a/.buildkite/snapshot.yml b/.buildkite/snapshot.yml index c33406f..e240188 100644 --- a/.buildkite/snapshot.yml +++ b/.buildkite/snapshot.yml @@ -1,5 +1,6 @@ agents: provider: "gcp" + #image: "family/ecs-logging-java-ubuntu-2204" steps: - label: "Run the snapshot" @@ -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"' diff --git a/.ci/release.sh b/.ci/release.sh index d2cf966..7e40208 100755 --- a/.ci/release.sh +++ b/.ci/release.sh @@ -27,9 +27,14 @@ echo $PATH java -version set +x -echo "--- Release the binaries to Maven Central :maven:" -if [[ "${dry_run}" == "true" ]] ; then - ./mvnw -V -s .ci/settings.xml -Pgpg clean package --batch-mode | tee release.txt -else - ./mvnw -V -s .ci/settings.xml -Pgpg clean deploy --batch-mode | tee release.txt +# Default in dry-run mode +GOAL="package" +DRY_RUN_MSG="(dry-run)" +# Otherwise, a RELEASE +if [[ "$dry_run" == "false" ]] ; then + GOAL="deploy" + DRY_RUN_MSG="" fi + +echo "--- Release the binaries to Maven Central :maven: [./mvnw ${GOAL})] ${DRY_RUN_MSG}" +./mvnw -V -s .ci/settings.xml -Pgpg clean $GOAL -DskipTests --batch-mode | tee release.txt diff --git a/.ci/snapshot.sh b/.ci/snapshot.sh index 98996c9..80e4614 100755 --- a/.ci/snapshot.sh +++ b/.ci/snapshot.sh @@ -24,9 +24,14 @@ echo $PATH java -version set +x -echo "--- Deploy the snapshot :package:" -if [[ "$dry_run" == "true" ]] ; then - ./mvnw -V -s .ci/settings.xml -Pgpg clean package --batch-mode | tee snapshot.txt -else - ./mvnw -V -s .ci/settings.xml -Pgpg clean deploy --batch-mode | tee snapshot.txt +# Default in dry-run mode +GOAL="package" +DRY_RUN_MSG="(dry-run)" +# Otherwise, a RELEASE +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 diff --git a/.github/workflows/maven-goal/action.yml b/.github/workflows/maven-goal/action.yml index 4a2468a..7b8dbb9 100644 --- a/.github/workflows/maven-goal/action.yml +++ b/.github/workflows/maven-goal/action.yml @@ -4,10 +4,6 @@ name: maven-goal description: Install specific JDK and run a command inputs: - version: - description: 'Java version' - required: true - default: '17' distribution: description: 'Java distribution' required: true @@ -26,7 +22,7 @@ runs: - name: Set up JDK uses: actions/setup-java@v4 with: - java-version: ${{ inputs.version }} + java-version-file: .java-version distribution: ${{ inputs.distribution }} cache: 'maven' - run: ${{ inputs.command }} diff --git a/.java-version b/.java-version new file mode 100644 index 0000000..8e2afd3 --- /dev/null +++ b/.java-version @@ -0,0 +1 @@ +17 \ No newline at end of file