Skip to content

Commit eb69a1d

Browse files
committed
Github workflows
1 parent 8ca4517 commit eb69a1d

File tree

4 files changed

+190
-0
lines changed

4 files changed

+190
-0
lines changed

.github/settings.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
5+
https://maven.apache.org/xsd/settings-1.0.0.xsd">
6+
<servers>
7+
<server>
8+
<id>github</id>
9+
<username>${env.MAVEN_USERNAME}</username>
10+
<password>${env.MAVEN_PASSWORD}</password>
11+
</server>
12+
<server>
13+
<id>central</id>
14+
<username>${{env.OSSRH_USERNAME_TOKEN }}</username>
15+
<password>${{env.OSSRH_PASSWORD_TOKEN }}</password>
16+
</server>
17+
</servers>
18+
19+
</settings>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
branches:
8+
- 'feature/release-*'
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up JDK 17
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '17'
23+
distribution: 'temurin'
24+
cache: maven
25+
26+
- name: Setup GPG
27+
env:
28+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
29+
GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }}
30+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
31+
run: |
32+
echo "Setting up GPG..."
33+
mkdir -p ~/.gnupg
34+
chmod 700 ~/.gnupg
35+
36+
# Debug: Sprawdź długość klucza
37+
echo "GPG_PRIVATE_KEY length: ${#GPG_PRIVATE_KEY}"
38+
39+
# Debug: Sprawdź początek klucza (bez ujawniania tajemnicy)
40+
echo "GPG_KEYNAME: $GPG_KEYNAME"
41+
echo "GPG_PASSPHRASE length: ${#GPG_PASSPHRASE}"
42+
echo "First 10 chars of GPG_PRIVATE_KEY: ${GPG_PRIVATE_KEY:0:10}"
43+
44+
# Tepporary write key for debug
45+
echo "$GPG_PRIVATE_KEY" > private.tmp
46+
echo "File content (first line): $(head -1 private.tmp)"
47+
48+
# Import key
49+
echo "Importing GPG key..."
50+
gpg --batch --import private.tmp || echo "Import failed!"
51+
rm private.tmp
52+
53+
- name: Configure Maven
54+
run: |
55+
mkdir -p ~/.m2
56+
cat > ~/.m2/settings.xml << EOF
57+
<settings>
58+
<servers>
59+
<server>
60+
<id>central</id>
61+
<username>${{ secrets.OSSRH_USERNAME_TOKEN }}</username>
62+
<password>${{ secrets.OSSRH_PASSWORD_TOKEN }}</password>
63+
</server>
64+
</servers>
65+
<profiles>
66+
<profile>
67+
<id>central</id>
68+
<activation>
69+
<activeByDefault>true</activeByDefault>
70+
</activation>
71+
<properties>
72+
<gpg.executable>gpg</gpg.executable>
73+
<gpg.passphrase>${{ secrets.GPG_PASSPHRASE }}</gpg.passphrase>
74+
</properties>
75+
</profile>
76+
</profiles>
77+
</settings>
78+
EOF
79+
80+
- name: Build and Publish
81+
env:
82+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME_TOKEN }}
83+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD_TOKEN }}
84+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
85+
GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }}
86+
run: |
87+
echo "Starting Maven build and deploy..."
88+
mvn clean deploy -P release \
89+
-Dmaven.javadoc.skip=false \
90+
-Dmaven.deploy.skip=false \
91+
-Dgpg.keyname=$GPG_KEYNAME \
92+
-Dgpg.useagent=false \
93+
-Dgpg.passphrase=$GPG_PASSPHRASE \
94+
-Dmaven.test.failure.ignore=false \
95+
-DaltDeploymentRepository=ossrh::default::https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ \
96+
-DrepositoryId=ossrh \
97+
-Dusername=$OSSRH_USERNAME \
98+
-Dpassword=$OSSRH_PASSWORD

.github/workflows/maven.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build and Publish
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags:
7+
- 'v*'
8+
pull_request:
9+
branches: [ main ]
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
packages: write
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Set up JDK 17
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '17'
23+
distribution: 'temurin'
24+
cache: 'maven'
25+
- name: Build
26+
run: mvn clean install -Dmaven.javadoc.skip=true
27+
- name: Create Release
28+
if: startsWith(github.ref, 'refs/tags/')
29+
uses: softprops/action-gh-release@v1
30+
with:
31+
files: |
32+
target/*.jar
33+
target/*.pom
34+
target/*.asc
35+
target/*.md5
36+
target/*.sha1
37+
generate_release_notes: true
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up JDK 17
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: '17'
22+
distribution: 'temurin'
23+
cache: 'maven'
24+
25+
- name: Build with Maven
26+
run: |
27+
mvn -B clean package -DskipTests
28+
mvn -B javadoc:javadoc
29+
mvn -B source:jar
30+
31+
- name: Create Release
32+
uses: softprops/action-gh-release@v1
33+
with:
34+
name:

0 commit comments

Comments
 (0)