Skip to content

Update release-jreleaser.yml: add SIGNING_KEY_ID to environment v… #3

Update release-jreleaser.yml: add SIGNING_KEY_ID to environment v…

Update release-jreleaser.yml: add SIGNING_KEY_ID to environment v… #3

name: Release to Maven Central (JReleaser)
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
dry_run:
description: "JReleaser dry run"
required: false
default: false
type: boolean
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN || github.token }}
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.MAVENCENTRAL_TOKEN }}
JRELEASER_LOG_LEVEL: info
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from tag
id: ver
shell: bash
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME#v}"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Detected version: $VERSION"
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "21"
cache: gradle
# - name: Build (tests optional)
# shell: bash
# run: |
# set -euo pipefail
# ./gradlew --no-daemon --stacktrace clean build -x test
- name: Check signing env
shell: bash
run: |
test -n "$SIGNING_KEY" || (echo "SIGNING_KEY is empty" && exit 1)
test -n "$SIGNING_PASSWORD" || (echo "SIGNING_PASSWORD is empty" && exit 1)
test -n "$SIGNING_KEY_ID" || (echo "SIGNING_KEY_ID is empty" && exit 1)
echo "$SIGNING_KEY" | grep -q "BEGIN PGP PRIVATE KEY BLOCK" || \
(echo "SIGNING_KEY is not a private PGP key block" && exit 1)
- name: Publish ksef-client to staging repository dir
shell: bash
run: |
set -euo pipefail
./gradlew --no-daemon --stacktrace \
-Pversion="${VERSION}" \
:ksef-client:publishMavenPublicationToStagingRepository
- name: JReleaser config (optional, useful for debugging)
shell: bash
run: |
set -euo pipefail
./gradlew --no-daemon --stacktrace jreleaserConfig
- name: JReleaser deploy to Maven Central
shell: bash
run: |
set -euo pipefail
if [[ "${{ inputs.dry_run }}" == "true" ]]; then
./gradlew --no-daemon --stacktrace jreleaserDeploy --dryrun
else
./gradlew --no-daemon --stacktrace jreleaserDeploy
fi
- name: Create GitHub Release (after Maven Central)
if: ${{ inputs.dry_run != true }}
shell: bash
run: |
set -euo pipefail
./gradlew --no-daemon --stacktrace jreleaserRelease