Skip to content

Commit

Permalink
Add ability to deploy snapshot builds
Browse files Browse the repository at this point in the history
  • Loading branch information
barchetta committed Aug 6, 2023
1 parent fac2c3c commit 4d08847
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 6 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
20 changes: 19 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 Down Expand Up @@ -238,7 +241,7 @@ release_build(){

# Perform deployment
mvn ${MAVEN_ARGS} clean deploy \
-Prelease,archetypes \
-Pdeploy,release,archetypes \
-DskipTests \
-DstagingRepositoryId="${STAGING_REPO_ID}" \
-DretryFailedDeploymentCount="10"
Expand All @@ -262,5 +265,20 @@ release_build(){
git push --force origin refs/tags/"${FULL_VERSION}":refs/tags/"${FULL_VERSION}"
}

deploy_snapshot(){

# Make sure version ends in -SNAPSHOT
if [[ ${FULL_VERSION} != *-SNAPSHOT ]]; then
echo "Helidon version ${FULL_VERSION} is not a SNAPSHOT version. Failing snapshot release."
exit 1
fi

# Perform deployment. Since the version is SNAPSHOT this will go to snapshot repository
mvn ${MAVEN_ARGS} clean deploy \
-Pdeploy,archetypes \
-DskipTests \
-DretryFailedDeploymentCount="10"
}

# Invoke command
${COMMAND}
38 changes: 33 additions & 5 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,6 @@
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
Expand All @@ -248,6 +243,18 @@
</plugins>
</build>
</profile>
<profile>
<id>deploy</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>staging</id>
<repositories>
Expand All @@ -269,5 +276,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 4d08847

Please sign in to comment.