publish-jar #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} |