Skip to content

Commit d82b1f2

Browse files
committed
Add gradle based builds and continuous integration
1 parent db920ca commit d82b1f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1007
-184
lines changed

.github/dependabot.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Dependabot configuration:
2+
# https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates
3+
4+
version: 2
5+
updates:
6+
# Maintain dependencies for Gradle dependencies
7+
- package-ecosystem: "gradle"
8+
directory: "/"
9+
target-branch: "next"
10+
schedule:
11+
interval: "daily"
12+
# Maintain dependencies for GitHub Actions
13+
- package-ecosystem: "github-actions"
14+
directory: "/"
15+
target-branch: "next"
16+
schedule:
17+
interval: "daily"

.github/workflows/build.yml

+255
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
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:
18+
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
19+
push:
20+
branches: [main]
21+
# Trigger the workflow on any pull request
22+
pull_request:
23+
24+
jobs:
25+
26+
# Run Gradle Wrapper Validation Action to verify the wrapper's checksum
27+
gradleValidation:
28+
name: Gradle Wrapper
29+
runs-on: ubuntu-latest
30+
steps:
31+
32+
# Check out current repository
33+
- name: Fetch Sources
34+
uses: actions/[email protected]
35+
36+
# Validate wrapper
37+
- name: Gradle Wrapper Validation
38+
uses: gradle/[email protected]
39+
40+
# Run verifyPlugin and test Gradle tasks
41+
test:
42+
name: Test
43+
needs: gradleValidation
44+
runs-on: ubuntu-latest
45+
steps:
46+
47+
# Setup Java 1.8 environment for the next steps
48+
- name: Setup Java
49+
uses: actions/setup-java@v2
50+
with:
51+
distribution: zulu
52+
java-version: 8
53+
54+
# Check out current repository
55+
- name: Fetch Sources
56+
uses: actions/[email protected]
57+
58+
# Cache Gradle dependencies
59+
- name: Setup Gradle Dependencies Cache
60+
uses: actions/[email protected]
61+
with:
62+
path: ~/.gradle/caches
63+
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
64+
65+
# Cache Gradle Wrapper
66+
- name: Setup Gradle Wrapper Cache
67+
uses: actions/[email protected]
68+
with:
69+
path: ~/.gradle/wrapper
70+
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
71+
72+
# Run detekt, ktlint and tests
73+
- name: Run Linters and Test
74+
run: ./gradlew check
75+
76+
# Run verifyPlugin Gradle task
77+
- name: Verify Plugin
78+
run: ./gradlew verifyPlugin
79+
80+
# Build plugin with buildPlugin Gradle task and provide the artifact for the next workflow jobs
81+
# Requires test job to be passed
82+
build:
83+
name: Build
84+
needs: test
85+
runs-on: ubuntu-latest
86+
outputs:
87+
name: ${{ steps.properties.outputs.name }}
88+
version: ${{ steps.properties.outputs.version }}
89+
changelog: ${{ steps.properties.outputs.changelog }}
90+
artifact: ${{ steps.properties.outputs.artifact }}
91+
steps:
92+
93+
# Setup Java 1.8 environment for the next steps
94+
- name: Setup Java
95+
uses: actions/setup-java@v2
96+
with:
97+
distribution: zulu
98+
java-version: 8
99+
100+
# Check out current repository
101+
- name: Fetch Sources
102+
uses: actions/[email protected]
103+
104+
# Cache Gradle Dependencies
105+
- name: Setup Gradle Dependencies Cache
106+
uses: actions/[email protected]
107+
with:
108+
path: ~/.gradle/caches
109+
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
110+
111+
# Cache Gradle Wrapper
112+
- name: Setup Gradle Wrapper Cache
113+
uses: actions/[email protected]
114+
with:
115+
path: ~/.gradle/wrapper
116+
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
117+
118+
# Set environment variables
119+
- name: Export Properties
120+
id: properties
121+
shell: bash
122+
run: |
123+
PROPERTIES="$(./gradlew properties --console=plain -q)"
124+
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
125+
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
126+
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
127+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
128+
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
129+
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
130+
ARTIFACT="${NAME}-${VERSION}.zip"
131+
132+
echo "::set-output name=version::$VERSION"
133+
echo "::set-output name=name::$NAME"
134+
echo "::set-output name=changelog::$CHANGELOG"
135+
echo "::set-output name=artifact::$ARTIFACT"
136+
137+
# Build artifact using buildPlugin Gradle task
138+
- name: Build Plugin
139+
run: ./gradlew buildPlugin
140+
141+
# Upload plugin artifact to make it available in the next jobs
142+
- name: Upload artifact
143+
uses: actions/[email protected]
144+
with:
145+
name: plugin-artifact
146+
path: ./build/distributions/${{ steps.properties.outputs.artifact }}
147+
148+
# Verify built plugin using IntelliJ Plugin Verifier tool
149+
# Requires build job to be passed
150+
verify:
151+
name: Verify
152+
needs: build
153+
runs-on: ubuntu-latest
154+
steps:
155+
156+
# Setup Java 1.8 environment for the next steps
157+
- name: Setup Java
158+
uses: actions/setup-java@v2
159+
with:
160+
distribution: zulu
161+
java-version: 8
162+
163+
# Check out current repository
164+
- name: Fetch Sources
165+
uses: actions/[email protected]
166+
167+
# Cache Gradle Dependencies
168+
- name: Setup Gradle Dependencies Cache
169+
uses: actions/[email protected]
170+
with:
171+
path: ~/.gradle/caches
172+
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
173+
174+
# Cache Gradle Wrapper
175+
- name: Setup Gradle Wrapper Cache
176+
uses: actions/[email protected]
177+
with:
178+
path: ~/.gradle/wrapper
179+
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
180+
181+
# Set environment variables
182+
- name: Export Properties
183+
id: properties
184+
shell: bash
185+
run: |
186+
PROPERTIES="$(./gradlew properties --console=plain -q)"
187+
IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
188+
189+
echo "::set-output name=ideVersions::$IDE_VERSIONS"
190+
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
191+
192+
# Cache Plugin Verifier IDEs
193+
- name: Setup Plugin Verifier IDEs Cache
194+
uses: actions/[email protected]
195+
with:
196+
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
197+
key: ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }}
198+
199+
# Run IntelliJ Plugin Verifier action using GitHub Action
200+
- name: Verify Plugin
201+
run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
202+
203+
# Prepare a draft release for GitHub Releases page for the manual verification
204+
# If accepted and published, release workflow would be triggered
205+
releaseDraft:
206+
name: Release Draft
207+
if: github.event_name != 'pull_request'
208+
needs: [build, verify]
209+
runs-on: ubuntu-latest
210+
steps:
211+
212+
# Check out current repository
213+
- name: Fetch Sources
214+
uses: actions/[email protected]
215+
216+
# Remove old release drafts by using the curl request for the available releases with draft flag
217+
- name: Remove Old Release Drafts
218+
env:
219+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
220+
run: |
221+
curl -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
222+
| tr '\r\n' ' ' \
223+
| jq '.[] | select(.draft == true) | .id' \
224+
| xargs -I '{}' \
225+
curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases/{}
226+
227+
# Create new release draft - which is not publicly visible and requires manual acceptance
228+
- name: Create Release Draft
229+
id: createDraft
230+
uses: actions/[email protected]
231+
env:
232+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
233+
with:
234+
tag_name: v${{ needs.build.outputs.version }}
235+
release_name: v${{ needs.build.outputs.version }}
236+
body: ${{ needs.build.outputs.changelog }}
237+
draft: true
238+
239+
# Download plugin artifact provided by the previous job
240+
- name: Download Artifact
241+
uses: actions/download-artifact@v2
242+
with:
243+
name: plugin-artifact
244+
245+
# Upload artifact as a release asset
246+
- name: Upload Release Asset
247+
id: upload-release-asset
248+
uses: actions/[email protected]
249+
env:
250+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
251+
with:
252+
upload_url: ${{ steps.createDraft.outputs.upload_url }}
253+
asset_path: ./${{ needs.build.outputs.artifact }}
254+
asset_name: ${{ needs.build.outputs.artifact }}
255+
asset_content_type: application/zip

.github/workflows/release.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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@v2
20+
with:
21+
distribution: zulu
22+
java-version: 8
23+
24+
# Check out current repository
25+
- name: Fetch Sources
26+
uses: actions/[email protected]
27+
with:
28+
ref: ${{ github.event.release.tag_name }}
29+
30+
# Publish the plugin to the Marketplace
31+
- name: Publish Plugin
32+
env:
33+
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
34+
run: ./gradlew publishPlugin
35+
36+
# Patch changelog, commit and push to the current repository
37+
changelog:
38+
name: Update Changelog
39+
needs: release
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@v2
46+
with:
47+
distribution: zulu
48+
java-version: 8
49+
50+
# Check out current repository
51+
- name: Fetch Sources
52+
uses: actions/[email protected]
53+
with:
54+
ref: ${{ github.event.release.tag_name }}
55+
56+
# Update Unreleased section with the current version
57+
- name: Patch Changelog
58+
run: ./gradlew patchChangelog
59+
60+
# Commit patched Changelog
61+
- name: Commit files
62+
run: |
63+
git config --local user.email "[email protected]"
64+
git config --local user.name "GitHub Action"
65+
git commit -m "Update changelog" -a
66+
67+
# Push changes
68+
- name: Push changes
69+
uses: ad-m/github-push-action@master
70+
with:
71+
branch: main
72+
github_token: ${{ secrets.GITHUB_TOKEN }}

.run/Run IDE with Plugin.run.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Run Plugin" type="GradleRunConfiguration" factoryName="Gradle">
3+
<log_file alias="idea.log" path="$PROJECT_DIR$/build/idea-sandbox/system/log/idea.log" />
4+
<ExternalSystemSettings>
5+
<option name="executionName" />
6+
<option name="externalProjectPath" value="$PROJECT_DIR$" />
7+
<option name="externalSystemIdString" value="GRADLE" />
8+
<option name="scriptParameters" value="" />
9+
<option name="taskDescriptions">
10+
<list />
11+
</option>
12+
<option name="taskNames">
13+
<list>
14+
<option value="runIde" />
15+
</list>
16+
</option>
17+
<option name="vmOptions" value="" />
18+
</ExternalSystemSettings>
19+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
20+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
21+
<DebugAllEnabled>false</DebugAllEnabled>
22+
<method v="2" />
23+
</configuration>
24+
</component>

.run/Run Plugin Tests.run.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Run Tests" type="GradleRunConfiguration" factoryName="Gradle">
3+
<log_file alias="idea.log" path="$PROJECT_DIR$/build/idea-sandbox/system/log/idea.log" />
4+
<ExternalSystemSettings>
5+
<option name="executionName" />
6+
<option name="externalProjectPath" value="$PROJECT_DIR$" />
7+
<option name="externalSystemIdString" value="GRADLE" />
8+
<option name="scriptParameters" value="" />
9+
<option name="taskDescriptions">
10+
<list />
11+
</option>
12+
<option name="taskNames">
13+
<list>
14+
<option value="check" />
15+
</list>
16+
</option>
17+
<option name="vmOptions" value="" />
18+
</ExternalSystemSettings>
19+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
20+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
21+
<DebugAllEnabled>false</DebugAllEnabled>
22+
<method v="2" />
23+
</configuration>
24+
</component>

0 commit comments

Comments
 (0)