From 9ae604d114099a66713da8cf04615ea54230acfc Mon Sep 17 00:00:00 2001 From: Julian Blazek Date: Fri, 21 Jun 2024 13:59:53 +0200 Subject: [PATCH] Update Build Action and add Release Action --- .github/workflows/build.yml | 41 +++++++++++++++++++++++ .github/workflows/gradle.yml | 31 ------------------ .github/workflows/release.yml | 45 ++++++++++++++++++++++++++ build.gradle | 21 ++++++++++-- gradle.properties | 7 ++++ src/main/resources/META-INF/plugin.xml | 3 +- 6 files changed, 113 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/gradle.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4e2aac4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +name: Build + +on: + push: + branches: [ main, ci-cd-improvements ] + pull_request: + +jobs: + build: + name: Build and upload plugin artifact + runs-on: ubuntu-24.04 + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + lfs: true + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: adopt-hotspot + - name: Run Gradle Check # also ensures gradle is downloaded + run: | + chmod +x gradlew + ./gradlew check + - name: Set Variables + id: environment + shell: bash + run: echo "version=$(./gradlew printVersion --console=plain -q)" >> $GITHUB_OUTPUT + - name: Build plugin + run: ./gradlew buildPlugin + - name: Unpack unsigned plugin for repackaging + shell: bash + run: | + cd ${{ github.workspace }}/build/distributions + unzip *.zip -d pluginfiles + - name: Upload built plugin + uses: actions/upload-artifact@v4 + with: + name: autoconfig-plugin-${{ steps.environment.outputs.version }} + path: build/distributions/pluginfiles/*/* \ No newline at end of file diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml deleted file mode 100644 index 796f65a..0000000 --- a/.github/workflows/gradle.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: CI - -on: - push: - branches: [ main ] - -jobs: - build: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - lfs: true - - uses: actions/setup-java@v4 - name: Set up JDK 17 - with: - java-version: 17 - distribution: adopt-hotspot - - name: Build plugin - run: | - chmod +x gradlew - ./gradlew check buildPlugin signPlugin --info - env: - CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }} - PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} - PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }} - - name: Upload built plugin - uses: actions/upload-artifact@v4 - with: - name: autoconfig-plugin - path: build/distributions/*.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0ab58ef --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: Release + +on: + release: + types: + - published + +jobs: + build: + name: Build, sign and publish plugin + runs-on: ubuntu-24.04 + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + lfs: true + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: adopt-hotspot + - name: Run Gradle Check # also ensures gradle is downloaded + run: | + chmod +x gradlew + ./gradlew check + - name: Set Variables + id: environment + shell: bash + run: | + echo "version=$(./gradlew printVersion --console=plain -q)" >> $GITHUB_OUTPUT + - name: Set release flag + id: release + shell: bash + run: echo "preRelease=${{ github.event.release.prerelease}}" >> $GITHUB_OUTPUT + - name: Build plugin, sign plugin and publish plugin + run: ./gradlew buildPlugin signPlugin publishPlugin -PpreRelease=${{ steps.release.outputs.preRelease }} + env: + PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} + - name: Sign and publish plugin + run: ./gradlew signPlugin publishPlugin -PpreRelease=${{ steps.release.outputs.preRelease }} + env: + PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} + CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }} + PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} + PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 164efd1..fa3e40e 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,9 @@ plugins { id "org.jsonschema2pojo" version "1.2.1" } +group = getProperty("pluginGroup") +version = getProperty("pluginVersion") + allprojects { group 'de.gebit.plugins.autoconfig' @@ -22,10 +25,18 @@ allprojects { } patchPluginXml { + version = getProperty("pluginVersion") sinceBuild = "232.1" untilBuild = "241.*" - pluginDescription = new File("metadata/description.html").text - changeNotes = new File("metadata/changelog.html").text + def bodyMatcher = /(?s)(?<=).*(?=<\/body>)/ + pluginDescription = new File("metadata/description.html").text.findAll(bodyMatcher)?[0] + changeNotes = new File("metadata/changelog.html").text.findAll(bodyMatcher)?[0] +} + +task printVersion { + doLast { + println(rootProject.version) + } } signPlugin { @@ -34,6 +45,12 @@ signPlugin { password = System.getenv("PRIVATE_KEY_PASSWORD") } +publishPlugin { + token = System.getenv("PUBLISH_TOKEN") + setHidden(getProperty("hidden") as Boolean) + channels = getProperty("preRelease") ? ["autoconfig-beta"] : ["default", "autoconfig-beta"] +} + repositories { mavenCentral() } diff --git a/gradle.properties b/gradle.properties index e5d9a95..540f531 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,8 @@ +# Autoconfig Plugin Properties +pluginVersion = 0.0.2 +preRelease = false +hidden = true +pluginGroup = de.gebit.plugins.autoconfig + +# IntelliJ Plugin Build Support kotlin.stdlib.default.dependency = false diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index ee9fd45..99b3ac0 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -2,8 +2,7 @@ de.gebit.plugins.autoconfig Autoconfig GEBIT Solutions GmbH - - 0.0.1 + com.intellij.modules.json