Skip to content

chore: prepare for release 1.0.3 #12

chore: prepare for release 1.0.3

chore: prepare for release 1.0.3 #12

Workflow file for this run

name: Publish
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
jobs:
release_version:
runs-on: ubuntu-latest
if: github.repository == 'block/kotlin-formatter'
outputs:
version: ${{ steps.release_version.outputs.version }}
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Extract release version
id: release_version
run: |
VERSION=$(grep "^version=" gradle.properties | cut -d'=' -f2 | xargs)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Validate tag matches release version
run: |
if [[ "${{ github.ref_name }}" != "${{ steps.release_version.outputs.version }}" ]]; then
echo "Error: Tag '${{ github.ref_name }}' does not match expected version '${{ steps.release_version.outputs.version }}'."
exit 1
fi
publish:
needs: release_version
env:
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SECRET_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SECRET_PASSPHRASE }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME_XYZ_BLOCK }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD_XYZ_BLOCK }}
runs-on: ubuntu-latest
steps:
# Free disk space to avoid running into "No space left on device" errors
# when downloading multiple versions of IntelliJ for plugin verification
- name: Maximize Build Space
uses: jlumbroso/free-disk-space@v1.3.1
with:
tool-cache: true
- name: Checkout the repo
uses: actions/checkout@v4
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Execute buildHealth for build-logic
run: './gradlew -p build-logic buildHealth -s'
- name: Execute check
run: './gradlew check -s'
- name: Execute buildHealth for main project
run: './gradlew buildHealth -s'
- name: Publish artifacts
run: './gradlew publishToMavenCentral -s --no-configuration-cache'
- name: Prepare assets for Github Release
run: |
echo "Renaming assets to match Maven Central naming conventions."
mv kotlin-format/build/libs/kotlin-format-${{ needs.release_version.outputs.version }}-all.jar kotlin-format/build/libs/kotlin-formatter-${{ needs.release_version.outputs.version }}-all.jar
mv kotlin-format/build/distributions/kotlin-format-shadow-${{ needs.release_version.outputs.version }}.zip kotlin-format/build/distributions/kotlin-formatter-dist-${{ needs.release_version.outputs.version }}.zip
- name: Extract release notes
id: release_notes
uses: ffurrer2/extract-release-notes@v2
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.release_version.outputs.version }}
name: ${{ needs.release_version.outputs.version }}
body: |
${{ steps.release_notes.outputs.release_notes }}
draft: false
prerelease: false
files: |
kotlin-format/build/libs/kotlin-formatter-${{ needs.release_version.outputs.version }}-all.jar
kotlin-format/build/distributions/kotlin-formatter-dist-${{ needs.release_version.outputs.version }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Idea Plugin
run: |
export IJ_PLUGIN_VERSION="${{ needs.release_version.outputs.version }}"
echo "IJ_PLUGIN_VERSION=$IJ_PLUGIN_VERSION" >> $GITHUB_ENV
./gradlew idea-plugin:publishPlugin
env:
JETBRAINS_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_SQUARE_PLUGINS }}