-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (68 loc) · 2.66 KB
/
release.yml
File metadata and controls
79 lines (68 loc) · 2.66 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
name: Manual Release
on:
workflow_dispatch:
inputs:
new_version:
description: 'New version (e.g., 1.2.0)'
required: true
release_name:
description: 'Release name'
required: true
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Check if tag already exists
run: |
if git rev-parse "v${{ github.event.inputs.new_version }}" >/dev/null 2>&1; then
echo "Error: Tag v${{ github.event.inputs.new_version }} already exists. Releases are immutable."
exit 1
fi
- name: Read Java version from .sdkmanrc
id: sdkman
run: |
JAVA_VERSION=$(grep "^java=" .sdkmanrc | cut -d'=' -f2 | cut -d'-' -f1)
echo "version=$JAVA_VERSION" >> $GITHUB_OUTPUT
- name: Set up JDK from .sdkmanrc
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ steps.sdkman.outputs.version }}
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Configure Git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Update Version Files
run: |
./mvnw versions:set -DnewVersion=${{ github.event.inputs.new_version }} -DgenerateBackupPoms=false --batch-mode
./mvnw versions:commit --batch-mode
sed -i '/either<\/artifactId>/,/<version>/ s/<version>[^<]*<\/version>/<version>${{ github.event.inputs.new_version }}<\/version>/' README.md
git add pom.xml README.md
git diff --staged --quiet || git commit -m "Bump version to ${{ github.event.inputs.new_version }}"
git push origin main
- name: Build and Deploy to Maven Central
run: ./mvnw clean deploy -Prelease --batch-mode
env:
MAVEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ github.event.inputs.new_version }}
name: ${{ github.event.inputs.release_name }}
files: target/*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}