-
Notifications
You must be signed in to change notification settings - Fork 31
78 lines (67 loc) · 2.3 KB
/
publish-maven.yml
File metadata and controls
78 lines (67 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Publish Maven Packages
on:
push:
tags:
- 'v*.*.*'
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Validate version consistency
run: |
# Extract version from pom.xml
POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
# Remove 'v' prefix from tag and compare
TAG_VERSION=${GITHUB_REF#refs/tags/v}
echo "POM version: $POM_VERSION"
echo "Tag version: $TAG_VERSION"
if [ "$POM_VERSION" != "$TAG_VERSION" ]; then
echo "Error: Version in pom.xml ($POM_VERSION) does not match tag version ($TAG_VERSION)"
exit 1
fi
- name: Check if prerelease
id: prerelease_check
run: |
# Check if the tag contains prerelease indicators
if [[ "${{ github.ref_name }}" =~ -(alpha|beta|rc|snapshot|preview|pre|dev|experimental) ]]; then
echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT
else
echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT
fi
- name: Build with Maven
run: mvn clean package -DskipTests
- name: Publish to Maven Central
run: mvn deploy -P release
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Create Release and Upload JARs
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
generate_release_notes: true
draft: false
prerelease: ${{ steps.prerelease_check.outputs.IS_PRERELEASE }}
files: |
target/cv4pve-api-java-[0-9]*.jar
target/cv4pve-api-java-[0-9]*-sources.jar
target/cv4pve-api-java-[0-9]*-javadoc.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}