Skip to content

Commit

Permalink
In progress migration to GH actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mivek committed Apr 19, 2022
1 parent 750d863 commit e6c7353
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 2 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build_sonar_verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Cache SonarCloud packages
uses: actions/cache@v2
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
46 changes: 46 additions & 0 deletions .github/workflows/bump-pom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Bump POM
on:
push:
branches:
- master
jobs:
bump_pom:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Expose git commit data
uses: rlespinasse/[email protected]

- name: Bump pom patch version for fixes and clean
run: |
mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} -DprocessAllModules versions:commit
if: "contains(env.GIT_COMMIT_MESSAGE_SUBJECT , 'Merge pull request') &&
(contains(env.GIT_COMMIT_MESSAGE_SUBJECT , 'fix') || contains(env.GIT_COMMIT_MESSAGE_SUBJECT , 'clean'))"

- name: Bump pom minor version for feature
run: |
mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0 -DprocessAllModules versions:commit
if: "contains(env.GIT_COMMIT_MESSAGE_SUBJECT , 'Merge pull request') && contains(env.GIT_COMMIT_MESSAGE_SUBJECT , 'feature')"

- name: Bump pom major version for major feature
run: |
mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0 -DprocessAllModules versions:commit
if: "contains(env.commit_message, 'Merge pull request') &&
(contains(env.GIT_COMMIT_MESSAGE_SUBJECT , 'clean') || contains(env.GIT_COMMIT_MESSAGE_SUBJECT , 'major'))"
- name: Retrieve the version
run: |
echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- name: Commit and tag
uses: EndBug/[email protected]
with:
add: "['pom.xml', './**/pom.xml']"
default_author: github_actions
message: Bump pom
tag: ${{ env.version }}
if: "contains(env.commit_message, 'Merge pull request')"
35 changes: 35 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Deploy to maven repository after bump pom

on:
push:
tags:
- "\d.\d.\d"

jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.actor == '' }}
steps:
- uses: actions/checkout@v2

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'

- name: Publish to Apache Maven Central
run: mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent -DskipTests deploy sonar:sonar --settings .settings.xml -P release,ossrh
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

- name: Upload the Jars
uses: actions/upload-artifact@v2
with:
path: /**/target/*.jar

# Remains upload jar artifacts
# Create the release https://github.com/marketplace/actions/gh-release?version=v0.1.5
release:
28 changes: 28 additions & 0 deletions .github/workflows/maven-verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Java CI

on: [push]

jobs:
verify:
runs-on: ubuntu-latest
concurrency: ci-${{ github.ref }}
strategy:
matrix:
java: ['8', '11', '13', '15']
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
- name: Cache maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Run the maven verify
run: mvn --batch-mode --update-snapshots clean verify
3 changes: 1 addition & 2 deletions .settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<gpg.executable>${env.GPG_EXECUTABLE}</gpg.executable>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
</properties>
</profile>
</profiles>
</settings>
</settings>

0 comments on commit e6c7353

Please sign in to comment.