Skip to content

Release Plugin

Release Plugin #12

---
name: Release Plugin
on:
workflow_dispatch:
inputs:
version:
type: string
description: Version to release
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
env:
GRADLE_OPTS: -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false
permissions: {}
jobs:
pre-release-check:
permissions:
contents: read
name: Pre-release check
runs-on: ubuntu-latest
steps:
- name: Version check
run: |
if ! [[ "$PLUGIN_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$ ]]; then
echo "[ERROR]: Input version doesn't follow semver: $PLUGIN_VERSION"
exit 1
fi
env:
PLUGIN_VERSION: ${{ inputs.version }}
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Install JDK 17
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Build project
run: >-
./gradlew build --no-daemon
"-Porg.jsonschema2dataclass.internal.git-version-override=$PLUGIN_VERSION"
env:
TEST_GRADLE_VER_EXACT: current
PLUGIN_VERSION: ${{ inputs.version }}
publish-github:
permissions:
contents: write # publish GitHub release
name: Publish GitHub (draft)
runs-on: ubuntu-latest
environment: production
needs:
- pre-release-check
steps:
- name: Checkout repo
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Create Github release
run: |
PRE_RELEASE=""
if [[ "$PLUGIN_VERSION" == *"beta"* ]]; then
PRE_RELEASE="-p"
fi
if [[ "$PLUGIN_VERSION" == *"alpha"* ]]; then
PRE_RELEASE="-p"
fi
if [[ "$PLUGIN_VERSION" == *"rc"* ]]; then
PRE_RELEASE="-p"
fi
set -x
gh release create --draft $PRE_RELEASE "v$PLUGIN_VERSION" --fail-on-no-commits --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PLUGIN_VERSION: ${{ inputs.version }}
publish-gradle:
name: Publish Gradle plugin
needs:
- publish-github
permissions:
contents: read
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout repo
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Install JDK 17
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Publish
run: |
./gradlew publishPlugins -s --scan --no-daemon --no-configuration-cache \
-Porg.jsonschema2dataclass.internal.git-version-override=$PLUGIN_VERSION
env:
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
PLUGIN_VERSION: ${{ inputs.version }}
finalise-github-release:
name: Publish GitHub
needs:
- publish-gradle
permissions:
contents: write # publish GitHub release
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Finalise Github release
run: |
gh release edit "v$PLUGIN_VERSION" --draft=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PLUGIN_VERSION: ${{ inputs.version }}