Skip to content

Commit dbcb9d7

Browse files
build: update central-publishing-maven-plugin to version 0.9.0 and add autoPublish configuration; add release workflow for GitHub Actions
1 parent e010be6 commit dbcb9d7

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

.github/workflows/release.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
concurrency:
13+
group: release-${{ github.ref }}
14+
cancel-in-progress: false
15+
16+
jobs:
17+
publish:
18+
runs-on: ubuntu-latest
19+
environment: release
20+
if: >
21+
github.repository == 'ChildrenGreens/multi-source-spring-boot-starter' &&
22+
startsWith(github.ref, 'refs/tags/v')
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Set release version
31+
id: version
32+
shell: bash
33+
run: |
34+
set -euo pipefail
35+
TAG="${GITHUB_REF_NAME}"
36+
VERSION="${TAG#v}"
37+
if [[ "${VERSION}" == *SNAPSHOT* ]]; then
38+
echo "Refusing to publish SNAPSHOT version from tag: ${TAG}" >&2
39+
exit 1
40+
fi
41+
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
42+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
43+
44+
- name: Set up JDK 17 + Maven settings
45+
uses: actions/setup-java@v4
46+
with:
47+
distribution: temurin
48+
java-version: "17"
49+
cache: maven
50+
server-id: ossrh
51+
server-username: MAVEN_USERNAME
52+
server-password: MAVEN_PASSWORD
53+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
54+
gpg-passphrase: GPG_PASSPHRASE
55+
env:
56+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
57+
58+
- name: Publish to Maven Central
59+
env:
60+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
61+
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
62+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
63+
run: >
64+
mvn -B -ntp
65+
-Drevision=${{ steps.version.outputs.version }}
66+
-Prelease
67+
clean deploy
68+
69+
- name: Create GitHub Release
70+
env:
71+
GH_TOKEN: ${{ github.token }}
72+
shell: bash
73+
run: |
74+
set -euo pipefail
75+
TAG="${{ steps.version.outputs.tag }}"
76+
if gh release view "${TAG}" >/dev/null 2>&1; then
77+
echo "GitHub Release already exists for ${TAG}, skipping."
78+
exit 0
79+
fi
80+
gh release create "${TAG}" --title "${TAG}" --generate-notes

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,11 @@
241241
<plugin>
242242
<groupId>org.sonatype.central</groupId>
243243
<artifactId>central-publishing-maven-plugin</artifactId>
244-
<version>0.6.0</version>
244+
<version>0.9.0</version>
245245
<extensions>true</extensions>
246246
<configuration>
247247
<publishingServerId>ossrh</publishingServerId>
248+
<autoPublish>true</autoPublish>
248249
</configuration>
249250
</plugin>
250251
<plugin>

0 commit comments

Comments
 (0)