Develop - Build and Deploy Snapshot on develop #68
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This builds develop and deploys a snapshot to our repository. | |
# Will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | |
name: Develop - Build and Deploy Snapshot | |
run-name: Develop - Build and Deploy Snapshot on ${{ github.ref_name }} | |
on: | |
push: | |
branches: [ develop ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
MVNCMD: mvn -B -ntp -s ${{ github.workspace }}/.github/settings-istrepo.xml | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
cache: maven | |
maven-version: 3.8.7 | |
- name: Dump event context for debugging | |
continue-on-error: true # Debugging output only, and this annoyingly fails when the commit messge has a ( | |
run: | | |
echo '${{ github.event_name }} for ${{ github.ref_type }} ${{ github.ref_name }} or ${{ github.event.ref }}' | |
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push | |
echo 'github.event:' | |
echo '${{ toJSON(github.event) }}' | |
- name: Dump github context | |
continue-on-error: true # Debugging output only, and this annoyingly fails when the commit message has a ( | |
run: | | |
echo '${{ toJSON(github) }}' | |
- name: Git & Maven Status | |
run: | | |
git status --untracked-files --ignored | |
git log -3 --no-color | |
$MVNCMD -version | |
- name: Mvn Effective POM | |
run: $MVNCMD -P develop -N help:effective-pom | |
- name: Mvn Effective Settings | |
run: $MVNCMD -P develop -N help:effective-settings | |
- name: Build with Maven | |
# When parent-2:1.7 is active, -P ensureSnapshots will do a sanity check of the version number | |
run: $MVNCMD -P ensureSnapshots,test -B verify | |
- name: Sanitycheck version before deploying | |
run: | | |
echo "Version: " | |
$MVNCMD help:evaluate -Dexpression=project.version -q -DforceStdout | |
$MVNCMD help:evaluate -Dexpression=project.version -q -DforceStdout | egrep -- '-SNAPSHOT$' > /dev/null || exit 1 | |
# unfortunately, this would require a snapshot parent if just called from the command line, so we cannot use it: :-( | |
# mvn org.apache.maven.plugins:maven-enforcer-plugin:3.0.0:enforce -Drules=requireSnapshotVersion | |
- name: Deploy with Maven | |
run: $MVNCMD -P develop deploy | |
env: | |
NEXUS_BUILD_USER: ${{ secrets.NEXUS_BUILD_USER }} | |
NEXUS_BUILD_PASSWD: ${{ secrets.NEXUS_BUILD_PASSWD }} |