Skip to content

Commit 67ff0e7

Browse files
committed
Add changelog and workflows
1 parent 927043c commit 67ff0e7

File tree

9 files changed

+238
-8
lines changed

9 files changed

+238
-8
lines changed
File renamed without changes.
File renamed without changes.

.github/workflows/build.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Build
2+
on:
3+
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
4+
push:
5+
branches: [ main ]
6+
# Trigger the workflow on any pull request
7+
pull_request:
8+
9+
jobs:
10+
11+
# Run Gradle Wrapper Validation Action to verify the wrapper's checksum
12+
# Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks
13+
# Build plugin and provide the artifact for the next workflow jobs
14+
build:
15+
name: Build
16+
runs-on: ubuntu-latest
17+
outputs:
18+
version: ${{ steps.properties.outputs.version }}
19+
changelog: ${{ steps.properties.outputs.changelog }}
20+
steps:
21+
22+
# Check out current repository
23+
- name: Fetch Sources
24+
uses: actions/checkout@v2.4.0
25+
26+
# Validate wrapper
27+
- name: Gradle Wrapper Validation
28+
uses: gradle/wrapper-validation-action@v1.0.4
29+
30+
# Setup Java 11 environment for the next steps
31+
- name: Setup Java
32+
uses: actions/setup-java@v2
33+
with:
34+
distribution: zulu
35+
java-version: 11
36+
cache: gradle
37+
38+
# Set environment variables
39+
- name: Export Properties
40+
id: properties
41+
shell: bash
42+
run: |
43+
PROPERTIES="$(./gradlew properties --console=plain -q)"
44+
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
45+
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
46+
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
47+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
48+
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
49+
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
50+
echo "::set-output name=version::$VERSION"
51+
echo "::set-output name=name::$NAME"
52+
echo "::set-output name=changelog::$CHANGELOG"
53+
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
54+
./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
55+
56+
# Cache Plugin Verifier IDEs
57+
- name: Setup Plugin Verifier IDEs Cache
58+
uses: actions/cache@v2.1.7
59+
with:
60+
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
61+
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
62+
63+
# Run Verify Plugin task and IntelliJ Plugin Verifier tool
64+
- name: Run Plugin Verification tasks
65+
run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
66+
67+
# Collect Plugin Verifier Result
68+
- name: Collect Plugin Verifier Result
69+
if: ${{ always() }}
70+
uses: actions/upload-artifact@v2
71+
with:
72+
name: pluginVerifier-result
73+
path: ${{ github.workspace }}/build/reports/pluginVerifier
74+
75+
# Prepare plugin archive content for creating artifact
76+
- name: Prepare Plugin Artifact
77+
id: artifact
78+
shell: bash
79+
run: |
80+
cd ${{ github.workspace }}/build/distributions
81+
FILENAME=`ls *.zip`
82+
unzip "$FILENAME" -d content
83+
echo "::set-output name=filename::${FILENAME:0:-4}"
84+
# Store already-built plugin as an artifact for downloading
85+
- name: Upload artifact
86+
uses: actions/upload-artifact@v2.2.4
87+
with:
88+
name: ${{ steps.artifact.outputs.filename }}
89+
path: ./build/distributions/content/*/*
90+
91+
# Prepare a draft release for GitHub Releases page for the manual verification
92+
# If accepted and published, release workflow would be triggered
93+
releaseDraft:
94+
name: Release Draft
95+
if: github.event_name != 'pull_request'
96+
needs: build
97+
runs-on: ubuntu-latest
98+
steps:
99+
100+
# Check out current repository
101+
- name: Fetch Sources
102+
uses: actions/checkout@v2.4.0
103+
104+
# Remove old release drafts by using the curl request for the available releases with draft flag
105+
- name: Remove Old Release Drafts
106+
env:
107+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108+
run: |
109+
gh api repos/{owner}/{repo}/releases \
110+
--jq '.[] | select(.draft == true) | .id' \
111+
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
112+
# Create new release draft - which is not publicly visible and requires manual acceptance
113+
- name: Create Release Draft
114+
env:
115+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
run: |
117+
gh release create v${{ needs.build.outputs.version }} \
118+
--draft \
119+
--title "v${{ needs.build.outputs.version }}" \
120+
--notes "$(cat << 'EOM'
121+
${{ needs.build.outputs.changelog }}
122+
EOM
123+
)"

.github/workflows/release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Release
2+
on:
3+
release:
4+
types: [ prereleased, released ]
5+
6+
jobs:
7+
8+
# Prepare and publish the plugin to the Marketplace repository
9+
release:
10+
name: Publish Plugin
11+
runs-on: ubuntu-latest
12+
steps:
13+
14+
# Check out current repository
15+
- name: Fetch Sources
16+
uses: actions/checkout@v2.4.0
17+
with:
18+
ref: ${{ github.event.release.tag_name }}
19+
20+
# Setup Java 11 environment for the next steps
21+
- name: Setup Java
22+
uses: actions/setup-java@v2
23+
with:
24+
distribution: zulu
25+
java-version: 11
26+
cache: gradle
27+
28+
# Set environment variables
29+
- name: Export Properties
30+
id: properties
31+
shell: bash
32+
run: |
33+
CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d'
34+
${{ github.event.release.body }}
35+
EOM
36+
)"
37+
38+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
39+
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
40+
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
41+
echo "::set-output name=changelog::$CHANGELOG"
42+
# Update Unreleased section with the current release note
43+
- name: Patch Changelog
44+
if: ${{ steps.properties.outputs.changelog != '' }}
45+
env:
46+
CHANGELOG: ${{ steps.properties.outputs.changelog }}
47+
run: |
48+
./gradlew patchChangelog --release-note="$CHANGELOG"
49+
# Publish the plugin to the Marketplace
50+
- name: Publish Plugin
51+
env:
52+
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
53+
run: ./gradlew publishPlugin
54+
55+
# Upload artifact as a release asset
56+
- name: Upload Release Asset
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
60+
61+
# Create pull request
62+
- name: Create Pull Request
63+
if: ${{ steps.properties.outputs.changelog != '' }}
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
run: |
67+
VERSION="${{ github.event.release.tag_name }}"
68+
BRANCH="changelog-update-$VERSION"
69+
git config user.email "action@github.com"
70+
git config user.name "GitHub Action"
71+
git checkout -b $BRANCH
72+
git commit -am "Changelog update - $VERSION"
73+
git push --set-upstream origin $BRANCH
74+
gh pr create \
75+
--title "Changelog update - \`$VERSION\`" \
76+
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
77+
--base main \
78+
--head $BRANCH

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## [Unreleased]
4+
### Added
5+
- Initial plugin release

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
44

5-
This plugin _(quite decently)_ implements inlay parameter hints support for <b>Python</b>.
5+
<!-- Plugin description -->
6+
This plugin _(quite decently)_ implements inlay parameter hints for **Python**.
67

78
## Supported expressions
89

@@ -12,6 +13,7 @@ Pretty much any expression is supported:
1213
* decorators
1314
* function calls
1415
* etc.
16+
<!-- Plugin description end -->
1517

1618
**Look at the examples below to see how it works.**
1719

@@ -23,6 +25,6 @@ The plugin can be disabled anytime in IDE settings:
2325

2426
## Demo Screenshots
2527

26-
![](./images/func_example.png)
28+
![](.github/readme/func_example.png)
2729

28-
![](./images/class_example.png)
30+
![](.github/readme/class_example.png)

build.gradle.kts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import org.jetbrains.changelog.date
2+
import org.jetbrains.changelog.markdownToHTML
13
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
24

35
fun properties(key: String) = project.findProperty(key).toString()
46

57
plugins {
68
id("org.jetbrains.kotlin.jvm") version "1.6.20"
79
id("org.jetbrains.intellij") version "1.7.0"
10+
id("org.jetbrains.changelog") version "1.3.1"
811
}
912

1013
group = properties("pluginGroup")
@@ -22,6 +25,12 @@ intellij {
2225
plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
2326
}
2427

28+
changelog {
29+
version.set(properties("pluginVersion"))
30+
header.set(provider { "[${version.get()}] - ${date()}" })
31+
groups.set(listOf("Added", "Changed", "Fixed"))
32+
}
33+
2534
tasks {
2635
// Set the JVM compatibility versions
2736
properties("javaVersion").let {
@@ -42,6 +51,24 @@ tasks {
4251
version.set(properties("pluginVersion"))
4352
sinceBuild.set(properties("pluginSinceBuild"))
4453
untilBuild.set(properties("pluginUntilBuild"))
54+
55+
changeNotes.set(provider {
56+
changelog.run {
57+
getOrNull(properties("pluginVersion")) ?: getLatest()
58+
}.toHTML()
59+
})
60+
61+
pluginDescription.set(
62+
projectDir.resolve("README.md").readText().lines().run {
63+
val start = "<!-- Plugin description -->"
64+
val end = "<!-- Plugin description end -->"
65+
66+
if (!containsAll(listOf(start, end))) {
67+
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
68+
}
69+
subList(indexOf(start) + 1, indexOf(end))
70+
}.joinToString("\n").run { markdownToHTML(this) }
71+
)
4572
}
4673

4774
signPlugin {

gradlew

100644100755
File mode changed.

src/main/resources/META-INF/plugin.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
<name>Python Inlay Params</name>
55
<vendor>WhiteMemory99</vendor>
66

7-
<description><![CDATA[
8-
This plugin adds inlay parameter hints support for <b>Python</b>.
9-
It was infuriating to see this feature missing, so let's fix that!
10-
]]></description>
11-
127
<depends>com.intellij.modules.lang</depends>
138
<depends>com.intellij.modules.python</depends>
149
<depends>com.intellij.modules.platform</depends>

0 commit comments

Comments
 (0)