Skip to content

Commit b7d5955

Browse files
authored
Setup GitHub Actions (fix #13) (#25)
* Create build.yml * trying to fix gradlew permissions * Update build.yml * added version * confiigured changelog plugin * fix changelog * fix submodule * fix changelog * updated to reflect intellij version * updated pluginSinceBuild to 202 * remove old intellij version from verify plugin step * Create release.yml * Update CHANGELOG.md * fixed unreleased section
1 parent 8b5c832 commit b7d5955

File tree

7 files changed

+355
-8
lines changed

7 files changed

+355
-8
lines changed

.github/workflows/build.yml

+233
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
# GitHub Actions Workflow created for testing and preparing the plugin release in following steps:
2+
# - validate Gradle Wrapper,
3+
# - run test and verifyPlugin tasks,
4+
# - run buildPlugin task and prepare artifact for the further tests,
5+
# - run IntelliJ Plugin Verifier,
6+
# - create a draft release.
7+
#
8+
# Workflow is triggered on push and pull_request events.
9+
#
10+
# Docs:
11+
# - GitHub Actions: https://help.github.com/en/actions
12+
# - IntelliJ Plugin Verifier GitHub Action: https://github.com/ChrisCarini/intellij-platform-plugin-verifier-action
13+
#
14+
## JBIJPPTPL
15+
16+
name: Build
17+
on: [push, pull_request]
18+
jobs:
19+
20+
# Run Gradle Wrapper Validation Action to verify the wrapper's checksum
21+
gradleValidation:
22+
name: Gradle Wrapper
23+
runs-on: ubuntu-latest
24+
steps:
25+
26+
# Check out current repository
27+
- name: Fetch Sources
28+
uses: actions/checkout@v2
29+
with:
30+
submodules: true
31+
32+
# Validate wrapper
33+
- name: Gradle Wrapper Validation
34+
uses: gradle/wrapper-validation-action@v1
35+
36+
# Run verifyPlugin and test Gradle tasks
37+
test:
38+
name: Test
39+
needs: gradleValidation
40+
runs-on: ubuntu-latest
41+
steps:
42+
43+
# Setup Java 1.8 environment for the next steps
44+
- name: Setup Java
45+
uses: actions/setup-java@v1
46+
with:
47+
java-version: 1.8
48+
49+
# Check out current repository
50+
- name: Fetch Sources
51+
uses: actions/checkout@v2
52+
with:
53+
submodules: true
54+
55+
# Cache Gradle dependencies
56+
- name: Setup Gradle Dependencies Cache
57+
uses: actions/cache@v2
58+
with:
59+
path: ~/.gradle/caches
60+
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
61+
62+
# Cache Gradle Wrapper
63+
- name: Setup Gradle Wrapper Cache
64+
uses: actions/cache@v2
65+
with:
66+
path: ~/.gradle/wrapper
67+
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
68+
69+
# Run detekt, ktlint and tests
70+
#- name: Run Linters and Test
71+
# run: ./gradlew check
72+
73+
# Run verifyPlugin Gradle task
74+
- name: Verify Plugin
75+
run: ./gradlew verifyPlugin
76+
77+
# Build plugin with buildPlugin Gradle task and provide the artifact for the next workflow jobs
78+
# Requires test job to be passed
79+
build:
80+
name: Build
81+
needs: test
82+
runs-on: ubuntu-latest
83+
outputs:
84+
name: ${{ steps.properties.outputs.name }}
85+
version: ${{ steps.properties.outputs.version }}
86+
changelog: ${{ steps.properties.outputs.changelog }}
87+
artifact: ${{ steps.properties.outputs.artifact }}
88+
steps:
89+
90+
# Setup Java 1.8 environment for the next steps
91+
- name: Setup Java
92+
uses: actions/setup-java@v1
93+
with:
94+
java-version: 1.8
95+
96+
# Check out current repository
97+
- name: Fetch Sources
98+
uses: actions/checkout@v2
99+
with:
100+
submodules: true
101+
102+
# Cache Gradle Dependencies
103+
- name: Setup Gradle Dependencies Cache
104+
uses: actions/cache@v2
105+
with:
106+
path: ~/.gradle/caches
107+
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
108+
109+
# Cache Gradle Wrapper
110+
- name: Setup Gradle Wrapper Cache
111+
uses: actions/cache@v2
112+
with:
113+
path: ~/.gradle/wrapper
114+
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
115+
116+
# Set environment variables
117+
- name: Export Properties
118+
id: properties
119+
shell: bash
120+
run: |
121+
PROPERTIES="$(./gradlew properties --console=plain -q)"
122+
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
123+
NAME="$(echo "$PROPERTIES" | grep "^pluginName_:" | cut -f2- -d ' ')"
124+
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
125+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
126+
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
127+
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
128+
ARTIFACT="${NAME}-${VERSION}.zip"
129+
130+
echo "::set-output name=version::$VERSION"
131+
echo "::set-output name=name::$NAME"
132+
echo "::set-output name=changelog::$CHANGELOG"
133+
echo "::set-output name=artifact::$ARTIFACT"
134+
135+
# Build artifact using buildPlugin Gradle task
136+
- name: Build Plugin
137+
run: ./gradlew buildPlugin
138+
139+
# Upload plugin artifact to make it available in the next jobs
140+
- name: Upload artifact
141+
uses: actions/upload-artifact@v1
142+
with:
143+
name: plugin-artifact
144+
path: ./build/distributions/${{ needs.build.outputs.artifact }}
145+
146+
# Verify built plugin using IntelliJ Plugin Verifier tool
147+
# Requires build job to be passed
148+
verify:
149+
name: Verify
150+
needs: build
151+
runs-on: ubuntu-latest
152+
steps:
153+
154+
# Download plugin artifact provided by the previous job
155+
- name: Download Artifact
156+
uses: actions/download-artifact@v1
157+
with:
158+
name: plugin-artifact
159+
160+
# Run IntelliJ Plugin Verifier action using GitHub Action
161+
- name: Verify Plugin
162+
id: verify
163+
uses: ChrisCarini/[email protected]
164+
with:
165+
plugin-location: plugin-artifact/*.zip
166+
ide-versions: |
167+
ideaIC:2020.1
168+
ideaIC:2020.2
169+
170+
# Print the output of the verify step
171+
- name: Print Logs
172+
if: ${{ always() }}
173+
env:
174+
OUTPUT_LOG: ${{ steps.verify.outputs.verification-output-log-filename }}
175+
run: |
176+
echo "The verifier log file [$OUTPUT_LOG] contents : " ;
177+
cat $OUTPUT_LOG
178+
179+
# Prepare a draft release for GitHub Releases page for the manual verification
180+
# If accepted and published, release workflow would be triggered
181+
releaseDraft:
182+
name: Release Draft
183+
if: github.event_name != 'pull_request'
184+
needs: [build, verify]
185+
runs-on: ubuntu-latest
186+
steps:
187+
188+
# Check out current repository
189+
- name: Fetch Sources
190+
uses: actions/checkout@v2
191+
with:
192+
submodules: true
193+
194+
# Remove old release drafts by using the curl request for the available releases with draft flag
195+
- name: Remove Old Release Drafts
196+
env:
197+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
198+
run: |
199+
curl -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
200+
| tr '\r\n' ' ' \
201+
| jq '.[] | select(.draft == true) | .id' \
202+
| xargs -I '{}' \
203+
curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases/{}
204+
205+
# Create new release draft - which is not publicly visible and requires manual acceptance
206+
- name: Create Release Draft
207+
id: createDraft
208+
uses: actions/create-release@v1
209+
env:
210+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
211+
with:
212+
tag_name: v${{ needs.build.outputs.version }}
213+
release_name: v${{ needs.build.outputs.version }}
214+
body: ${{ needs.build.outputs.changelog }}
215+
draft: true
216+
217+
# Download plugin artifact provided by the previous job
218+
- name: Download Artifact
219+
uses: actions/download-artifact@v1
220+
with:
221+
name: plugin-artifact
222+
223+
# Upload artifact as a release asset
224+
- name: Upload Release Asset
225+
id: upload-release-asset
226+
uses: actions/upload-release-asset@v1
227+
env:
228+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
229+
with:
230+
upload_url: ${{ steps.createDraft.outputs.upload_url }}
231+
asset_path: ./plugin-artifact/${{ needs.build.outputs.artifact }}
232+
asset_name: ${{ needs.build.outputs.artifact }}
233+
asset_content_type: application/zip

.github/workflows/release.yml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# GitHub Actions Workflow created for handling the release process based on the draft release prepared
2+
# with the Build workflow. Running the publishPlugin task requires the PUBLISH_TOKEN secret provided.
3+
4+
name: Release
5+
on:
6+
release:
7+
types: [prereleased, released]
8+
9+
jobs:
10+
11+
# Prepare and publish the plugin to the Marketplace repository
12+
release:
13+
name: Publish Plugin
14+
runs-on: ubuntu-latest
15+
steps:
16+
17+
# Setup Java 1.8 environment for the next steps
18+
- name: Setup Java
19+
uses: actions/setup-java@v1
20+
with:
21+
java-version: 1.8
22+
23+
# Check out current repository
24+
- name: Fetch Sources
25+
uses: actions/checkout@v2
26+
with:
27+
ref: ${{ github.event.release.tag_name }}
28+
29+
# Publish the plugin to the Marketplace
30+
- name: Publish Plugin
31+
env:
32+
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
33+
run: ./gradlew publishPlugin
34+
35+
# Patch changelog, commit and push to the current repository
36+
changelog:
37+
name: Update Changelog
38+
needs: release
39+
runs-on: ubuntu-latest
40+
steps:
41+
42+
# Setup Java 1.8 environment for the next steps
43+
- name: Setup Java
44+
uses: actions/setup-java@v1
45+
with:
46+
java-version: 1.8
47+
48+
# Check out current repository
49+
- name: Fetch Sources
50+
uses: actions/checkout@v2
51+
with:
52+
ref: ${{ github.event.release.tag_name }}
53+
54+
# Update Unreleased section with the current version
55+
- name: Patch Changelog
56+
run: ./gradlew patchChangelog
57+
58+
# Commit patched Changelog
59+
- name: Commit files
60+
run: |
61+
git config --local user.email "[email protected]"
62+
git config --local user.name "GitHub Action"
63+
git commit -m "Update changelog" -a
64+
# Push changes
65+
- name: Push changes
66+
uses: ad-m/github-push-action@master
67+
with:
68+
branch: main
69+
github_token: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
<!-- Keep a Changelog guide -> https://keepachangelog.com -->
22

3-
# Draw.io Integration Changelog
3+
# Changelog
4+
5+
## [Unreleased]
46

5-
## [0.0.1]
67
### Added
78
- MVP
9+
- load *.(drawio|dio)(.svg|.png|) in editor
10+
- support dark theme for darcula
11+
- autosave
12+
13+
## [0.1.0]

build.gradle.kts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import io.gitlab.arturbosch.detekt.Detekt
22
import org.jetbrains.changelog.closure
3+
import org.jetbrains.changelog.date
34
import org.jetbrains.changelog.markdownToHTML
45
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
56

@@ -11,7 +12,7 @@ plugins {
1112
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
1213
id("org.jetbrains.intellij") version "0.5.0"
1314
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
14-
id("org.jetbrains.changelog") version "0.5.0"
15+
id("org.jetbrains.changelog") version "0.6.2"
1516
// detekt linter - read more: https://detekt.github.io/detekt/gradle.html
1617
id("io.gitlab.arturbosch.detekt") version "1.13.1"
1718
// ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle
@@ -145,6 +146,16 @@ tasks {
145146
// https://jetbrains.org/intellij/sdk/docs/tutorials/build_system/deployment.html#specifying-a-release-channel
146147
channels(pluginVersion.split('-').getOrElse(1) { "default" }.split('.').first())
147148
}
149+
changelog {
150+
version = "${project.version}"
151+
path = "${project.projectDir}/CHANGELOG.md"
152+
header = closure { "[${project.version}] - ${date()}" }
153+
headerParserRegex = """\d+\.\d+\.\d+""".toRegex()
154+
itemPrefix = "-"
155+
keepUnreleasedSection = true
156+
unreleasedTerm = "[Unreleased]"
157+
groups = listOf("Added", "Changed", "Deprecated", "Removed", "Fixed", "Security")
158+
}
148159
}
149160

150161
tasks.test {

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pluginGroup = org.jetbrains.plugins.template
55
pluginName_ = Draw.io Integration
66
pluginVersion = 0.1.0
7-
pluginSinceBuild = 193
7+
pluginSinceBuild = 202
88
pluginUntilBuild = 202.*
99

1010
platformType = IC

gradlew

100644100755
File mode changed.

0 commit comments

Comments
 (0)