Skip to content

Publish

Publish #4

Workflow file for this run

name: Publish
on:
workflow_dispatch:
inputs:
type:
description: "Publish type"
required: true
type: choice
options:
- snapshot
- production
version:
description: "Version (e.g. 1.2.3)"
required: true
jobs:
publish:
name: Release build and publish
runs-on: ubuntu-latest
environment: ${{ inputs.type }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: gradle
- name: Validate inputs
run: |
if ! [[ "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "version must be like 1.2.3"; exit 1;
fi
- name: Format version
id: v
run: |
VERSION="${{ inputs.version }}"
if [ "${{ inputs.type }}" = "snapshot" ]; then
VERSION="${VERSION}-SNAPSHOT"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Publish to MavenCentral
run: ./gradlew --no-configuration-cache -Pversion='${{ steps.v.outputs.version }}' :mobilenlp-kit:publishToMavenCentral
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }}