Skip to content

Commit

Permalink
chore(gha): use gitflow maven plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
rbioteau committed Jun 25, 2024
1 parent afd467c commit db67af6
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 171 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: workflow-build

on:
push:
branches: [ dev ]
workflow_call:
inputs:
ossrh-publication:
type: boolean
default: false

jobs:

Expand Down Expand Up @@ -49,6 +52,7 @@ jobs:

# Build and Push snapshots to maven central
- name: Deploy snapshots to Maven central
if: ${{ inputs.ossrh-publication }}
run: ./mvnw -B -ntp deploy -DskipTests=true -Pdeploy

test-supported-versions:
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Continuous Integration

on:
push:
branches:
- develop
- release/*
- support/*
paths-ignore:
- "README.adoc"
- "CHANGELOG.adoc"
- ".github/**"
- "!.github/workflows/build.yml"
- "!.github/workflows/_reusable_build.yml"

jobs:
build:
uses: ./.github/workflows/_reusable_build.yml
with:
ossrh-publication: true
secrets: inherit
21 changes: 21 additions & 0 deletions .github/workflows/build_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build Pull Request

on:
pull_request:
branches:
- develop
- release/*
- support/*
paths-ignore:
- "README.adoc"
- "CHANGELOG.adoc"
- ".github/**"
- "!.github/workflows/build_pr.yml"
- "!.github/workflows/_reusable_build.yml"

jobs:
build:
uses: ./.github/workflows/_reusable_build.yml
with:
ossrh-publication: false
secrets: inherit
43 changes: 43 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish

on:
workflow_dispatch:
inputs:
tag:
description: "Tag to publish"
type: string
required: true
default: "x.y.z"

jobs:
build:
name: Publication pipeline
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag }}

- uses: Keeper-Security/ksm-action@v1
with:
keeper-secret-config: ${{ secrets.KSM_CONFIG }}
secrets: |
${{ vars.KEEPER_OSSRH_RECORD_ID }}/field/login > env:MAVEN_USERNAME
${{ vars.KEEPER_OSSRH_RECORD_ID }}/field/password > env:MAVEN_PASSWORD
${{ vars.KEEPER_GPG_ARTIFACT_SIGNING_RECORD_ID }}/custom_field/gpg-private-key > env:GPG_PRIVATE_KEY
${{ vars.KEEPER_GPG_ARTIFACT_SIGNING_RECORD_ID }}/field/password > env:MAVEN_GPG_PASSPHRASE
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_PASSWORD
gpg-passphrase: MAVEN_GPG_PASSPHRASE
gpg-private-key: ${{ env.GPG_PRIVATE_KEY }} # Value of the GPG private key to import

- name: Publish tag
run: ./mvnw -ntp --batch-mode deploy -Pdeploy
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: Version to release (leave empty to use pom version)
type: string
default: ""
required: false
nextVersion:
description: "Next development version (leave empty to use default version incrementation policy)"
type: string
required: false
default: ""
skipMergeReleaseInMaster:
description: "Skip merge into master (major/minor version only should be merged)"
type: boolean
required: false
default: false

jobs:
build:
name: Release pipeline
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: "0"

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17

- uses: bonitasoft/git-setup-action@v1
with:
keeper-secret-config: ${{ secrets.KSM_CONFIG }}

- name: Create Release
run: ./mvnw -ntp --batch-mode -Dstyle.color=always gitflow:release -DgitFlowConfig.developmentBranch=${{ github.ref_name }} -DdevelopmentVersion=${{ github.event.inputs.nextVersion }} -DreleaseVersion=${{ github.event.inputs.version }} -DskipReleaseMergeProdBranch=${{ github.event.inputs.skipMergeReleaseInMaster }} -Dverbose
78 changes: 0 additions & 78 deletions .github/workflows/workflow-PR.yml

This file was deleted.

91 changes: 0 additions & 91 deletions .github/workflows/workflow-release.yml

This file was deleted.

12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
<sonar-maven-plugin.version>4.0.0.4121</sonar-maven-plugin.version>
<nexus-staging-maven-plugin.version>1.7.0</nexus-staging-maven-plugin.version>
<gitflow-maven-plugin.version>1.21.0</gitflow-maven-plugin.version>
<maven-javadoc-plugin.version>3.7.0</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
<maven-gpg-plugin.version>3.2.4</maven-gpg-plugin.version>
Expand Down Expand Up @@ -395,6 +396,17 @@
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>com.amashchenko.maven.plugin</groupId>
<artifactId>gitflow-maven-plugin</artifactId>
<version>${gitflow-maven-plugin.version}</version>
<configuration>
<versionsMavenPluginVersion>${versions-maven-plugin.version}</versionsMavenPluginVersion>
<!-- 0: increment major digit on develop, 1: increment minor digit on develop, 2: increment patch digit on develop -->
<versionDigitToIncrement>1</versionDigitToIncrement>
<commitMessagePrefix xml:space="preserve">chore(release): </commitMessagePrefix>
</configuration>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
Expand Down

0 comments on commit db67af6

Please sign in to comment.