diff options
-rw-r--r-- | .github/dependabot.yml | 17 | ||||
-rw-r--r-- | .github/workflows/build.yml | 143 | ||||
-rw-r--r-- | .github/workflows/release.yml | 88 | ||||
-rw-r--r-- | CHANGELOG.md | 10 | ||||
-rw-r--r-- | README.md | 7 | ||||
-rw-r--r-- | build.gradle.kts | 61 | ||||
-rw-r--r-- | gradle.properties | 16 | ||||
-rw-r--r-- | gradle/libs.versions.toml | 2 | ||||
-rw-r--r-- | src/main/resources/META-INF/plugin.xml | 5 |
9 files changed, 340 insertions, 9 deletions
diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f6fd812 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +# Dependabot configuration: +# https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + # Maintain dependencies for Gradle dependencies + - package-ecosystem: "gradle" + directory: "/" + target-branch: "next" + schedule: + interval: "daily" + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + target-branch: "next" + schedule: + interval: "daily" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..97f8e3b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,143 @@ +name: Build +on: + push: + branches: [ main ] + pull_request: + +concurrency: + group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}" + cancel-in-progress: true + +jobs: + build: + name: Build + runs-on: ubuntu-latest + outputs: + version: ${{ steps.properties.outputs.version }} + changelog: ${{ steps.properties.outputs.changelog }} + pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }} + steps: + - name: Fetch Sources + uses: actions/checkout@v4 + + - name: Gradle Wrapper Validation + uses: gradle/wrapper-validation-action@v2 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true + + - name: Export Properties + id: properties + shell: bash + run: | + PROPERTIES="$(./gradlew properties --console=plain -q)" + VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')" + CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)" + + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT + + echo "changelog<<EOF" >> $GITHUB_OUTPUT + echo "$CHANGELOG" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier + + - name: Build plugin + run: ./gradlew buildPlugin + + - name: Prepare Plugin Artifact + id: artifact + shell: bash + run: | + cd ${{ github.workspace }}/build/distributions + FILENAME=`ls *.zip` + unzip "$FILENAME" -d content + + echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.artifact.outputs.filename }} + path: ./build/distributions/content/*/* + + verify: + name: Verify plugin + needs: [ build ] + runs-on: ubuntu-latest + steps: + - name: Maximize Build Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + large-packages: false + + - name: Fetch Sources + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true + + - name: Setup Plugin Verifier IDEs Cache + uses: actions/cache@v4 + with: + path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides + key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }} + + - name: Run Plugin Verification tasks + run: ./gradlew runPluginVerifier -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }} + + - name: Collect Plugin Verifier Result + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: pluginVerifier-result + path: ${{ github.workspace }}/build/reports/pluginVerifier + + releaseDraft: + name: Release draft + if: github.event_name != 'pull_request' + needs: [ build, verify ] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Fetch Sources + uses: actions/checkout@v4 + + - name: Remove Old Release Drafts + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh api repos/{owner}/{repo}/releases \ + --jq '.[] | select(.draft == true) | .id' \ + | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{} + + - name: Create Release Draft + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create "v${{ needs.build.outputs.version }}" \ + --draft \ + --title "v${{ needs.build.outputs.version }}" \ + --notes "$(cat << 'EOM' + ${{ needs.build.outputs.changelog }} + EOM + )" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..01eaeee --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,88 @@ +name: Release +on: + release: + types: [prereleased, released] + +jobs: + release: + name: Publish Plugin + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - name: Fetch Sources + uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.tag_name }} + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true + + - name: Export Properties + id: properties + shell: bash + run: | + CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d' + ${{ github.event.release.body }} + EOM + )" + + echo "changelog<<EOF" >> $GITHUB_OUTPUT + echo "$CHANGELOG" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Patch Changelog + if: ${{ steps.properties.outputs.changelog != '' }} + env: + CHANGELOG: ${{ steps.properties.outputs.changelog }} + run: | + ./gradlew patchChangelog --release-note="$CHANGELOG" + + - name: Publish Plugin + env: + PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} + CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }} + PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} + PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }} + run: ./gradlew publishPlugin + + - name: Upload Release Asset + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/* + + - name: Create Pull Request + if: ${{ steps.properties.outputs.changelog != '' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + VERSION="${{ github.event.release.tag_name }}" + BRANCH="changelog-update-$VERSION" + LABEL="release changelog" + + git config user.email "action@github.com" + git config user.name "GitHub Action" + + git checkout -b $BRANCH + git commit -am "Changelog update - $VERSION" + git push --set-upstream origin $BRANCH + + gh label create "$LABEL" \ + --description "Pull requests with release changelog update" \ + --force \ + || true + + gh pr create \ + --title "Changelog update - \`$VERSION\`" \ + --body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \ + --label "$LABEL" \ + --head $BRANCH diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e720231 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +<!-- Keep a Changelog guide -> https://keepachangelog.com --> + +# IntelliProcessor Changelog + +## [Unreleased] +### Added +- added meowing + +### fixed +- updated version @@ -1,5 +1,10 @@ # IntelliProcessor +![Build](https://github.com/Polyfrost/IntelliProcessor/workflows/Build/badge.svg) +[![Version](https://img.shields.io/jetbrains/plugin/v/org.polyfrost.sorbet.intelliprocessor.svg)](https://plugins.jetbrains.com/plugin/org.polyfrost.sorbet.intelliprocessor) +[![Downloads](https://img.shields.io/jetbrains/plugin/d/org.polyfrost.sorbet.intelliprocessor.svg)](https://plugins.jetbrains.com/plugin/org.polyfrost.sorbet.intelliprocessor) + +<!-- plugin description --> An IntelliJ plugin to add support for the ReplayMod [preprocessor syntax](https://github.com/ReplayMod/Preprocessor) ## Features @@ -10,3 +15,5 @@ An IntelliJ plugin to add support for the ReplayMod [preprocessor syntax](https: * Highlighting/intellisense of preprocessor comment blocks. * Ability to "fold" preprocessor comment blocks. * Auto-remapping within preprocessor comment blocks based on variables. +<!-- plugin description end --> + diff --git a/build.gradle.kts b/build.gradle.kts index da0ea43..89b2ea9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,15 @@ +import org.jetbrains.changelog.Changelog +import org.jetbrains.changelog.markdownToHTML + fun properties(key: String) = providers.gradleProperty(key) +fun environment(key: String) = providers.environmentVariable(key) plugins { id("java") alias(libs.plugins.kotlin) alias(libs.plugins.intellij) alias(libs.plugins.kotlinter) + alias(libs.plugins.changelog) } group = properties("pluginGroup").get() @@ -15,7 +20,7 @@ repositories { } kotlin { - jvmToolchain(21) + jvmToolchain(17) } kotlinter { @@ -26,11 +31,18 @@ kotlinter { intellij { pluginName = properties("pluginName") version = properties("platformVersion") + type = properties("platformType") + plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) } } +changelog { + groups.empty() + repositoryUrl = properties("pluginRepositoryUrl") +} + tasks { wrapper { gradleVersion = properties("gradleVersion").get() @@ -40,5 +52,52 @@ tasks { version = properties("pluginVersion") sinceBuild = properties("pluginSinceBuild") untilBuild = properties("pluginUntilBuild") + + pluginDescription = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { + val start = "<!-- plugin description -->" + val end = "<!-- plugin description end -->" + + with (it.lines()) { + if (!containsAll(listOf(start, end))) { + throw GradleException("Plugin description section not found in README.md:\n$start ... $end") + } + subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML) + } + } + + val changelog = project.changelog + changeNotes = properties("pluginVersion").map { pluginVersion -> + with(changelog) { + renderItem( + (getOrNull(pluginVersion) ?: getUnreleased()) + .withHeader(false) + .withEmptySections(false), + Changelog.OutputType.HTML, + ) + } + } } + + runIdeForUiTests { + systemProperty("robot-server.port", "8082") + systemProperty("ide.mac.message.dialogs.as.sheets", "false") + systemProperty("jb.privacy.policy.text", "<!--999.999-->") + systemProperty("jb.consents.confirmation.enabled", "false") + } + + signPlugin { + certificateChain = environment("CERTIFICATE_CHAIN") + privateKey = environment("PRIVATE_KEY") + password = environment("PRIVATE_KEY_PASSWORD") + } + + publishPlugin { + dependsOn("patchChangelog") + token = environment("PUBLISH_TOKEN") + channels = properties("pluginVersion").map { + listOf(it.substringAfter("-", "").substringBefore(".").ifEmpty { + "default" + }) + } + } } diff --git a/gradle.properties b/gradle.properties index 4653e92..e0cc99b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,25 @@ pluginGroup=org.polyfrost.sorbet.intelliprocessor pluginName=IntelliProcessor pluginRepositoryUrl=https://github.com/Polyfrost/IntelliProcessor -pluginVersion=1.0.1 + +pluginVersion=1.0.2 + pluginSinceBuild=223 -pluginUntilBuild=242.* +pluginUntilBuild=241.* + platformType=IC platformVersion=2022.3.3 + platformPlugins=com.intellij.java -gradleVersion=8.3 + +gradleVersion=8.7 + kotlin.stdlib.default.dependency=false kotlin.code.style=official + +org.gradle.configuration-cache = true +org.gradle.caching = true + org.gradle.daemon=true org.gradle.parallel=true org.gradle.configureoncommand=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3979485..f684def 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,8 +2,10 @@ kotlin = "1.9.23" intellij = "1.17.3" kotlinter = "4.3.0" +changelog = "2.2.0" [plugins] kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } intellij = { id = "org.jetbrains.intellij", version.ref = "intellij" } kotlinter = { id = "org.jmailen.kotlinter", version.ref = "kotlinter" } +changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index d20684e..d78ccad 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -3,11 +3,6 @@ <name>IntelliProcessor</name> <vendor url="https://polyfrost.org">Polyfrost</vendor> - <description><![CDATA[ - An IntelliJ IDEA plugin to add support for - <a href="https://github.com/ReplayMod/preprocessor">preprocessor syntax</a> - ]]></description> - <depends>com.intellij.modules.platform</depends> <depends>com.intellij.modules.java</depends> |