Skip to content

Build and test

Build and test #273

Workflow file for this run

name: Build and test
on:
push:
paths-ignore:
- '.github/**'
- '**/*.md'
tags-ignore:
- '**'
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
skipTests:
description: "Skip Tests?"
required: true
default: "no"
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Set Release version env variable
run: |
echo "TAG_NAME=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
# only build SNAPSHOTS, use release for tagged releases
- name: Check if tag contains SNAPSHOT
if: contains(env.TAG_NAME, 'SNAPSHOT') != true
run: |
echo "Tag '$TAG_NAME' does not contain 'SNAPSHOT', failing build."
exit 1
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 11
server-id: sonatype-nexus
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-passphrase: MAVEN_GPG_PASSPHRASE
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
- name: Deploy SNAPSHOT to maven central
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_PASSWORD }}
SKIP_TESTS: ${{ github.event.inputs.skipTests }}
run: |
./mvnw --batch-mode $(if [ "$SKIP_TESTS" = "yes" ]; then echo "-DskipTests"; fi) clean deploy
- name: Upload jar
uses: actions/upload-artifact@v4
with:
name: sonar-pmd-plugin-${{ env.TAG_NAME }}
path: sonar-pmd-plugin/target/sonar-pmd-plugin-*.jar