From fd1b3835ffa0e2148d31de5467cd05eb50f8b14e Mon Sep 17 00:00:00 2001 From: Joe DiPol Date: Tue, 15 Aug 2023 15:43:00 -0700 Subject: [PATCH] 3.x: Add ability to deploy snapshot builds (#7315) * Add ability to deploy snapshot builds --- .github/workflows/snapshotrelease.yaml | 39 ++++++++++++++++++++++++++ etc/scripts/release.sh | 32 ++++++++++++++++++++- parent/pom.xml | 25 +++++++++++++++-- 3 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/snapshotrelease.yaml diff --git a/.github/workflows/snapshotrelease.yaml b/.github/workflows/snapshotrelease.yaml new file mode 100644 index 00000000000..46f0349106a --- /dev/null +++ b/.github/workflows/snapshotrelease.yaml @@ -0,0 +1,39 @@ +# Perform a snapshot build and deploy to snapshot repository +# Notes +# - cannot run on Windows, as we use shell scripts + +name: "Snapshot Release" + +on: + workflow_dispatch: + +env: + JAVA_VERSION: '17' + JAVA_DISTRO: 'oracle' + MAVEN_HTTP_ARGS: '-Dmaven.wagon.httpconnectionManager.ttlSeconds=60 -Dmaven.wagon.http.retryHandler.count=3' + +concurrency: + group: release-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +jobs: + deploy: + timeout-minutes: 60 + runs-on: ubuntu-20.04 + environment: release + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: '0' + - name: Set up JDK 17 + uses: actions/setup-java@v3.11.0 + with: + distribution: ${{ env.JAVA_DISTRO }} + java-version: ${{ env.JAVA_VERSION }} + cache: maven + - name: Build and deploy + env: + MAVEN_SETTINGS: ${{ secrets.MAVEN_SETTINGS }} + RELEASE_WORKFLOW: "true" + run: | + etc/scripts/release.sh deploy_snapshot \ No newline at end of file diff --git a/etc/scripts/release.sh b/etc/scripts/release.sh index 88caa486471..3156e5c784a 100755 --- a/etc/scripts/release.sh +++ b/etc/scripts/release.sh @@ -49,6 +49,9 @@ $(basename ${0}) [ --build-number=N ] CMD Perform a release build This will create a local branch, deploy artifacts and push a tag + deploy_snapshot + Perform a snapshot build and deploy to snapshot repository + EOF } @@ -66,7 +69,7 @@ for ((i=0;i<${#ARGS[@]};i++)) exit 0 ;; *) - if [ "${ARG}" = "update_version" ] || [ "${ARG}" = "release_build" ] ; then + if [ "${ARG}" = "update_version" ] || [ "${ARG}" = "release_build" ] || [ "${ARG}" = "deploy_snapshot" ] ; then readonly COMMAND="${ARG}" else echo "ERROR: unknown argument: ${ARG}" @@ -262,5 +265,32 @@ release_build(){ git push --force origin refs/tags/"${FULL_VERSION}":refs/tags/"${FULL_VERSION}" } +deploy_snapshot(){ + + # Make sure version ends in -SNAPSHOT + if [[ ${MVN_VERSION} != *-SNAPSHOT ]]; then + echo "Helidon version ${MVN_VERSION} is not a SNAPSHOT version. Failing snapshot release." + exit 1 + fi + + readonly NEXUS_SNAPSHOT_URL="https://oss.sonatype.org/content/repositories/snapshots/" + echo "Deploying snapshot build ${MVN_VERSION} to ${NEXUS_SNAPSHOT_URL}" + + # The nexus-staging-maven-plugin had issues deploying the module + # helidon-applications because the distributionManagement section is empty. + # So we deploy using the apache maven-deploy-plugin and altDeploymentRepository + # property. The deployAtEnd option requires version 3.0.0 of maven-deploy-plugin + # or newer to work correctly on multi-module systems + set -x + mvn ${MAVEN_ARGS} -e clean deploy \ + -Parchetypes \ + -DskipTests \ + -DaltDeploymentRepository="ossrh::${NEXUS_SNAPSHOT_URL}" \ + -DdeployAtEnd=true \ + -DretryFailedDeploymentCount="10" + + echo "Done. ${MVN_VERSION} deployed to ${NEXUS_SNAPSHOT_URL}" +} + # Invoke command ${COMMAND} diff --git a/parent/pom.xml b/parent/pom.xml index 537234f87aa..78ccdbf588a 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -53,7 +53,7 @@ - ossrh-snapshots + ossrh Helidon Snapshot Repository https://oss.sonatype.org/content/repositories/snapshots/ @@ -144,7 +144,7 @@ 3.3.1 - 2.8.2 + 3.1.1 1.6 3.1.1 1.6.13 @@ -269,5 +269,26 @@ + + snapshot + + + ossrh-snapshot + https://oss.sonatype.org/content/repositories/snapshots/ + + true + + + + + + ossrh-snapshot + https://oss.sonatype.org/content/repositories/snapshots/ + + true + + + +