Skip to content

Commit

Permalink
Update Build Action and add Release Action
Browse files Browse the repository at this point in the history
  • Loading branch information
nailujx86 committed Jun 21, 2024
1 parent 1a6b996 commit dd88a48
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 35 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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/*/*
42 changes: 42 additions & 0 deletions .github/workflows/buildPlugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
workflow_call:
outputs:
version:
value: ${{ jobs.buildPlugin.outputs.version }}
artifactName:
value: "pluginArtifact"

jobs:
buildPlugin:
name: Build plugin
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.environment.outputs.version }}
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: Upload artifact
uses: actions/upload-artifact@v4
id: artifact-upload
with:
path: ${{ github.workspace }}/build/distributions
name: pluginArtifact
overwrite: true
retention-days: 1
31 changes: 0 additions & 31 deletions .github/workflows/gradle.yml

This file was deleted.

45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
21 changes: 19 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ plugins {
id "org.jsonschema2pojo" version "1.2.1"
}

group = getProperty("pluginGroup")
version = getProperty("pluginVersion")

allprojects {

group 'de.gebit.plugins.autoconfig'
Expand All @@ -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>).*(?=<\/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 {
Expand All @@ -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()
}
Expand Down
7 changes: 7 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<id>de.gebit.plugins.autoconfig</id>
<name>Autoconfig</name>
<vendor email="[email protected]" url="https://github.com/GEBIT/autoconfig-intellij-plugin">GEBIT Solutions GmbH</vendor>

<version>0.0.1</version>

<idea-version since-build="232.1"/>

<depends>com.intellij.modules.json</depends>
Expand Down

0 comments on commit dd88a48

Please sign in to comment.