Skip to content

Commit 948d7f0

Browse files
committed
better versioning
1 parent b4f0061 commit 948d7f0

File tree

3 files changed

+24
-33
lines changed

3 files changed

+24
-33
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,12 @@ jobs:
2626
java-version: 11
2727
distribution: "temurin"
2828
cache: maven
29-
server-id: ossrh
30-
server-username: OSSRH_USERNAME
31-
server-password: OSSRH_PASSWORD
32-
settings-path: ${{ github.workspace }}/.mvn/settings.xml
3329

3430
- name: Install GPG key
3531
run: |
3632
echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 --decode | gpg --batch --import
3733
gpg --list-secret-keys --keyid-format LONG
3834
39-
# Determine if this is a tag push (release) or branch push (snapshot)
4035
- name: Set release type
4136
id: release_type
4237
run: |
@@ -49,34 +44,23 @@ jobs:
4944
echo "This is a snapshot build from branch ${GITHUB_REF#refs/heads/}"
5045
fi
5146
52-
# Build and test
53-
- name: Build and test
47+
- name: Build code
5448
run: mvn clean verify -DskipTests
5549

56-
# For releases
57-
- name: Deploy release to Maven Central
58-
if: env.IS_RELEASE == 'true'
50+
- name: Deploy to Maven Central
5951
run: |
60-
mvn deploy -P sonatype -DskipTests \
61-
-s ${{ github.workspace }}/.github/settings.xml
62-
env:
63-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
64-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
65-
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
66-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
67-
VERSIONING_GIT_REF: ${{ github.ref }}
68-
VERSIONING_EXTENSION_LOG: true
69-
70-
# For snapshots
71-
- name: Deploy snapshot to Maven Central
72-
if: env.IS_RELEASE == 'false'
73-
run: |
74-
mvn deploy -DskipTests \
75-
-s ${{ github.workspace }}/.github/settings.xml
52+
if [[ $IS_RELEASE == true ]]; then
53+
echo "Deploying release to Maven Central"
54+
mvn deploy -P sonatype -DskipTests \
55+
-s ${{ github.workspace }}/.github/settings.xml
56+
else
57+
echo "Deploying snapshot to Maven Central"
58+
mvn deploy -DskipTests \
59+
-s ${{ github.workspace }}/.github/settings.xml
60+
fi
7661
env:
7762
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
7863
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
7964
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
8065
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
81-
VERSIONING_GIT_REF: ${{ github.ref }}
8266
VERSIONING_EXTENSION_LOG: true

.mvn/extensions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<extension>
44
<groupId>me.qoomon</groupId>
55
<artifactId>maven-git-versioning-extension</artifactId>
6-
<version>9.6.5</version>
6+
<version>9.10.2</version>
77
</extension>
88
</extensions>
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<gitVersioning>
3+
<verbose>true</verbose>
4+
<updatePom>true</updatePom>
5+
<preferTags>true</preferTags>
36
<refs>
7+
<!-- For tags like v5.0.0 or v5.0.0-M1 -->
8+
<ref type="tag">
9+
<pattern>v(.*)</pattern>
10+
<version>${1}</version>
11+
</ref>
12+
13+
<!-- For branches - add commit hash and SNAPSHOT -->
414
<ref type="branch">
515
<pattern>.*</pattern>
6-
<version>${commit.short}-SNAPSHOT</version>
7-
</ref>
8-
<ref type="tag">
9-
<pattern>v([0-9]+)\.([0-9]+)\.([0-9]+)</pattern>
10-
<version>${1}.${2}.${3}</version>
16+
<version>
17+
${project.version.release}+${git.commit.timestamp.datetime}-${git.commit.id.abbrev}-SNAPSHOT</version>
1118
</ref>
1219
</refs>
1320
</gitVersioning>

0 commit comments

Comments
 (0)