diff --git a/.github/workflows/assign-issue-to-project.yml b/.github/workflows/assign-issue-to-project.yml deleted file mode 100644 index c728e810958..00000000000 --- a/.github/workflows/assign-issue-to-project.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Assign Issue to Project - -on: - issues: - types: [opened, reopened] -env: - GITHUB_API_KEY: ${{ secrets.GITHUB_TOKEN }} - - -jobs: - Assign-Issue-To-Backlog: - runs-on: ubuntu-latest - steps: - - name: Check out repository code - uses: actions/checkout@v4 - - run: etc/scripts/assign-issue-to-project.sh $GITHUB_REPOSITORY ${{ github.event.issue.number }} Backlog Triage diff --git a/.github/workflows/assign-issue.yml b/.github/workflows/assign-issue.yml new file mode 100644 index 00000000000..d41bd33da66 --- /dev/null +++ b/.github/workflows/assign-issue.yml @@ -0,0 +1,31 @@ +# +# Copyright (c) 2021, 2024 Oracle and/or its affiliates. +# +# Licensed 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. + +name: Assign Issue to Project + +on: + issues: + types: [opened, reopened] +env: + GITHUB_API_KEY: ${{ secrets.GITHUB_TOKEN }} + + +jobs: + Assign-Issue-To-Backlog: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - run: etc/scripts/assign-issue.sh $GITHUB_REPOSITORY ${{ github.event.issue.number }} Backlog Triage diff --git a/.github/workflows/backport-issues.yml b/.github/workflows/backport-issues.yml new file mode 100644 index 00000000000..b017feb9002 --- /dev/null +++ b/.github/workflows/backport-issues.yml @@ -0,0 +1,56 @@ +# +# Copyright (c) 2022, 2024 Oracle and/or its affiliates. +# +# Licensed 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. + +name: Create Backport Issues + +on: + workflow_dispatch: + inputs: + issue: + description: 'Issue number' + required: true + version: + description: 'Helidon version this issue was reported for' + required: true + type: choice + options: + - 2.x + - 3.x + - 4.x + default: '2.x' + target-2: + type: boolean + description: 'Port to 2.x?' + default: false + target-3: + type: boolean + description: 'Port to 3.x?' + default: true + target-4: + type: boolean + description: 'Port to 4.x?' + default: true + +env: + GITHUB_API_KEY: ${{ secrets.GITHUB_TOKEN }} + + +jobs: + Issue-Backport: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - run: etc/scripts/backport-issues.sh $GITHUB_REPOSITORY ${{ github.event.inputs.issue }} ${{ github.event.inputs.version }} ${{ github.event.inputs.target-2 }} ${{ github.event.inputs.target-3 }} ${{ github.event.inputs.target-4 }} diff --git a/.github/workflows/create-backport-issues.yml b/.github/workflows/create-backport-issues.yml deleted file mode 100644 index ec0fb5d79bf..00000000000 --- a/.github/workflows/create-backport-issues.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Create Backport Issues - -on: - workflow_dispatch: - inputs: - issue: - description: 'Issue number' - required: true - version: - description: 'Helidon version this issue was reported for' - required: true - type: choice - options: - - 2.x - - 3.x - - 4.x - default: '2.x' - target-2: - type: boolean - description: 'Port to 2.x?' - default: false - target-3: - type: boolean - description: 'Port to 3.x?' - default: true - target-4: - type: boolean - description: 'Port to 4.x?' - default: true - -env: - GITHUB_API_KEY: ${{ secrets.GITHUB_TOKEN }} - - -jobs: - Issue-Backport: - runs-on: ubuntu-latest - steps: - - name: Check out repository code - uses: actions/checkout@v4 - - run: etc/scripts/create-backport-issues.sh $GITHUB_REPOSITORY ${{ github.event.inputs.issue }} ${{ github.event.inputs.version }} ${{ github.event.inputs.target-2 }} ${{ github.event.inputs.target-3 }} ${{ github.event.inputs.target-4 }} diff --git a/.github/workflows/pr-merge.yaml b/.github/workflows/pr-merge.yaml index 5841badecd7..03e92433a19 100644 --- a/.github/workflows/pr-merge.yaml +++ b/.github/workflows/pr-merge.yaml @@ -1,5 +1,17 @@ # -# Workflow that runs on any push to main. +# Copyright (c) 2024 Oracle and/or its affiliates. +# +# Licensed 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. name: "Post PR Merge" @@ -18,5 +30,5 @@ jobs: uses: ./.github/workflows/validate.yml snapshot: needs: validate - uses: ./.github/workflows/snapshotrelease.yaml + uses: ./.github/workflows/snapshot.yaml secrets: inherit diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e7e72b18ad3..45c92e84f1b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,66 +1,74 @@ -# Notes -# - cannot run on Windows, as we use shell scripts +# +# Copyright (c) 2023, 2024 Oracle and/or its affiliates. +# +# Licensed 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. name: "Release" on: push: - branches: - - 'release-*' + branches: [ 'release-*' ] + env: JAVA_VERSION: '21' JAVA_DISTRO: 'oracle' - MAVEN_HTTP_ARGS: '-Dmaven.wagon.httpconnectionManager.ttlSeconds=60 -Dmaven.wagon.http.retryHandler.count=3' + MAVEN_ARGS: | + -B -e + -Dmaven.wagon.httpconnectionManager.ttlSeconds=60 + -Dmaven.wagon.http.retryHandler.count=3 + -Djdk.toolchain.version=${JAVA_VERSION} concurrency: group: release-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: - copyright: - timeout-minutes: 10 + create-tag: runs-on: ubuntu-20.04 + environment: release + outputs: + tag: ${{ steps.create-tag.outputs.tag }} steps: - uses: actions/checkout@v4 with: - fetch-depth: 0 - - name: Set up JDK ${{ env.JAVA_VERSION }} + token: ${{ secrets.SERVICE_ACCOUNT_TOKEN }} + - name: Set up JDK uses: actions/setup-java@v4.1.0 with: distribution: ${{ env.JAVA_DISTRO }} java-version: ${{ env.JAVA_VERSION }} - cache: maven - - name: Copyright - run: etc/scripts/copyright.sh + - id: create-tag + run: ./etc/scripts/release.sh create_tag >> "${GITHUB_OUTPUT}" + validate: + needs: create-tag + uses: ./.github/workflows/validate.yml + with: + ref: ${{ needs.create-tag.outputs.tag }} release: - timeout-minutes: 60 + needs: [ create-tag, validate ] runs-on: ubuntu-20.04 + timeout-minutes: 30 environment: release steps: - uses: actions/checkout@v4 with: - token: ${{ secrets.SERVICE_ACCOUNT_TOKEN }} - fetch-depth: '0' - - name: Set up JDK ${{ env.JAVA_VERSION }} - uses: actions/setup-java@v4.1.0 + ref: ${{ needs.create-tag.outputs.tag }} + - uses: ./.github/actions/common with: - distribution: ${{ env.JAVA_DISTRO }} - java-version: ${{ env.JAVA_VERSION }} - cache: maven - - name: Release - env: - GPG_PASSPHRASE: ${{ secrets.HELIDON_GPG_PASSPHRASE }} - GPG_PRIVATE_KEY: ${{ secrets.HELIDON_GPG_PRIVATE_KEY }} - GPG_PUBLIC_KEY: ${{ secrets.HELIDON_GPG_PUBLIC_KEY }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} MAVEN_SETTINGS: ${{ secrets.MAVEN_SETTINGS }} - RELEASE_WORKFLOW: "true" - run: | - git config user.email "helidon-robot_ww@oracle.com" - git config user.name "Helidon Robot" - etc/scripts/release.sh release_build - - name: Upload Staged Artifacts - uses: actions/upload-artifact@v4 - with: - name: io-helidon-artifacts-${{ github.ref_name }} - path: parent/target/nexus-staging/ - retention-days: 90 + build-cache: read-only + artifact-name: io-helidon-artifacts-${{ github.ref_name }} + artifact-path: target/nexus-staging/ + run: etc/scripts/release.sh release_build diff --git a/.github/workflows/snapshotrelease.yaml b/.github/workflows/snapshot.yaml similarity index 60% rename from .github/workflows/snapshotrelease.yaml rename to .github/workflows/snapshot.yaml index d32f67eee92..9a094ebc14f 100644 --- a/.github/workflows/snapshotrelease.yaml +++ b/.github/workflows/snapshot.yaml @@ -1,6 +1,17 @@ -# Perform a snapshot build and deploy to snapshot repository -# Notes -# - cannot run on Windows, as we use shell scripts +# +# Copyright (c) 2023, 2024 Oracle and/or its affiliates. +# +# Licensed 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. name: "Snapshot Release" diff --git a/.mvn/cache-config.xml b/.mvn/cache-config.xml index a3a9224975e..05ae14ba323 100644 --- a/.mvn/cache-config.xml +++ b/.mvn/cache-config.xml @@ -70,11 +70,6 @@ tests/integration/packaging/** - - - tests/integration/packaging/** - - tests/integration/** diff --git a/etc/scripts/assign-issue-to-project.sh b/etc/scripts/assign-issue.sh similarity index 100% rename from etc/scripts/assign-issue-to-project.sh rename to etc/scripts/assign-issue.sh diff --git a/etc/scripts/create-backport-issues.sh b/etc/scripts/backport-issues.sh similarity index 100% rename from etc/scripts/create-backport-issues.sh rename to etc/scripts/backport-issues.sh diff --git a/etc/scripts/build-examples.sh b/etc/scripts/build-examples.sh index a9ac86b1a2a..cace3a84a16 100755 --- a/etc/scripts/build-examples.sh +++ b/etc/scripts/build-examples.sh @@ -15,8 +15,6 @@ # limitations under the License. # -# Build helidon examples, cloning the examples repository if needed - set -o pipefail || true # trace ERR through pipes set -o errtrace || true # trace ERR through commands and functions set -o errexit || true # exit the script if any statement returns a non-true return value @@ -43,31 +41,35 @@ readonly SCRIPT_PATH WS_DIR=$(cd $(dirname -- "${SCRIPT_PATH}") ; cd ../.. ; pwd -P) readonly WS_DIR -# If needed we clone the helidon-examples repo into a subdirectory of the helidon repository -readonly HELIDON_EXAMPLES_PATH=${WS_DIR}/helidon-examples +version() { + awk 'BEGIN {FS="[<>]"} ; // {print $3; exit 0}' "${1}" +} + +HELIDON_VERSION=$(version "${WS_DIR}/bom/pom.xml") +readonly HELIDON_VERSION + +# If needed we clone the helidon-examples repo if [ ! -d "${WS_DIR}/helidon-examples" ]; then echo "Cloning examples repository into ${WS_DIR}/helidon-examples" git clone --branch dev-4.x --single-branch https://github.com/helidon-io/helidon-examples.git "${WS_DIR}/helidon-examples" -fi -version() { - # shellcheck disable=SC2086 - mvn ${MAVEN_ARGS} -B -N -f "${1}" -Dexpression=helidon.version help:evaluate | grep -v '\[INFO\]' -} - -# Make sure the helidon version from the example repo aligns with this repository -HELIDON_VERSION_IN_THIS_REPO=$(version "${WS_DIR}/pom.xml") -readonly HELIDON_VERSION_IN_THIS_REPO + # If in a tag, update the version on the fly + if [ -n "$(git tag --points-at HEAD)" ] ; then + export TMPDIR=/tmp # FIXME remove tmp hack + "${WS_DIR}/helidon-examples"/etc/scripts/updatehelidonversion.sh "${HELIDON_VERSION}" + fi +fi HELIDON_VERSION_IN_EXAMPLES=$(version "${WS_DIR}/helidon-examples/pom.xml") readonly HELIDON_VERSION_IN_EXAMPLES -if [ "${HELIDON_VERSION_IN_THIS_REPO}" != "${HELIDON_VERSION_IN_EXAMPLES}" ]; then +# Make sure the helidon version from the example repo aligns with this repository +if [ "${HELIDON_VERSION}" != "${HELIDON_VERSION_IN_EXAMPLES}" ]; then printf "The Helidon version in this repository (%s) does not match the Helidon version in %s (%s)\n" \ - "${HELIDON_VERSION_IN_THIS_REPO}" \ - "${HELIDON_EXAMPLES_PATH}" \ + "${HELIDON_VERSION}" \ + "${WS_DIR}/helidon-examples" \ "${HELIDON_VERSION_IN_EXAMPLES}" - exit 78 + exit 1 fi # shellcheck disable=SC2086 diff --git a/etc/scripts/release.sh b/etc/scripts/release.sh index 1f2884eab87..bbb84551218 100755 --- a/etc/scripts/release.sh +++ b/etc/scripts/release.sh @@ -23,7 +23,7 @@ on_error(){ CODE="${?}" && \ set +x && \ printf "[ERROR] Error(code=%s) occurred at %s:%s command: %s\n" \ - "${CODE}" "${BASH_SOURCE[0]}" "${LINENO}" "${BASH_COMMAND}" + "${CODE}" "${BASH_SOURCE[0]}" "${LINENO}" "${BASH_COMMAND}" >&2 } trap on_error ERR @@ -111,13 +111,7 @@ fi exec 6>&1 1>&2 current_version() { - # shellcheck disable=SC2086 - mvn ${MAVEN_ARGS} -q \ - -f "${WS_DIR}"/pom.xml \ - -Dexec.executable="echo" \ - -Dexec.args="\${project.version}" \ - --non-recursive \ - org.codehaus.mojo:exec-maven-plugin:1.3.1:exec + awk 'BEGIN {FS="[<>]"} ; // {print $3; exit 0}' "${WS_DIR}"/parent/pom.xml } release_version() { @@ -126,22 +120,56 @@ release_version() { echo "${current_version%-*}" } +search() { + set +o pipefail + grep "${1}" -Er . --include "${2}" --exclude-dir "${3}" | cut -d ':' -f 1 | sort | uniq +} + replace() { - local pattern value include - pattern="${1}" - value="${2}" - include="${3}" - for file in $(grep "${pattern}" -Er . --include "${include}" | cut -d ':' -f 1 | sort | uniq); do + local pattern value replace include exclude_dir + while (( ${#} > 0 )); do + case ${1} in + "--pattern="*) + pattern=${1#*=} + shift + ;; + "--include="*) + include=${1#*=} + shift + ;; + "--replace="*) + replace=${1#*=} + shift + ;; + "--value="*) + value=${1#*=} + shift + ;; + "--exclude-dir="*) + exclude_dir=${1#*=} + shift + ;; + *) + echo "Unsupported argument: ${1}" >&2 + return 1 + ;; + esac + done + + if [ -z "${replace}" ] && [ -n "${value}" ] ; then + replace=${pattern/\.\*/${value}} + fi + + for file in $(search "${pattern}" "${include}" "${exclude_dir}"); do echo "Updating ${file}" - sed -e s@"${pattern}"@"${pattern/\.\*/${value}}"@g \ - < "${file}" \ - > "${file}.tmp" + sed -e s@"${pattern}"@"${replace}"@g "${file}" > "${file}.tmp" mv "${file}.tmp" "${file}" done } update_version(){ - local version + local version current_version is_release + version=${1-${VERSION}} if [ -z "${version+x}" ] ; then echo "ERROR: version required" @@ -149,33 +177,38 @@ update_version(){ exit 1 fi - # shellcheck disable=SC2086 - mvn ${MAVEN_ARGS} "${ARGS[@]}" \ - -f ${WS_DIR}/parent/pom.xml versions:set versions:set-property \ - -DgenerateBackupPoms="false" \ - -DnewVersion="${version}" \ - -Dproperty="helidon.version" \ - -DprocessFromLocalAggregationRoot="false" \ - -DupdateMatchingVersions="false" - - # Hack to update helidon.version - replace ".*" "${version}" "pom.xml" - - # Hack to update helidon.version in build.gradle files - replace "helidonversion = .*" "${version}" "build.gradle" - - # Hack to update helidon-version in doc files - replace ":helidon-version: .*" "${version}" "attributes.adoc" - - # Hack to update helidon-version-is-release in doc files - # We are a released version if we are not a SNAPSHOT version - local is_released - if [[ ${1} == *-SNAPSHOT ]]; then - is_released="false" + if [[ ${version} == *-SNAPSHOT ]]; then + is_release="false" else - is_released="true" + is_release="true" fi - replace ":helidon-version-is-release: .*" "${is_released}" "attributes.adoc" + + # find current version + current_version=$(current_version) + + # update poms + replace \ + --pattern="${current_version}" \ + --replace="${version}" \ + --include="pom.xml" \ + --exclude-dir="helidon-examples" + + replace \ + --pattern=".*" \ + --value="${version}" \ + --include="pom.xml" \ + --exclude-dir="helidon-examples" + + # update docs + replace \ + --pattern=":helidon-version: .*" \ + --value="${version}" \ + --include="attributes.adoc" + + replace \ + --pattern=":helidon-version-is-release: .*" \ + --value="${is_release}" \ + --include="attributes.adoc" } create_tag() { @@ -229,20 +262,21 @@ credentials() { } release_build(){ - local tmpfile version + local version credentials # Perform local deployment # shellcheck disable=SC2086 mvn ${MAVEN_ARGS} "${ARGS[@]}" \ - deploy \ -Prelease \ -DskipTests \ - -DskipRemoteStaging=true + -DskipRemoteStaging=true \ + deploy # Upload all artifacts to nexus version=$(release_version) + # shellcheck disable=SC2086 mvn ${MAVEN_ARGS} -N nexus-staging:deploy-staged \ -DstagingDescription="Helidon v${version}" diff --git a/etc/scripts/test-quickstarts.sh b/etc/scripts/test-quickstarts.sh index 78c0b1b4313..73ebfe35ad4 100755 --- a/etc/scripts/test-quickstarts.sh +++ b/etc/scripts/test-quickstarts.sh @@ -40,6 +40,10 @@ readonly SCRIPT_PATH WS_DIR=$(cd $(dirname -- "${SCRIPT_PATH}") ; cd ../.. ; pwd -P) readonly WS_DIR +version() { + awk 'BEGIN {FS="[<>]"} ; // {print $3; exit 0}' "${1}" +} + if [ -z "${GRAALVM_HOME}" ]; then echo "ERROR: GRAALVM_HOME is not set"; exit 1 @@ -55,10 +59,18 @@ mvn ${MAVEN_ARGS} --version "${GRAALVM_HOME}"/bin/native-image --version; -# If needed we clone the helidon-examples repo into a subdirectory of the helidon repository +HELIDON_VERSION=$(version "${WS_DIR}/bom/pom.xml") +readonly HELIDON_VERSION + +# If needed we clone the helidon-examples repo if [ ! -d "${WS_DIR}/helidon-examples" ]; then - echo "Cloning examples repository into ${HELIDON_EXAMPLES_PATH}" + echo "Cloning examples repository into ${WS_DIR}/helidon-examples" git clone --branch dev-4.x --single-branch https://github.com/helidon-io/helidon-examples.git "${WS_DIR}/helidon-examples" + + # If in a tag, update the version on the fly + if [ -n "$(git tag --points-at HEAD)" ] ; then + "${WS_DIR}/helidon-examples"/etc/scripts/updatehelidonversion.sh "${HELIDON_VERSION}" + fi fi # Build quickstart native-image executable and run jar file