-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (60 loc) · 2.11 KB
/
publish-jar.yml
File metadata and controls
64 lines (60 loc) · 2.11 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
name: publish-jar
on:
workflow_dispatch:
inputs:
tag:
description: 'Optional tag. Default to the tag of the selected branch.'
required: false
type: string
permissions:
contents: read
jobs:
publish-jar:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
cache: 'gradle'
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: Get version
id: version
run: echo "VERSION=$(./gradlew -q printVersion)" >> "$GITHUB_OUTPUT"
- name: Validate tag format and version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ ! -z "${{ github.event.inputs.tag }}" ]; then
TAG=${{ github.event.inputs.tag }}
else
TAG=${GITHUB_REF#refs/tags/}
fi
if [[ ! $TAG =~ ^v ]]; then
echo "Error: Tag must start with 'v'"
exit 1
fi
if [[ ! $TAG == v${{ steps.version.outputs.VERSION }} ]]; then
echo "Error: Tag version ($TAG) does not match project version (v${{ steps.version.outputs.VERSION }})"
exit 1
fi
- name: Install Node modules
run: npm install
- name: Build a publishable JAR
run: ./gradlew clean publish
- name: Publish to Sonatype
run: ./gradlew jreleaserDeploy
env:
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.JRELEASER_MAVENCENTRAL_PASSWORD }}
CI: true
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}