Housekeeping: Add dependabot.yml for GitHub Actions and Maven updates #114
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: Build | |
on: | |
push: | |
branches: | |
- '**' | |
tags-ignore: | |
- '**' | |
pull_request: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Allows reuse of this workflow as a generic "Java build with Maven that publishes to main on merge" | |
workflow_call: | |
jobs: | |
build_feature_branch: | |
name: Build feature branch | |
runs-on: ubuntu-latest | |
if: "github.ref != 'refs/heads/main'" | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup Java and Maven | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 21 | |
cache: 'maven' | |
- name: Build with Maven verify | |
run: ./mvnw -B verify | |
build_main_branch: | |
name: Build main branch | |
runs-on: ubuntu-latest | |
if: "github.ref == 'refs/heads/main'" | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: true | |
- name: Setup Java and Maven | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 21 | |
cache: 'maven' | |
server-id: 'reload' | |
server-username: MAVEN_SERVER_USERNAME | |
server-password: MAVEN_SERVER_PASSWORD | |
- name: Read revision version from pom.xml | |
shell: bash | |
run: | | |
MAVEN_POM_REVISION_VERSION="$(./mvnw help:evaluate -Dexpression=revision -q -DforceStdout)" | |
echo "MAVEN_POM_REVISION_VERSION=$MAVEN_POM_REVISION_VERSION" >> $GITHUB_ENV | |
- name: Check if revision is already tagged | |
shell: bash | |
run: | | |
if git tag -l $MAVEN_POM_REVISION_VERSION | grep -q $MAVEN_POM_REVISION_VERSION; then | |
echo "Revision $MAVEN_POM_REVISION_VERSION is already tagged. Skipping the build and deployment!" | |
exit 0 | |
else | |
DEPLOY_RELEASE=true | |
echo "DEPLOY_RELEASE=$DEPLOY_RELEASE" >> $GITHUB_ENV | |
fi | |
- name: Build with Maven deploy | |
if: ${{ env.DEPLOY_RELEASE == 'true' }} | |
run: ./mvnw -Dchangelist= -B deploy | |
env: | |
MAVEN_SERVER_USERNAME: ${{ secrets.MAVEN_SERVER_USERNAME }} | |
MAVEN_SERVER_PASSWORD: ${{ secrets.MAVEN_SERVER_PASSWORD }} | |
- name: Create new git tag | |
uses: rickstaa/action-create-tag@v1 | |
if: ${{ env.DEPLOY_RELEASE == 'true' }} | |
with: | |
tag: ${{ env.MAVEN_POM_REVISION_VERSION }} | |
message: Release ${{ env.MAVEN_POM_REVISION_VERSION }} |