-
Notifications
You must be signed in to change notification settings - Fork 4
99 lines (87 loc) · 3.71 KB
/
Copy pathrelease.yml
File metadata and controls
99 lines (87 loc) · 3.71 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
99
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (must match the version in build.gradle)'
required: true
dry-run:
description: 'Dry run'
type: boolean
required: true
default: false
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Verify release version
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
PROJECT_VERSION=$(grep -E "^version = " build.gradle | sed -E "s/version = '(.*)'/\1/")
echo "build.gradle version: $PROJECT_VERSION"
echo "requested version: $INPUT_VERSION"
if [ "$PROJECT_VERSION" != "$INPUT_VERSION" ]; then
echo "::error::Requested version '$INPUT_VERSION' does not match build.gradle version '$PROJECT_VERSION'. Bump build.gradle (and README/CHANGELOG) and commit before releasing."
exit 1
fi
- name: Setup Java
uses: actions/setup-java@v5
with:
java-version: '25'
distribution: 'zulu'
- name: Cache Gradle
uses: actions/cache@v6
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Build
run: ./gradlew build
env:
GH_PACKAGES_READ_TOKEN: ${{ secrets.GH_PACKAGES_READ_TOKEN }}
GH_PACKAGES_WRITE_TOKEN: ${{ secrets.GH_PACKAGES_WRITE_TOKEN }}
IPREGISTRY_API_KEY: ${{ secrets.IPREGISTRY_API_KEY }}
IPREGISTRY_DATASETS_SECRET_KEY: ${{ secrets.IPREGISTRY_DATASETS_SECRET_KEY }}
- name: Publish artifacts to staging
run: ./gradlew publish
- name: Deploy to Maven Central
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
run: |
mkdir -p build/jreleaser
echo "=== Staging directory contents ==="
find build/staging-deploy -type f -ls || echo "No staging directory found"
echo "=== Running JReleaser Deploy ==="
./gradlew jreleaserDeploy --stacktrace ${{ inputs.dry-run && '--dryrun' || '' }} || {
echo "=== JReleaser failed, checking logs ==="
find build/jreleaser -name "*.log" -exec cat {} \; || echo "No log files found"
exit 1
}
- name: Create GitHub release
if: ${{ !inputs.dry-run }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=$(grep -E "^version = " build.gradle | sed -E "s/version = '(.*)'/\1/")
echo "Creating GitHub release for version: $VERSION"
# Extract the CHANGELOG.md section for this version as the release notes.
awk -v ver="$VERSION" 'index($0, "## [" ver "]") == 1 {f=1; next} f && /^## \[/ {f=0} f' CHANGELOG.md > release-notes.md
if [ ! -s release-notes.md ]; then
echo "Release $VERSION" > release-notes.md
fi
if gh release view "$VERSION" >/dev/null 2>&1; then
gh release edit "$VERSION" --target "$GITHUB_SHA" --title "$VERSION" --notes-file release-notes.md
else
gh release create "$VERSION" --target "$GITHUB_SHA" --title "$VERSION" --notes-file release-notes.md
fi