Merge pull request #8 from levigo/bugfix/INF-57_gh_actions_update #26
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
name: Continuous Delivery | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
# - '.github/**' | |
- '**/README.md' | |
env: | |
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log. | |
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work. | |
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" | |
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used | |
# when running from the command line. | |
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins. | |
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Bump version and create tag | |
id: semanticversion | |
uses: mathieudutour/github-tag-action@v6.2 | |
with: | |
release_branches: main | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Verify and print new build number | |
run: | | |
if echo '${{ steps.semanticversion.outputs.new_tag }}' |grep -Eq '^v[0-9]+[.][0-9]+[.][0-9]+$'; then | |
echo Tag '${{ steps.semanticversion.outputs.new_tag }}', New version '${{ steps.semanticversion.outputs.new_version }}', Changelog '${{ steps.semanticversion.outputs.changelog }}' | |
else | |
echo 'unexpected tag format - aborting' | |
exit -1 | |
fi | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
cache: 'maven' | |
- name: Prepare maven settings | |
env: | |
REPOSITORY_USERID: ${{ secrets.PUB_NEXUS2_USERNAME_RW }} | |
REPOSITORY_CREDENTIALS: ${{ secrets.PUB_NEXUS2_PASSWORD_RW }} | |
run: | | |
mkdir -p ~/.m2 | |
envsubst < ./.github/settings.xml > ~/.m2/settings.xml | |
- name: Set version | |
id: version | |
run: | | |
echo Releasing as ${{ steps.semanticversion.outputs.new_version }} | |
mvn $MAVEN_CLI_OPTS versions:set -DnewVersion=${{ steps.semanticversion.outputs.new_version }} | |
- name: Perform build | |
run: mvn $MAVEN_CLI_OPTS package -DskipTests -Dmaven.test.failure.ignore=true | |
- name: Publish Test Report | |
uses: scacap/action-surefire-report@v1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
fail_on_test_failures: true | |
fail_if_no_tests: false | |
- name: Deploy artifacts | |
env: | |
REPO_URL: ${{ secrets.NEXUS2_REPO_RELEASES }} | |
run: mvn $MAVEN_CLI_OPTS deploy -DaltDeploymentRepository=levigo::default::${REPO_URL} -Dmaven.test.skip.exec=true -Dmaven.install.skip=true | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: Release ${{ steps.semanticversion.outputs.new_version }} | |
tag_name: ${{ steps.semanticversion.outputs.new_tag }} |