Workflow file for this run
This file contains 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
# When a new release is created, publish artifacts to Maven Central / JetBrains Marketplace / etc.. | |
# | |
# About secrets used here: | |
# 1. OSSRH_USERNAME, OSSRH_TOKEN: token obtained from https://oss.sonatype.org/ | |
# 2. OSSRH_GPG_SECRET_KEY - private key for signing Maven artifacts | |
# 3. OSSRH_GPG_SECRET_KEY_PASSWORD - password for unlocking OSSRH_GPG_SECRET_KEY | |
# 4. JETBRAINS_MARKETPLACE_TOKEN - token obtained from https://plugins.jetbrains.com/author/me/tokens | |
name: Publish package to Maven Central and JetBrains Marketplace | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
inputs: | |
release_tag: | |
description: 'Release tag' | |
required: true | |
type: string | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.events.release.tag_name || inputs.release_tag || github.ref }} | |
- name: Set up Maven Central Repository | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
distribution: zulu | |
- id: install-secret-key | |
name: Install gpg secret key | |
run: | | |
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import | |
gpg --list-secret-keys --keyid-format LONG | |
- id: publish-to-central | |
name: Publish to Maven Central Repository | |
env: | |
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | |
run: | | |
mvn \ | |
--no-transfer-progress \ | |
--batch-mode \ | |
-Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} \ | |
-Prelease clean deploy | |
- name: Publish IntelliJ plugin to JetBrains Marketplace | |
run: | | |
pushd ktfmt_idea_plugin | |
./gradlew publishPlugin --stacktrace --no-daemon | |
popd | |
env: | |
JETBRAINS_MARKETPLACE_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }} | |
- uses: actions/setup-node@v4 | |
- name: Deploy website | |
run: | | |
KTFMT_TMP_DIR=$(mktemp -d) | |
pushd website | |
npm install . | |
KTFMT_WEBSITE_OUTPUT_DIR="$KTFMT_TMP_DIR" gulp build-website | |
popd | |
git fetch | |
git checkout gh-pages | |
git config user.email [email protected] | |
git config user.name ktfmt | |
rm -rf * | |
cp -R "$KTFMT_TMP_DIR"/* . | |
git add . | |
git commit -m "Publish website" | |
git push --force | |
rm -rf "$KTFMT_TMP_DIR" |