Skip to content

Commit 1a1437e

Browse files
authored
update
1 parent 8fcfde5 commit 1a1437e

File tree

1 file changed

+15
-91
lines changed

1 file changed

+15
-91
lines changed

.github/workflows/pipeline.yml

+15-91
Original file line numberDiff line numberDiff line change
@@ -10,94 +10,18 @@ jobs:
1010
bump:
1111
uses: UnterrainerInformatik/bump-semver-workflow/.github/workflows/workflow.yml@master
1212
build:
13-
name: Build and publish to Maven Central 🔨
14-
runs-on: [self-hosted, Linux, X64]
15-
env:
16-
MAVEN_PROFILES: release-to-sonatype
17-
MAVEN_ARGS: -Dmaven.test.skip=true
18-
needs: [bump]
19-
steps:
20-
- name: Pre-fetch upload-artifact action (self-hosted only) ⚙️
21-
if: contains(runner.labels, 'self-hosted')
22-
run: |
23-
mkdir -p ~/.setup-actions
24-
cd ~/.setup-actions
25-
if [ ! -d "upload-artifact" ]; then
26-
echo "Cloning upload-artifact@v4..."
27-
git clone --depth=1 --branch v4 https://github.com/actions/upload-artifact.git upload-artifact
28-
echo "✅ upload-artifact@v4 cloned manually!"
29-
else
30-
echo "✅ upload-artifact already fetched."
31-
fi
32-
- name: Checkout repo 📦
33-
uses: actions/checkout@v4
34-
- name: Cache Maven packages 💾
35-
uses: actions/cache@v3
36-
with:
37-
path: ~/.m2/repository
38-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
39-
restore-keys: ${{ runner.os }}-maven-
40-
- name: Set up JDK 21 ⚙️
41-
uses: actions/setup-java@v4
42-
with:
43-
java-version: '21'
44-
distribution: 'temurin'
45-
server-id: maven
46-
server-username: ${{ secrets.SONATYPE_USERNAME }}
47-
server-password: ${{ secrets.SONATYPE_PASSWORD }}
48-
- name: Set up GPG for CI 🔐
49-
run: |
50-
which gpg2 || sudo apt update && sudo apt install -y gnupg2
51-
mkdir -p ~/.gnupg
52-
chmod 700 ~/.gnupg
53-
echo "use-agent" >> ~/.gnupg/gpg.conf
54-
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
55-
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
56-
echo "default-cache-ttl 600" >> ~/.gnupg/gpg-agent.conf
57-
echo "max-cache-ttl 7200" >> ~/.gnupg/gpg-agent.conf
58-
gpgconf --kill gpg-agent
59-
gpgconf --launch gpg-agent
60-
echo "${{ secrets.GPG_SECRET_KEY }}" | base64 --decode | gpg2 --batch --yes --import
61-
echo "${{ secrets.GPG_OWNERTRUST }}" | base64 --decode | gpg2 --import-ownertrust
62-
export GPG_TTY=$(tty)
63-
- name: Write .m2/settings.xml 💾
64-
run: |
65-
mkdir -p ~/.m2
66-
cat <<EOF > ~/.m2/settings.xml
67-
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
68-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
69-
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
70-
<servers>
71-
<server>
72-
<id>maven</id>
73-
<username>${{ secrets.SONATYPE_USERNAME }}</username>
74-
<password>${{ secrets.SONATYPE_PASSWORD }}</password>
75-
</server>
76-
</servers>
77-
</settings>
78-
EOF
79-
- name: Conditionally setup Maven ⚙️
80-
run: |
81-
wihch mvn || (sudo apt update && sudo apt install -y maven)
82-
- name: Update pom.xml version 💾
83-
run: |
84-
mvn versions:set -DnewVersion=${{ needs.bump.outputs.major_version }}.${{ needs.bump.outputs.minor_version }}.${{ needs.bump.outputs.build_version }} -DgenerateBackupPoms=false
85-
- name: Build and publish with Maven 🔨
86-
env:
87-
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
88-
run: mvn clean deploy --batch-mode --update-snapshots -P${{ env.MAVEN_PROFILES }} $MAVEN_ARGS
89-
- name: List signed files 🐞
90-
run: |
91-
echo "📦 Contents of target/:"
92-
ls -lh target/
93-
echo ""
94-
echo "🔍 GPG signatures:"
95-
find target/ -type f -name "*.asc" -exec echo "✔ Found:" {} \;
96-
echo ""
97-
echo "❓ Missing POM signature?" && test ! -f target/*pom.asc && echo "❌ No POM signature found!" || echo "✅ POM is signed."
98-
- name: Upload build artifacts ⬆️
99-
if: ${{ always() && hashFiles('target/*.jar') != '' }}
100-
uses: actions/upload-artifact@v4
101-
with:
102-
name: maven-artifacts
103-
path: target/*.jar
13+
name: Build and publish to Maven Central 🚀
14+
needs: bump
15+
uses: UnterrainerInformatik/maven-central-workflow/.github/workflows/workflow.yml@master
16+
with:
17+
major_version: ${{ needs.bump.outputs.major_version }}
18+
minor_version: ${{ needs.bump.outputs.minor_version }}
19+
build_version: ${{ needs.bump.outputs.build_version }}
20+
maven_profiles: release-to-sonatype
21+
maven_args: -Dmaven.test.skip=true
22+
secrets:
23+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
24+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
25+
GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
26+
GPG_OWNERTRUST: ${{ secrets.GPG_OWNERTRUST }}
27+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

0 commit comments

Comments
 (0)