Skip to content

Commit c2cbbb5

Browse files
authored
build with github actions
1 parent d9bdd92 commit c2cbbb5

File tree

2 files changed

+98
-21
lines changed

2 files changed

+98
-21
lines changed

.github/workflows/bump-version.yml

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

.github/workflows/pipeline.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: PIPELINE
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
workflow_dispatch:
8+
9+
jobs:
10+
bump:
11+
name: Get And Bump SemVer 👊
12+
runs-on: ubuntu-latest
13+
outputs:
14+
pom_version: ${{ steps.set_version.outputs.pom_version }}
15+
major_version: ${{ steps.set_version.outputs.major_version }}
16+
minor_version: ${{ steps.set_version.outputs.minor_version }}
17+
build_version: ${{ steps.set_version.outputs.build_version }}
18+
steps:
19+
- name: Checkout repo 📦
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: '0'
23+
- name: Bump version and push tag 👊
24+
uses: anothrNick/github-tag-action@master
25+
id: bump_version
26+
env:
27+
GITHUB_TOKEN: ${{ github.TOKEN }}
28+
RELEASE_BRANCHES: master
29+
DEFAULT_BUMP: patch
30+
WITH_V: false
31+
- name: Extract version from tag 🔍
32+
id: set_version
33+
env:
34+
POM_VERSION: ${{ steps.bump_version.outputs.new_tag }}
35+
run: |
36+
MAJOR_VERSION=$(echo $POM_VERSION | cut -d. -f1)
37+
MINOR_VERSION=$(echo $POM_VERSION | cut -d. -f2)
38+
BUILD_VERSION=$(echo $POM_VERSION | cut -d. -f3)
39+
echo POM:$POM_VERSION, MAJOR:$MAJOR_VERSION, MINOR:$MINOR_VERSION, BUILD:$BUILD_VERSION
40+
echo --- set output for step ---
41+
echo "pom_version=${POM_VERSION}" >> $GITHUB_ENV
42+
echo "major_version=${MAJOR_VERSION}" >> $GITHUB_ENV
43+
echo "minor_version=${MINOR_VERSION}" >> $GITHUB_ENV
44+
echo "build_version=${BUILD_VERSION}" >> $GITHUB_ENV
45+
echo --- set output for job ---
46+
echo "pom_version=${POM_VERSION}" >> $GITHUB_OUTPUT
47+
echo "major_version=${MAJOR_VERSION}" >> $GITHUB_OUTPUT
48+
echo "minor_version=${MINOR_VERSION}" >> $GITHUB_OUTPUT
49+
echo "build_version=${BUILD_VERSION}" >> $GITHUB_OUTPUT
50+
build:
51+
name: Build 🔨
52+
runs-on: ubuntu-latest
53+
outputs:
54+
pom_version: ${{ needs.bump.outputs.pom_version }}
55+
major_version: ${{ needs.bump.outputs.major_version }}
56+
minor_version: ${{ needs.bump.outputs.minor_version }}
57+
build_version: ${{ needs.bump.outputs.build_version }}
58+
needs: [bump]
59+
steps:
60+
- name: Checkout repo 📦
61+
uses: actions/checkout@v4
62+
- name: Cache Maven packages 💾
63+
uses: actions/cache@v3
64+
with:
65+
path: ~/.m2/repository
66+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
67+
restore-keys: ${{ runner.os }}-maven-
68+
- name: Set up JDK 21 ⚙️
69+
uses: actions/setup-java@v4
70+
with:
71+
java-version: '21'
72+
distribution: 'temurin'
73+
server-id: maven
74+
server-username: ${{ secrets.SONATYPE_USERNAME }}
75+
server-password: ${{ secrets.SONATYPE_PASSWORD }}
76+
gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
77+
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
78+
- name: Update pom.xml version 💾
79+
run: |
80+
mvn versions:set -DnewVersion=${{ needs.bump.outputs.major_version }}.${{ needs.bump.outputs.minor_version }}.${{ needs.bump.outputs.build_version }} -DgenerateBackupPoms=false
81+
- name: Import GPG key and set trust
82+
run: |
83+
echo "${{ secrets.GPG_SECRET_KEY }}" | base64 --decode | gpg --batch --import
84+
echo "${{ secrets.GPG_OWNERTRUST }}" | gpg --import-ownertrust
85+
- name: Build and verify with Maven 🔨
86+
run: mvn --batch-mode --update-snapshots verify
87+
- name: Publish to Maven Central
88+
run: mvn deploy
89+
env:
90+
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
91+
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }}
92+
MAVEN_GPG_PRIVATE_KEY: ${{ secrets.GPG_SECRET_KEY }}
93+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
94+
- name: Upload build artifacts ⬆️
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: maven-artifacts
98+
path: target/*.jar

0 commit comments

Comments
 (0)