Skip to content

Publish

Publish #6

Workflow file for this run

name: Publish
on:
workflow_dispatch:
inputs:
staging_repository_action:
description: What to do with the Sonatype staging repository after upload
required: true
default: none
type: choice
options:
- none
- close
- close-and-release
publish_docs:
description: Publish Dokka docs over SSH
required: true
default: true
type: boolean
release_version:
description: Release version, for example 1.0.0
required: true
type: string
next_version:
description: Next development version, for example 1.0.1-SNAPSHOT
required: true
type: string
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
jobs:
publish:
name: Publish artifacts
runs-on: ubuntu-latest
timeout-minutes: 90
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.GPG_SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGNING_PASSWORD }}
DOKKA_REPO: ${{ secrets.DOKKA_REPO }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 25
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: false
cache-cleanup: on-success
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-v1-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', '**/gradle-wrapper.properties', 'gradle/*.versions.toml') }}
restore-keys: |
${{ runner.os }}-m2-v1-
- name: Configure Git identity
run: |
git config user.name "Kirill Gagarski"
git config user.email "kirill.gagarski@gmail.com"
- name: Validate release branch
if: ${{ github.ref_name != 'master' }}
run: |
echo "Releases must be run from master; current ref is ${{ github.ref_name }}."
exit 1
- name: Set up SSH for docs
if: ${{ inputs.publish_docs }}
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.DOKKA_SSH_PRIVATE_KEY }}
- name: Configure SSH known hosts
if: ${{ inputs.publish_docs }}
shell: bash
env:
DOKKA_KNOWN_HOSTS: ${{ secrets.DOKKA_KNOWN_HOSTS }}
run: |
mkdir -p ~/.ssh
chmod 700 ~/.ssh
if [ -n "$DOKKA_KNOWN_HOSTS" ]; then
printf '%s\n' "$DOKKA_KNOWN_HOSTS" > ~/.ssh/known_hosts
chmod 600 ~/.ssh/known_hosts
fi
- name: Release, publish artifacts, and optionally publish docs
run: >-
./gradlew --build-cache release
-Prelease.useAutomaticVersion=true
-Prelease.releaseVersion="${{ inputs.release_version }}"
-Prelease.newVersion="${{ inputs.next_version }}"
-Pvertigram.staging.action="${{ inputs.staging_repository_action }}"
-Pvertigram.dokka.publish="${{ inputs.publish_docs }}"
-Pvertigram.dokka.repo="$DOKKA_REPO"