Skip to content

Commit db504e5

Browse files
committed
revert to 650bbc0
1 parent 019a7f8 commit db504e5

35 files changed

+222
-287
lines changed
Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Snapshot Deploy (Central + GitHub)
1+
name: Publish SNAPSHOT
22

33
on:
44
push:
@@ -10,60 +10,54 @@ jobs:
1010
permissions:
1111
contents: read
1212
packages: write
13+
1314
steps:
1415
- uses: actions/checkout@v4
1516

16-
- name: Read version
17-
id: v
17+
- name: Extract version
18+
id: version
1819
run: |
19-
VER=$(grep -m1 '<version>' pom.xml | sed -E 's/.*<version>([^<]+)<\/version>.*/\1/')
20-
echo "version=$VER" >> $GITHUB_OUTPUT
21-
if [[ "$VER" == *-SNAPSHOT ]]; then echo "deploy=true" >> $GITHUB_OUTPUT; else echo "deploy=false" >> $GITHUB_OUTPUT; fi
22-
23-
- name: Abort (not SNAPSHOT)
24-
if: steps.v.outputs.deploy != 'true'
25-
run: echo "Version ${{ steps.v.outputs.version }} not snapshot."
26-
27-
- name: Setup Java
28-
if: steps.v.outputs.deploy == 'true'
20+
VERSION=$(grep -m1 '<version>' pom.xml | sed -E 's/.*<version>([^<]+)<\/version>.*/\1/')
21+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
22+
if [[ "$VERSION" == *-SNAPSHOT ]]; then
23+
echo "deploy=true" >> "$GITHUB_OUTPUT"
24+
else
25+
echo "deploy=false" >> "$GITHUB_OUTPUT"
26+
fi
27+
28+
- name: Abort (not a SNAPSHOT)
29+
if: steps.version.outputs.deploy != 'true'
30+
run: echo "Version ${{ steps.version.outputs.version }} is not a SNAPSHOT. Skipping deploy."
31+
32+
- name: Set up JDK 23 (generate settings.xml)
33+
if: steps.version.outputs.deploy == 'true'
2934
uses: actions/setup-java@v4
3035
with:
3136
distribution: temurin
3237
java-version: '23'
38+
server-id: github
39+
settings-path: ${{ github.workspace }}
3340

34-
- name: Write settings.xml
35-
if: steps.v.outputs.deploy == 'true'
36-
env:
37-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
38-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
39-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
run: |
41-
mkdir -p ~/.m2
42-
cat > ~/.m2/settings.xml <<'EOF'
43-
<settings>
44-
<servers>
45-
<server>
46-
<id>sonatype</id>
47-
<username>${env.SONATYPE_USERNAME}</username>
48-
<password>${env.SONATYPE_PASSWORD}</password>
49-
</server>
50-
<server>
51-
<id>github</id>
52-
<username>${env.GITHUB_ACTOR}</username>
53-
<password>${env.GITHUB_TOKEN}</password>
54-
</server>
55-
</servers>
56-
</settings>
57-
EOF
58-
sed 's/<password>.*<\/password>/<password>***<\/password>/' ~/.m2/settings.xml
41+
- name: Cache Maven
42+
if: steps.version.outputs.deploy == 'true'
43+
uses: actions/cache@v4
44+
with:
45+
path: ~/.m2/repository
46+
key: maven-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
47+
restore-keys: |
48+
maven-${{ runner.os }}-
5949
60-
- name: Deploy Snapshot to Sonatype
61-
if: steps.v.outputs.deploy == 'true'
62-
run: mvn -B -DskipTests deploy
50+
- name: Build (package)
51+
if: steps.version.outputs.deploy == 'true'
52+
run: mvn -B -s $GITHUB_WORKSPACE/settings.xml package
6353

64-
- name: Deploy Snapshot to GitHub Packages
65-
if: steps.v.outputs.deploy == 'true'
66-
run: mvn -B -DskipTests -Pgithub -Dgpg.skip=true deploy
54+
- name: Deploy SNAPSHOT
55+
if: steps.version.outputs.deploy == 'true'
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
run: mvn -B -s $GITHUB_WORKSPACE/settings.xml -DskipTests deploy
6759

6860
- name: Summary
69-
run: echo "Snapshot ${{ steps.v.outputs.version }} deployed."
61+
run: |
62+
echo "Version: ${{ steps.version.outputs.version }}"
63+
echo "Deployed: ${{ steps.version.outputs.deploy }}"

.github/workflows/release.yml

Lines changed: 28 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release Deploy (Central + GitHub)
1+
name: Release Publish
22

33
on:
44
push:
@@ -11,71 +11,51 @@ jobs:
1111
permissions:
1212
contents: write
1313
packages: write
14+
1415
steps:
1516
- uses: actions/checkout@v4
1617
with:
1718
fetch-depth: 0
1819

19-
- name: Derive version
20+
- name: Derive version from tag
2021
id: rel
2122
run: |
22-
TAG="${GITHUB_REF_NAME}"
23-
VERSION="${TAG#v}"
24-
echo "version=$VERSION" >> $GITHUB_OUTPUT
23+
TAG="${GITHUB_REF_NAME}" # e.g. v2.2.0
24+
VERSION="${TAG#v}" # strip leading v
25+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
2526
26-
- name: Setup Java
27+
- name: Set up JDK 23 (generate settings.xml)
2728
uses: actions/setup-java@v4
2829
with:
2930
distribution: temurin
3031
java-version: '23'
32+
server-id: github
33+
settings-path: ${{ github.workspace }}
3134

32-
- name: Import GPG Key
33-
env:
34-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
35-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
36-
run: |
37-
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
38-
gpg --list-secret-keys
39-
40-
- name: Write settings.xml
41-
env:
42-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
43-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
44-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45-
run: |
46-
mkdir -p ~/.m2
47-
cat > ~/.m2/settings.xml <<'EOF'
48-
<settings>
49-
<servers>
50-
<server>
51-
<id>sonatype</id>
52-
<username>${env.SONATYPE_USERNAME}</username>
53-
<password>${env.SONATYPE_PASSWORD}</password>
54-
</server>
55-
<server>
56-
<id>github</id>
57-
<username>${env.GITHUB_ACTOR}</username>
58-
<password>${env.GITHUB_TOKEN}</password>
59-
</server>
60-
</servers>
61-
</settings>
62-
EOF
63-
sed 's/<password>.*<\/password>/<password>***<\/password>/' ~/.m2/settings.xml
35+
- name: Cache Maven
36+
uses: actions/cache@v4
37+
with:
38+
path: ~/.m2/repository
39+
key: maven-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
40+
restore-keys: |
41+
maven-${{ runner.os }}-
6442
65-
- name: Set Release Version
43+
- name: Set release version (remove -SNAPSHOT)
6644
run: |
67-
mvn -B versions:set -DnewVersion="${{ steps.rel.outputs.version }}" -DgenerateBackupPoms=false
45+
mvn -B -s $GITHUB_WORKSPACE/settings.xml versions:set -DnewVersion="${{ steps.rel.outputs.version }}" -DgenerateBackupPoms=false
6846
grep -m1 '<version>' pom.xml
6947
70-
- name: Deploy Release to Central (staging + signing)
48+
- name: Deploy Release
7149
env:
72-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
73-
run: mvn -B -DskipTests -Prelease-publish -Dgpg.passphrase="${GPG_PASSPHRASE}" deploy
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
run: mvn -B -s $GITHUB_WORKSPACE/settings.xml -DskipTests deploy
7452

75-
- name: Deploy Release to GitHub Packages
76-
run: mvn -B -DskipTests -Pgithub -Dgpg.skip=true deploy
53+
- name: Collect artifacts
54+
run: |
55+
ls -1 target
56+
cp target/*.jar main-artifact.jar || true
7757
78-
- name: GitHub Release
58+
- name: Create GitHub Release
7959
uses: softprops/action-gh-release@v2
8060
with:
8161
tag_name: ${{ github.ref_name }}
@@ -84,7 +64,7 @@ jobs:
8464
files: |
8565
target/*-sources.jar
8666
target/*-javadoc.jar
87-
target/*.jar
67+
main-artifact.jar
8868
8969
- name: Summary
90-
run: echo "Released ${{ steps.rel.outputs.version }} to Central & GitHub."
70+
run: echo "Published release ${{ steps.rel.outputs.version }}"

0 commit comments

Comments
 (0)