-
Notifications
You must be signed in to change notification settings - Fork 10
98 lines (86 loc) · 3.1 KB
/
release.yml
File metadata and controls
98 lines (86 loc) · 3.1 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
89
90
91
92
93
94
95
96
97
98
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., 0.9.0)'
required: true
next_dev_version:
description: 'Next development version (e.g., 0.10.0-SNAPSHOT). Leave empty to auto-increment minor version.'
required: false
default: ''
type: string
skip_tests:
description: 'Skip tests (use for hotfixes only)'
required: false
default: false
type: boolean
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Set version
run: ./mvnw versions:set -DnewVersion=${{ inputs.version }} -DgenerateBackupPoms=false
- name: Verify no SNAPSHOT dependencies
run: |
if grep -r "SNAPSHOT" --include="pom.xml" . | grep -v "<!--" | grep -v "target/"; then
echo "ERROR: Found SNAPSHOT references in POM files"
exit 1
fi
echo "No SNAPSHOT dependencies found"
- name: Build and verify
run: |
if [ "${{ inputs.skip_tests }}" = "true" ]; then
./mvnw clean verify -B -DskipTests
else
./mvnw clean verify -B
fi
- name: Publish release to Maven Central
run: ./mvnw deploy -B -DskipTests -Prelease
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Create Git tag
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git tag -a v${{ inputs.version }} -m "Release v${{ inputs.version }}"
git push origin v${{ inputs.version }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ inputs.version }}
name: Release ${{ inputs.version }}
draft: false
prerelease: ${{ contains(inputs.version, '-') }}
generate_release_notes: true
- name: Bump to next development version
run: |
if [ -n "${{ inputs.next_dev_version }}" ]; then
NEXT_VERSION="${{ inputs.next_dev_version }}"
else
IFS='.' read -r MAJOR MINOR PATCH <<< "${{ inputs.version }}"
NEXT_VERSION="${MAJOR}.$((MINOR + 1)).0-SNAPSHOT"
fi
echo "Next development version: ${NEXT_VERSION}"
./mvnw versions:set -DnewVersion=${NEXT_VERSION} -DgenerateBackupPoms=false
git add -A
git commit -m "Bump version to ${NEXT_VERSION}"
git push origin HEAD:main