-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (73 loc) · 2.83 KB
/
release.yml
File metadata and controls
88 lines (73 loc) · 2.83 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
79
80
81
82
83
84
85
86
87
88
name: Release to Maven Central
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
server-id: central
server-username: CENTRAL_USERNAME
server-password: CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Get current version and increment
id: version
run: |
CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
# Remove -SNAPSHOT if present
RELEASE_VERSION=${CURRENT_VERSION%-SNAPSHOT}
echo "release=$RELEASE_VERSION" >> $GITHUB_OUTPUT
# Calculate next version (increment patch)
IFS='.' read -r major minor patch <<< "$RELEASE_VERSION"
NEXT_VERSION="$major.$minor.$((patch + 1))-SNAPSHOT"
echo "next=$NEXT_VERSION" >> $GITHUB_OUTPUT
- name: Set release version
run: |
mvn versions:set -DnewVersion=${{ steps.version.outputs.release }} -DgenerateBackupPoms=false
- name: Build and verify
run: mvn -B clean verify -Prelease
env:
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Deploy to Maven Central
run: mvn -B deploy -Prelease -DskipTests
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Create Git tag
run: |
git tag -a "v${{ steps.version.outputs.release }}" -m "Release v${{ steps.version.outputs.release }}"
git push origin "v${{ steps.version.outputs.release }}"
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.version.outputs.release }}
name: Release v${{ steps.version.outputs.release }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set next development version
run: |
mvn versions:set -DnewVersion=${{ steps.version.outputs.next }} -DgenerateBackupPoms=false
git add pom.xml
git commit -m "chore: bump version to ${{ steps.version.outputs.next }} [skip ci]"
git push origin main