Skip to content

Commit ae055f9

Browse files
committed
better versioning
1 parent b4f0061 commit ae055f9

File tree

2 files changed

+36
-31
lines changed

2 files changed

+36
-31
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
Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<gitVersioning>
3+
<verbose>true</verbose>
4+
<updatePom>false</updatePom>
35
<refs>
6+
<!-- Handle tags first - exact tag matches will produce a release version -->
7+
<ref type="tag">
8+
<pattern>v([0-9]+)\.([0-9]+)\.([0-9]+)(-[a-zA-Z0-9]+)?</pattern>
9+
<version>${1}.${2}.${3}${4}</version>
10+
</ref>
11+
12+
<!-- For branches that are exactly on a tag -->
413
<ref type="branch">
514
<pattern>.*</pattern>
6-
<version>${commit.short}-SNAPSHOT</version>
15+
<version>${describe.tag.version}</version>
16+
<!-- Filter for branches that are exactly on a tag; if there's distance, this won't match -->
17+
<properties>
18+
<describe.distance>0</describe.distance>
19+
</properties>
720
</ref>
8-
<ref type="tag">
9-
<pattern>v([0-9]+)\.([0-9]+)\.([0-9]+)</pattern>
10-
<version>${1}.${2}.${3}</version>
21+
22+
<!-- For branches with commits after a tag -->
23+
<ref type="branch">
24+
<pattern>.*</pattern>
25+
<version>${describe.tag.version}+${describe.distance}-${commit.short}-SNAPSHOT</version>
1126
</ref>
1227
</refs>
28+
<rev>
29+
<!-- Fallback version if no branch/tag match -->
30+
<version>${commit.short}-SNAPSHOT</version>
31+
</rev>
32+
<preferTags>true</preferTags>
33+
<disable>false</disable>
1334
</gitVersioning>

0 commit comments

Comments
 (0)