Skip to content

Commit 4f7f808

Browse files
authored
Ci workflows (#117)
* ci workflows
1 parent e5c8eba commit 4f7f808

File tree

12 files changed

+157
-72
lines changed

12 files changed

+157
-72
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,19 @@
1313
## JBIJPPTPL (Jetbrains intellij platform plugin template)
1414

1515

16-
name: Build
16+
name: Build, Verify and Prepare Release
1717
on:
1818
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
1919
push:
2020
branches: [ main ]
21-
# Trigger the workflow on any pull request
22-
# pull_request:
23-
# branches: [ main ]
2421

2522
jobs:
2623

27-
#todo: java matrix , os matrix
28-
2924
# Run Gradle Wrapper Validation Action to verify the wrapper's checksum
3025
# Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks
3126
# Build plugin and provide the artifact for the next workflow jobs
3227
build:
33-
name: Build
28+
name: Build and Verify
3429
runs-on: ubuntu-latest
3530
outputs:
3631
version: ${{ steps.properties.outputs.version }}
@@ -59,13 +54,8 @@ jobs:
5954
uses: gradle/[email protected]
6055

6156
# Set environment variables
62-
# the original template feeds the whole changelog history to the release draft. we don't need it,
63-
# and we don't keep a changelog file in the repository
64-
# CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
65-
# CHANGELOG="${CHANGELOG//'%'/'%25'}"
66-
# CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
67-
# CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
68-
# echo "::set-output name=changelog::$CHANGELOG"
57+
# the original jetbrains template feeds the whole changelog history to the release draft. we don't need it,
58+
# we keep an empty CHANGELOG.md file in the repository used only to patch plugin.xml in the publish workflow.
6959
- name: Export Properties
7060
id: properties
7161
shell: bash
@@ -78,7 +68,7 @@ jobs:
7868
echo "::set-output name=name::$NAME"
7969
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
8070
81-
./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
71+
./gradlew listProductsReleases -q # prepare list of IDEs for Plugin Verifier
8272
8373
# Run tests
8474
- name: Run Tests
@@ -138,7 +128,7 @@ jobs:
138128
# Prepare a draft release for GitHub Releases page for the manual verification
139129
# If accepted and published, release workflow would be triggered
140130
releaseDraft:
141-
name: Release Draft
131+
name: Prepare Release Draft
142132
if: github.event_name != 'pull_request'
143133
needs: build
144134
runs-on: ubuntu-latest

.github/workflows/gradle-ci-pr.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
7+
8+
name: CI Build and Upload plugin on pull request to main
9+
10+
on:
11+
pull_request:
12+
branches: [ main ]
13+
14+
jobs:
15+
build:
16+
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- name: Set up JDK 11
23+
uses: actions/setup-java@v3
24+
with:
25+
java-version: '11'
26+
distribution: 'corretto'
27+
28+
- name: Setup dotnet
29+
uses: actions/setup-dotnet@v2
30+
with:
31+
dotnet-version: |
32+
6.0.102
33+
- name: Validate Gradle wrapper
34+
uses: gradle/[email protected]
35+
36+
- name: Build with Gradle
37+
uses: gradle/[email protected]
38+
with:
39+
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
40+
arguments: buildPlugin runPluginVerifier --no-daemon
41+
42+
- name: Prepare Plugin Artifact
43+
id: artifact
44+
shell: bash
45+
run: |
46+
cd ${{ github.workspace }}/build/distributions
47+
FILENAME=`ls *.zip`
48+
unzip "$FILENAME" -d content
49+
echo "::set-output name=filename::${FILENAME:0:-4}"
50+
51+
- name: Upload Artifact
52+
uses: actions/upload-artifact@v3
53+
with:
54+
name: ${{ steps.artifact.outputs.filename }}
55+
path: ./build/distributions/content/*/*
56+
retention-days: 5
57+
58+
# Collect Tests Result of failed tests
59+
##todo: add other modules test reports
60+
- name: Collect Tests Result
61+
if: ${{ failure() }}
62+
uses: actions/upload-artifact@v3
63+
with:
64+
name: tests-result
65+
path: ${{ github.workspace }}/ide-common/build/reports/tests
66+
retention-days: 5

.github/workflows/gradle-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
66
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
77

8-
name: CI Build and Upload plugin all branches
8+
name: CI Build and Upload plugin all branches (!main)
99

1010
on:
1111
push:
1212
branches: [ '**','!main' ]
13-
pull_request:
14-
branches: [ main ]
1513

1614
jobs:
1715
build:
@@ -59,6 +57,7 @@ jobs:
5957
with:
6058
name: ${{ steps.artifact.outputs.filename }}
6159
path: ./build/distributions/content/*/*
60+
retention-days: 5
6261

6362
# Collect Tests Result of failed tests
6463
##todo: add other modules test reports
@@ -68,3 +67,4 @@ jobs:
6867
with:
6968
name: tests-result
7069
path: ${{ github.workspace }}/ide-common/build/reports/tests
70+
retention-days: 5

.github/workflows/multi-java-build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@
55
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
66
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
77

8-
name: Multi Java CI Build
8+
name: Multi Java CI Build on main
99

1010
on:
1111
push:
1212
branches: [ 'main' ]
13+
pull_request:
14+
branches: [ 'main' ]
1315

1416
jobs:
1517
build:
1618
runs-on: ubuntu-latest
1719
strategy:
1820
matrix:
1921
java: [ '11', '17' ]
20-
name: Java ${{ matrix.Java }} sample
22+
name: Java ${{ matrix.Java }} build
2123

2224
steps:
2325
- uses: actions/checkout@v3

.github/workflows/multi-os-build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
66
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
77

8-
name: Multi OS CI Build
8+
name: Multi OS CI Build on main
99

1010
on:
1111
push:
1212
branches: [ 'main' ]
13+
pull_request:
14+
branches: [ 'main' ]
1315

1416
jobs:
1517
build:
Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
# with the Build workflow. Running the publishPlugin task requires the PUBLISH_TOKEN secret provided.
33

44

5-
name: Release
5+
name: Publish to jetbrains marketplace
66
on:
77
release:
88
types: [prereleased, released]
99

1010
jobs:
1111

1212
# Prepare and publish the plugin to the Marketplace repository
13-
release:
13+
publish:
1414
name: Publish Plugin
1515
runs-on: ubuntu-latest
1616
steps:
@@ -76,24 +76,27 @@ jobs:
7676
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7777
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
7878

79-
# Create pull request
80-
# - name: Create Pull Request
81-
# if: ${{ steps.properties.outputs.changelog != '' }}
82-
# env:
83-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84-
# run: |
85-
# VERSION="${{ github.event.release.tag_name }}"
86-
# BRANCH="changelog-update-$VERSION"
87-
#
88-
# git config user.email "[email protected]"
89-
# git config user.name "GitHub Action"
90-
#
91-
# git checkout -b $BRANCH
92-
# git commit -am "Changelog update - $VERSION"
93-
# git push --set-upstream origin $BRANCH
94-
#
95-
# gh pr create \
96-
# --title "Changelog update - \`$VERSION\`" \
97-
# --body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
98-
# --base main \
99-
# --head $BRANCH
79+
80+
- name: Revert changelog file and untracked files
81+
run: |
82+
git reset --hard HEAD
83+
git clean -fd
84+
./gradlew clean
85+
86+
- name: Checkout main branch
87+
uses: actions/checkout@v3
88+
with:
89+
ref: main
90+
91+
- name: Increment version
92+
run: |
93+
./gradlew incrementSemanticVersion
94+
./gradlew printVersion -q
95+
96+
- name: Commit next version to main
97+
run: |
98+
git config user.name github-actions
99+
git config user.email [email protected]
100+
git add version.properties
101+
git commit -m "increment next version after publish"
102+
git push

CHANGELOG.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
# Changelog
22

33
## [Unreleased]
4-
5-
- Example item
6-

build.gradle.kts

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ intellij {
4444

4545
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
4646
changelog {
47-
version.set(properties("pluginVersion"))
47+
version.set(project.semanticVersion.version.get().toString())
4848
path.set("${project.projectDir}/CHANGELOG.md")
4949
//groups.set(listOf("Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"))
5050
groups.set(emptyList())
@@ -64,7 +64,7 @@ qodana {
6464

6565
project.afterEvaluate{
6666
//the final plugin distribution is packaged from the sandbox.
67-
//So,make all the sub projects buildPlugin task run before this project's buildPlugin.
67+
//So,make all the subprojects buildPlugin task run before this project's buildPlugin.
6868
//that will make sure that their prepareSandbox task runs before building the plugin coz
6969
//maybe they contribute something to the sandbox.
7070
//currently, only rider contributes the dotnet dll's to the sandbox.
@@ -81,8 +81,12 @@ project.afterEvaluate{
8181

8282
tasks {
8383

84+
incrementSemanticVersion {
85+
//enable the SemanticVersion only for this module
86+
enabled = true
87+
}
8488

85-
jar{
89+
jar {
8690
dependsOn(":rider:copyKotlinModuleFile")
8791
}
8892

@@ -93,27 +97,27 @@ tasks {
9397
}
9498

9599
patchPluginXml {
96-
version.set(properties("pluginVersion"))
100+
version.set(project.semanticVersion.version.get().toString())
97101
sinceBuild.set(properties("pluginSinceBuild"))
98102
untilBuild.set(properties("pluginUntilBuild"))
99103

100104
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
101105
pluginDescription.set(
102-
projectDir.resolve("README.md").readText().lines().run {
103-
val start = "<!-- Plugin description -->"
104-
val end = "<!-- Plugin description end -->"
105-
106-
if (!containsAll(listOf(start, end))) {
107-
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
108-
}
109-
subList(indexOf(start) + 1, indexOf(end))
110-
}.joinToString("\n").run { markdownToHTML(this) }
106+
projectDir.resolve("README.md").readText().lines().run {
107+
val start = "<!-- Plugin description -->"
108+
val end = "<!-- Plugin description end -->"
109+
110+
if (!containsAll(listOf(start, end))) {
111+
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
112+
}
113+
subList(indexOf(start) + 1, indexOf(end))
114+
}.joinToString("\n").run { markdownToHTML(this) }
111115
)
112116

113117
// Get the latest available change notes from the changelog file
114118
changeNotes.set(provider {
115119
changelog.run {
116-
getOrNull(properties("pluginVersion")) ?: getLatest()
120+
getOrNull(project.semanticVersion.version.get().toString()) ?: getLatest()
117121
}.toHTML()
118122
})
119123
}
@@ -177,22 +181,30 @@ tasks {
177181

178182
signPlugin {
179183
if (System.getenv("DIGMA_JB_PRIVATE_KEY_PASSWORD") != null) {
180-
certificateChainFile.set(file(System.getenv("DIGMA_JB_CERTIFICATE_CHAIN_FILE")))
181-
privateKeyFile.set(file(System.getenv("DIGMA_JB_PRIVATE_KEY_FILE")))
182-
password.set(System.getenv("DIGMA_JB_PRIVATE_KEY_PASSWORD"))
184+
certificateChain.set(System.getenv("DIGMA_JB_CERTIFICATE_CHAIN_FILE").trimIndent())
185+
privateKey.set(System.getenv("DIGMA_JB_PRIVATE_KEY_FILE").trimIndent())
186+
password.set(System.getenv("DIGMA_JB_PRIVATE_KEY_PASSWORD").trim())
183187
}
184188
}
185189

186190

187191
publishPlugin {
188192
if (System.getenv("PUBLISH_TOKEN") != null) {
189-
token.set(System.getenv("PUBLISH_TOKEN"))
193+
token.set(System.getenv("PUBLISH_TOKEN").trim())
190194
}
191195

192-
// pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
196+
// the version is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
193197
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
194198
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
195-
channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first()))
199+
channels.set(listOf(project.semanticVersion.version.get().toString().split('-').getOrElse(1) { "default" }
200+
.split('.').first()))
201+
}
202+
203+
204+
create("printVersion", DefaultTask::class.java) {
205+
doLast {
206+
println("The project current version is ${project.semanticVersion.version.get()}")
207+
}
196208
}
197209

198210
}

buildSrc/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies {
1515
implementation("org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.5.2")
1616
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21")
1717
implementation("com.dorongold.plugins:task-tree:2.1.0")
18+
implementation("com.glovoapp.semantic-versioning:com.glovoapp.semantic-versioning.gradle.plugin:1.1.10")
1819
}
1920

2021

0 commit comments

Comments
 (0)