SongodaCore/.github/workflows/sonarcloud.yml
Christian Koop 5e1f1b802c
Introduce new CI/CD pipeline using GitHub Actions
A lot is happening in this release!

tl;dr: GitHub Actions runs tests, compiles the project, signs the jar files, deploys them to the Maven repo; Pushing a git tag issues a release instead of snapshot deployment; -SNAPSHOT is always added to the version otherwise; Core Version is now injected by maven instead of manually updating it in one of the classes


We now use GitHub Actions to run automated tests, compile the project, sign the resulting jar files, and always deploy a version to the Maven repo.
By default, a snapshot release is published but by creating a git tag, a release deploy can be triggered.

Additionally the Core version is not manually updated in one of the classes but injected after compiling it.
I think I found the most stable and easiest way to do this in maven,
although I'd have wished for it to be easier and maybe not after the class file has already been created.
2022-08-07 19:33:38 +02:00

44 lines
1.0 KiB
YAML

name: SonarCloud
on:
push:
branches: [ master, development ]
pull_request:
types: [ opened, synchronize, reopened ]
permissions: read-all
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_PROJECT_KEY: songoda_SongodaCore
jobs:
Analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
if: ${{ env.SONAR_TOKEN != null }}
with:
fetch-depth: 0
- name: Prepare Workspace
if: ${{ env.SONAR_TOKEN != null }}
uses: ./.github/actions/setup_project_workspace
- name: 'Cache: SonarCloud'
if: ${{ env.SONAR_TOKEN != null }}
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
- name: Analyze project
if: ${{ env.SONAR_TOKEN != null }}
run: >
mvn -B \
verify \
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
"-Dsonar.projectKey=$SONAR_PROJECT_KEY"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}