Skip to content

Commit 6e5ab7f

Browse files
committed
Multiple updates on Actions and code
1 parent 2a42584 commit 6e5ab7f

File tree

20 files changed

+1378
-702
lines changed

20 files changed

+1378
-702
lines changed

.github/workflows/build.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
branches:
9+
- 'main'
10+
- 'hotfix/v*.*.*'
11+
schedule:
12+
- cron: '0 5 * * 1'
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
java: [ '17', '21' ]
20+
steps:
21+
- name: Checkout project
22+
uses: actions/checkout@v5
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set up JDK ${{ matrix.java }}
27+
uses: actions/setup-java@v4
28+
with:
29+
java-version: ${{ matrix.java }}
30+
distribution: 'temurin'
31+
cache: maven
32+
server-id: central
33+
server-username: SONATYPE_USERNAME
34+
server-password: SONATYPE_TOKEN
35+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
36+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
37+
38+
- name: Cache SonarQube packages
39+
uses: actions/cache@v4
40+
with:
41+
path: ~/.sonar/cache
42+
key: ${{ runner.os }}-sonar
43+
restore-keys: ${{ runner.os }}-sonar
44+
45+
- name: Cache Maven packages
46+
uses: actions/cache@v4
47+
with:
48+
path: ~/.m2
49+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
50+
restore-keys: ${{ runner.os }}-m2
51+
52+
- name: Lint
53+
run: mvn spotless:check
54+
55+
- name: Build
56+
run: mvn clean package
57+
58+
- name: Publish test report
59+
if: always()
60+
uses: mikepenz/action-junit-report@v5
61+
with:
62+
report_paths: '**/target/surefire-reports/TEST-*.xml'
63+
64+
- name: Grype source code
65+
if: matrix.java == '17'
66+
id: grype_source_code
67+
uses: anchore/scan-action@v6
68+
with:
69+
path: .
70+
fail-build: true
71+
severity-cutoff: high
72+
only-fixed: true
73+
74+
- name: Upload Grype source code report
75+
if: always() && steps.grype_source_code.outputs.sarif != ''
76+
uses: github/codeql-action/upload-sarif@v3
77+
with:
78+
sarif_file: ${{ steps.grype_source_code.outputs.sarif }}
79+
category: 'source-code'
80+
81+
- name: Sonar
82+
if: matrix.java == '17' && github.event.pull_request.head.repo.fork == false
83+
run: mvn verify sonar:sonar
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
87+
88+
- name: Metadata
89+
if: matrix.java == '17' && github.ref == 'refs/heads/main'
90+
id: metadata
91+
run: echo current_version=$(echo $(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)) >> $GITHUB_OUTPUT
92+
93+
- name: Deploy
94+
if: matrix.java == '17' && github.ref == 'refs/heads/main' && endsWith(steps.metadata.outputs.current_version, '-SNAPSHOT')
95+
run: mvn -B deploy -DskipTests -Psign
96+
env:
97+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
98+
SONATYPE_TOKEN: ${{ secrets.SONATYPE_TOKEN }}
99+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

.github/workflows/hotfix.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Hotfix
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag_version:
7+
description: 'Tag version'
8+
required: true
9+
10+
jobs:
11+
create-branch:
12+
name: Create Branch
13+
runs-on: ubuntu-latest
14+
if: github.ref == 'refs/heads/main'
15+
steps:
16+
- name: Checkout project
17+
uses: actions/checkout@v5
18+
with:
19+
fetch-depth: 0
20+
token: ${{ secrets.CI_CD_TOKEN }}
21+
22+
- name: Create branch
23+
run: |
24+
START_TAG=v${{ github.event.inputs.tag_version }}
25+
echo "Start from tag $START_TAG"
26+
MAJOR_MINOR_DIGIT=$(echo "$START_TAG" | cut -d '.' -f 1-2)
27+
PATCH_DIGIT=$(echo "$START_TAG" | cut -d '.' -f 3)
28+
NEW_PATCH_DIGIT=$((PATCH_DIGIT + 1))
29+
HOTFIX_VERSION="${MAJOR_MINOR_DIGIT}.${NEW_PATCH_DIGIT}"
30+
HOTFIX_BRANCH_NAME="hotfix/$HOTFIX_VERSION"
31+
echo "Create hotfix branch $HOTFIX_BRANCH_NAME"
32+
git fetch --all
33+
git checkout tags/$START_TAG -b $HOTFIX_BRANCH_NAME
34+
git push origin $HOTFIX_BRANCH_NAME

.github/workflows/on_pull_request.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/on_push_main.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,44 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout project
13-
uses: actions/checkout@v4
13+
uses: actions/checkout@v5
1414

1515
- name: Set up JDK 17
16-
uses: actions/setup-java@v3
16+
uses: actions/setup-java@v4
1717
with:
1818
java-version: '17'
1919
distribution: 'temurin'
2020
cache: maven
21-
server-id: ossrh
22-
server-username: MAVEN_USERNAME
23-
server-password: MAVEN_PASSWORD
21+
server-id: central
22+
server-username: SONATYPE_USERNAME
23+
server-password: SONATYPE_TOKEN
2424
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
2525
gpg-passphrase: MAVEN_GPG_PASSPHRASE
2626

27+
- name: Cache Maven packages
28+
uses: actions/cache@v4
29+
with:
30+
path: ~/.m2
31+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
32+
restore-keys: ${{ runner.os }}-m2
33+
2734
- name: Deploy
2835
run: mvn -B clean deploy -DskipTests -Psign
2936
env:
30-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
31-
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
37+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
38+
SONATYPE_TOKEN: ${{ secrets.SONATYPE_TOKEN }}
3239
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
3340

3441
- name: Generate release changelog
35-
uses: mikepenz/release-changelog-builder-action@v4.0.0
42+
uses: mikepenz/release-changelog-builder-action@v5
3643
id: build_changelog
3744
with:
3845
configuration: 'changelog-builder.json'
3946
env:
4047
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4148

4249
- name: Create release
43-
uses: ncipollo/release-action@v1.14.0
50+
uses: ncipollo/release-action@v1.18.0
4451
with:
4552
token: ${{ secrets.GITHUB_TOKEN }}
4653
body: ${{ steps.build_changelog.outputs.changelog }}

.github/workflows/tag.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ on:
99

1010
jobs:
1111
tag:
12+
name: Tag
1213
runs-on: ubuntu-latest
13-
if: github.ref == 'refs/heads/main'
14+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/hotfix/v')
1415
steps:
1516
- name: Checkout project
16-
uses: actions/checkout@v4
17+
uses: actions/checkout@v5
1718
with:
1819
token: ${{ secrets.CI_CD_TOKEN }}
1920

2021
- name: Set up JDK 17
21-
uses: actions/setup-java@v3
22+
uses: actions/setup-java@v4
2223
with:
2324
java-version: '17'
2425
distribution: 'temurin'
@@ -32,6 +33,16 @@ jobs:
3233
git_user_signingkey: true
3334
git_commit_gpgsign: true
3435

36+
- name: Validate release version format
37+
run: |
38+
if [[ ! "${{ github.event.inputs.release_version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
39+
echo "Release version must follow SemVer format (X.Y.Z) and start with a digit"
40+
echo "Current value: ${{ github.event.inputs.release_version }}"
41+
echo "Expected format: 1.2.3, 2.0.0, etc."
42+
echo "Note: The 'v' prefix will be added automatically to the tag. Do not include it manually"
43+
exit 1
44+
fi
45+
3546
- name: Tag
3647
run: |
3748
mvn versions:set -DnewVersion=${{ github.event.inputs.release_version }}

.spotless/HEADER

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/

0 commit comments

Comments
 (0)