Skip to content

Commit dd4e298

Browse files
committed
chore: setting up snapshots on github
1 parent a870b6e commit dd4e298

File tree

3 files changed

+52
-35
lines changed

3 files changed

+52
-35
lines changed

.github/workflows/release.yml

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jobs:
1515
steps:
1616
- name: Checkout code
1717
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
token: ${{ secrets.GITHUB_TOKEN }}
1821

1922
- name: Set up Java
2023
uses: actions/setup-java@v4
@@ -27,29 +30,59 @@ jobs:
2730
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
2831
gpg-passphrase: GPG_PASSPHRASE
2932

30-
- name: Get version from pom.xml
31-
id: get_version
33+
- name: Configure Git
34+
run: |
35+
git config user.name "github-actions[bot]"
36+
git config user.email "github-actions[bot]@users.noreply.github.com"
37+
38+
- name: Get current version and increment
39+
id: version
3240
run: |
33-
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
34-
echo "version=$VERSION" >> $GITHUB_OUTPUT
41+
CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
42+
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
43+
44+
# Remove -SNAPSHOT if present
45+
RELEASE_VERSION=${CURRENT_VERSION%-SNAPSHOT}
46+
echo "release=$RELEASE_VERSION" >> $GITHUB_OUTPUT
47+
48+
# Calculate next version (increment patch)
49+
IFS='.' read -r major minor patch <<< "$RELEASE_VERSION"
50+
NEXT_VERSION="$major.$minor.$((patch + 1))-SNAPSHOT"
51+
echo "next=$NEXT_VERSION" >> $GITHUB_OUTPUT
52+
53+
- name: Set release version
54+
run: |
55+
mvn versions:set -DnewVersion=${{ steps.version.outputs.release }} -DgenerateBackupPoms=false
3556
3657
- name: Build and verify
3758
run: mvn -B clean verify -Prelease
3859
env:
3960
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
4061

4162
- name: Deploy to Maven Central
42-
run: mvn -B clean deploy -Prelease
63+
run: mvn -B deploy -Prelease -DskipTests
4364
env:
4465
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
4566
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
4667
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
4768

69+
- name: Create Git tag
70+
run: |
71+
git tag -a "v${{ steps.version.outputs.release }}" -m "Release v${{ steps.version.outputs.release }}"
72+
git push origin "v${{ steps.version.outputs.release }}"
73+
4874
- name: Create GitHub Release
4975
uses: softprops/action-gh-release@v1
5076
with:
51-
tag_name: v${{ steps.get_version.outputs.version }}
52-
name: Release v${{ steps.get_version.outputs.version }}
77+
tag_name: v${{ steps.version.outputs.release }}
78+
name: Release v${{ steps.version.outputs.release }}
5379
generate_release_notes: true
5480
env:
5581
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
83+
- name: Set next development version
84+
run: |
85+
mvn versions:set -DnewVersion=${{ steps.version.outputs.next }} -DgenerateBackupPoms=false
86+
git add pom.xml
87+
git commit -m "chore: bump version to ${{ steps.version.outputs.next }} [skip ci]"
88+
git push origin main

.github/workflows/snapshot.yml

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
name: Publish Snapshot
1+
name: Dev Build
22

33
on:
44
push:
55
branches:
66
- dev
77

88
jobs:
9-
snapshot:
9+
build:
1010
runs-on: ubuntu-latest
1111

12-
permissions:
13-
contents: read
14-
1512
steps:
1613
- name: Checkout code
1714
uses: actions/checkout@v4
@@ -21,27 +18,14 @@ jobs:
2118
with:
2219
distribution: temurin
2320
java-version: '17'
24-
server-id: central
25-
server-username: CENTRAL_USERNAME
26-
server-password: CENTRAL_PASSWORD
27-
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
28-
gpg-passphrase: GPG_PASSPHRASE
29-
30-
- name: Set snapshot version
31-
run: |
32-
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
33-
if [[ ! "$VERSION" == *"-SNAPSHOT" ]]; then
34-
mvn versions:set -DnewVersion="${VERSION}-SNAPSHOT" -DgenerateBackupPoms=false
35-
fi
21+
cache: maven
3622

37-
- name: Build and verify
38-
run: mvn -B clean verify -Prelease
39-
env:
40-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
23+
- name: Build and test
24+
run: mvn -B clean verify
4125

42-
- name: Deploy snapshot to Maven Central
43-
run: mvn -B clean deploy -Prelease
44-
env:
45-
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
46-
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
47-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
26+
- name: Upload build artifacts
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: endee-java-client-dev
30+
path: target/*.jar
31+
retention-days: 7

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.endee</groupId>
88
<artifactId>endee-java-client</artifactId>
9-
<version>0.1.0</version>
9+
<version>0.1.1-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Endee Java Client</name>

0 commit comments

Comments
 (0)