Skip to content

Commit 6d71f6f

Browse files
author
Andrzej Swatowski
committed
Prepare rest of the GitHub workflows
1 parent 8e0d8ad commit 6d71f6f

File tree

4 files changed

+212
-2
lines changed

4 files changed

+212
-2
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: Build
33
on:
44
push:
55
branches:
6-
- main
7-
- develop
6+
- 'main'
7+
- 'release/**'
88
pull_request:
99

1010
env:
@@ -37,6 +37,7 @@ jobs:
3737
- name: Add coverage to PR
3838
id: jacoco
3939
uses: madrapps/jacoco-report@v1.2
40+
if: github.event_name == 'pull_request'
4041
with:
4142
paths: ${{ github.workspace }}/target/site/jacoco/jacoco.xml
4243
token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Prepare release branch
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_part:
7+
description: The part of the version to update (patch, minor or major)
8+
required: true
9+
options:
10+
- Patch
11+
- Minor
12+
- Major
13+
default: 'Minor'
14+
15+
jobs:
16+
prepare-branch:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: Set up JDK 11
22+
uses: actions/setup-java@v3
23+
with:
24+
java-version: '11'
25+
distribution: 'adopt'
26+
cache: maven
27+
28+
- name: Validate inputs
29+
run: |
30+
echo "INPUT_VERSION_PART: ${{ github.event.inputs.version_part }}"
31+
python -c "if '${{ github.event.inputs.version_part }}' not in ['Patch', 'Minor', 'Major']: raise ValueError(\"'${{ github.event.inputs.version_part }}' must be one of ['Patch', 'Minor', 'Major'])\")"
32+
33+
- name: Save current version
34+
id: save_current_version
35+
run: |
36+
mvn versions:set -DremoveSnapshot -DgenerateBackupPoms=false
37+
echo "::set-output name=current_version::$(mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout)"
38+
39+
- name: Update the CHANGELOG according to 'Keep a Changelog' guidelines
40+
uses: thomaseizinger/keep-a-changelog-new-release@v1
41+
with:
42+
version: ${{ steps.save_current_version.outputs.current_version }}
43+
44+
- name: Create a new release branch
45+
run: |
46+
git config user.name github-actions
47+
git config user.email github-actions@github.com
48+
git commit -am "Bump CHANGELOG for release ${{ steps.save_current_version.outputs.current_version }}"
49+
git checkout -b release/${{ steps.save_current_version.outputs.current_version }}
50+
git push -u origin release/${{ steps.save_current_version.outputs.current_version }}
51+
52+
- name: Bump development version
53+
run: |
54+
git checkout main
55+
mvn validate -D 'bump${{ github.event.inputs.version_part }}' -DgenerateBackupPoms=false
56+
git commit -m "Bump development version to $(mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout)"
57+
git push origin main

.github/workflows/publish.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
MAVEN_CLI_OPTS: "--batch-mode"
9+
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
10+
JAVA_ADDITIONAL_OPTS: "-Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS"
11+
FF_USE_FASTZIP: "true"
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Check release tag match # ... and fail fast if they do not
20+
run: diff <(echo "${{ github.ref_name }}") <(echo "$(mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout)")
21+
22+
- name: Set up JDK 11
23+
uses: actions/setup-java@v3
24+
with:
25+
java-version: '11'
26+
distribution: 'adopt'
27+
cache: maven
28+
29+
- name: Build
30+
run: mvn $MAVEN_CLI_OPTS $JAVA_ADDITIONAL_OPTS compile
31+
32+
- name: Tests
33+
run: |
34+
mvn $MAVEN_CLI_OPTS $JAVA_ADDITIONAL_OPTS test integration-test
35+
36+
- name: Set up Apache Maven Central
37+
uses: actions/setup-java@v3
38+
with:
39+
java-version: '11'
40+
distribution: 'adopt'
41+
server-id: ossrh
42+
server-username: SONATYPE_USERNAME
43+
server-password: SONATYPE_PASSWORD
44+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
45+
gpg-passphrase: GPG_PRIVATE_KEY_PASSWORD
46+
47+
- name: Publish to Apache Maven Central
48+
if: github.event.release
49+
run: mvn deploy -P release
50+
env:
51+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
52+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
53+
GPG_PRIVATE_KEY_PASSWORD: ${{ secrets.GPG_PRIVATE_KEY_PASSWORD }}

pom.xml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,20 @@ under the License.
365365
</execution>
366366
</executions>
367367
</plugin>
368+
369+
<plugin>
370+
<groupId>org.codehaus.mojo</groupId>
371+
<artifactId>build-helper-maven-plugin</artifactId>
372+
<version>3.3.0</version>
373+
<executions>
374+
<execution>
375+
<id>parse-version</id>
376+
<goals>
377+
<goal>parse-version</goal>
378+
</goals>
379+
</execution>
380+
</executions>
381+
</plugin>
368382
</plugins>
369383

370384
<pluginManagement>
@@ -472,5 +486,90 @@ under the License.
472486
</plugins>
473487
</build>
474488
</profile>
489+
490+
<profile>
491+
<id>bump-patch</id>
492+
<activation>
493+
<property>
494+
<name>bumpPatch</name>
495+
</property>
496+
</activation>
497+
<build>
498+
<plugins>
499+
<plugin>
500+
<groupId>org.codehaus.mojo</groupId>
501+
<artifactId>versions-maven-plugin</artifactId>
502+
503+
<executions>
504+
<execution>
505+
<goals>
506+
<goal>set</goal>
507+
</goals>
508+
<phase>validate</phase>
509+
<configuration>
510+
<newVersion>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextIncrementalVersion}-SNAPSHOT</newVersion>
511+
</configuration>
512+
</execution>
513+
</executions>
514+
</plugin>
515+
</plugins>
516+
</build>
517+
</profile>
518+
<profile>
519+
<id>bump-minor</id>
520+
<activation>
521+
<property>
522+
<name>bumpMinor</name>
523+
</property>
524+
</activation>
525+
<build>
526+
<plugins>
527+
<plugin>
528+
<groupId>org.codehaus.mojo</groupId>
529+
<artifactId>versions-maven-plugin</artifactId>
530+
531+
<executions>
532+
<execution>
533+
<goals>
534+
<goal>set</goal>
535+
</goals>
536+
<phase>validate</phase>
537+
<configuration>
538+
<newVersion>${parsedVersion.majorVersion}.${parsedVersion.nextMinorVersion}.0-SNAPSHOT</newVersion>
539+
</configuration>
540+
</execution>
541+
</executions>
542+
</plugin>
543+
</plugins>
544+
</build>
545+
</profile>
546+
<profile>
547+
<id>bump-major</id>
548+
<activation>
549+
<property>
550+
<name>bumpMajor</name>
551+
</property>
552+
</activation>
553+
<build>
554+
<plugins>
555+
<plugin>
556+
<groupId>org.codehaus.mojo</groupId>
557+
<artifactId>versions-maven-plugin</artifactId>
558+
559+
<executions>
560+
<execution>
561+
<goals>
562+
<goal>set</goal>
563+
</goals>
564+
<phase>validate</phase>
565+
<configuration>
566+
<newVersion>${parsedVersion.nextMajorVersion}.0.0-SNAPSHOT</newVersion>
567+
</configuration>
568+
</execution>
569+
</executions>
570+
</plugin>
571+
</plugins>
572+
</build>
573+
</profile>
475574
</profiles>
476575
</project>

0 commit comments

Comments
 (0)