Skip to content

Commit

Permalink
3.x: Add ability to deploy snapshot builds (#7315)
Browse files Browse the repository at this point in the history
* Add ability to deploy snapshot builds
  • Loading branch information
barchetta authored Aug 15, 2023
1 parent b644751 commit fd1b383
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 3 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/snapshotrelease.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
32 changes: 31 additions & 1 deletion etc/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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}"
Expand Down Expand Up @@ -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}
25 changes: 23 additions & 2 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

<distributionManagement>
<snapshotRepository>
<id>ossrh-snapshots</id>
<id>ossrh</id>
<name>Helidon Snapshot Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
Expand Down Expand Up @@ -144,7 +144,7 @@

<properties>
<version.plugin.clean>3.3.1</version.plugin.clean>
<version.plugin.deploy>2.8.2</version.plugin.deploy>
<version.plugin.deploy>3.1.1</version.plugin.deploy>
<version.plugin.gpg>1.6</version.plugin.gpg>
<version.plugin.install>3.1.1</version.plugin.install>
<version.plugin.nexus-staging>1.6.13</version.plugin.nexus-staging>
Expand Down Expand Up @@ -269,5 +269,26 @@
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>snapshot</id>
<repositories>
<repository>
<id>ossrh-snapshot</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>ossrh-snapshot</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</project>

0 comments on commit fd1b383

Please sign in to comment.