mirror of
https://github.com/JetBrains/intellij-platform-plugin-template.git
synced 2024-10-27 20:44:05 +00:00
GitHub Actions - template cleanup workflow
This commit is contained in:
parent
9cd83d4719
commit
e4a1106495
BIN
.github/readme/getting-started_use-this-template.png
vendored
Normal file
BIN
.github/readme/getting-started_use-this-template.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 74 KiB |
7
.github/template-cleanup/CHANGELOG.md
vendored
Normal file
7
.github/template-cleanup/CHANGELOG.md
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<!-- Keep a Changelog guide -> https://keepachangelog.com -->
|
||||||
|
|
||||||
|
# %NAME% Changelog
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
### Added
|
||||||
|
- Initial scaffold created from [IntelliJ Plugin Template](https://github.com/JetBrains/intellij-plugin-template)
|
28
.github/template-cleanup/README.md
vendored
Normal file
28
.github/template-cleanup/README.md
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# %NAME%
|
||||||
|
|
||||||
|
![Build](https://github.com/hsz/intellij-plugin-template/workflows/Build/badge.svg)
|
||||||
|
|
||||||
|
<!-- Plugin description -->
|
||||||
|
This Fancy IntelliJ Plugin is going to be your implementation of the brilliant ideas that you have.
|
||||||
|
|
||||||
|
This specific section is a source for the [plugin.xml](./src/main/resources/META-INF/plugin.xml) file which will be
|
||||||
|
extracted by the [Gradle](./build.gradle.kts) during the build process.
|
||||||
|
|
||||||
|
To keep everything working, do not remove `<!-- ... -->` sections.
|
||||||
|
<!-- Plugin description end -->
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
- Using IDE built-in plugin system:
|
||||||
|
|
||||||
|
<kbd>Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>Marketplace</kbd> > <kbd>Search for "%NAME%"</kbd> >
|
||||||
|
<kbd>Install Plugin</kbd>
|
||||||
|
|
||||||
|
- Manually:
|
||||||
|
|
||||||
|
Download the [latest release](https://github.com/%REPOSITORY%/releases/latest) and install it manually using
|
||||||
|
<kbd>Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>⚙️</kbd> > <kbd>Install plugin from disk...</kbd>
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
Plugin based on the [IntelliJ Plugin Template](https://github.com/JetBrains/intellij-plugin-template).
|
14
.github/workflows/build.yml
vendored
14
.github/workflows/build.yml
vendored
@ -1,9 +1,11 @@
|
|||||||
# GitHub Actions Workflow created for testing the plugin in three steps:
|
# GitHub Actions Workflow created for testing and preparing the plugin release in following steps:
|
||||||
# - test using Gradle tasks, such as tes and verifyPlugin,
|
# - validate Gradle Wrapper,
|
||||||
# - test building process by preparing the artifact using buildPlugin Gradle task,
|
# - run test and verifyPlugin tasks,
|
||||||
# - run IntelliJ Plugin Verifier.
|
# - run buildPlugin task and prepare artifact for the further tests,
|
||||||
|
# - run IntelliJ Plugin Verifier,
|
||||||
|
# - create a draft release.
|
||||||
#
|
#
|
||||||
# Workflow is triggered on push or pull request event.
|
# Workflow is triggered on push and pull_request events.
|
||||||
#
|
#
|
||||||
# Docs:
|
# Docs:
|
||||||
# - GitHub Actions: https://help.github.com/en/actions
|
# - GitHub Actions: https://help.github.com/en/actions
|
||||||
@ -156,7 +158,7 @@ jobs:
|
|||||||
# If accepted and published, release workflow would be triggered.
|
# If accepted and published, release workflow would be triggered.
|
||||||
releaseDraft:
|
releaseDraft:
|
||||||
name: Release Draft
|
name: Release Draft
|
||||||
# if: github.ref == 'refs/heads/master'
|
if: github.ref == 'refs/heads/master'
|
||||||
needs: [build, verify]
|
needs: [build, verify]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
3
.github/workflows/release.yml
vendored
3
.github/workflows/release.yml
vendored
@ -1,3 +1,6 @@
|
|||||||
|
# GitHub Actions Workflow created for handling the release process based on the draft release prepared
|
||||||
|
# with the Build workflow. Running the publishPlugin task requires the PUBLISH_TOKEN secret provided.
|
||||||
|
|
||||||
name: Release
|
name: Release
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
|
67
.github/workflows/template-cleanup.yml
vendored
Normal file
67
.github/workflows/template-cleanup.yml
vendored
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# GitHub Actions Workflow responsible for cleaning up the IntelliJ Plugin Template repository from
|
||||||
|
# the template-specific files and configurations. This workflow is supposed to be triggered automatically
|
||||||
|
# when a new template-based repository has been created.
|
||||||
|
|
||||||
|
name: Tempalte Cleanup
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
# Run cleaning process only if workflow is triggered by the non-JetBrains/intellij-plugin-template repository.
|
||||||
|
template-cleanup:
|
||||||
|
name: Template Cleanup
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.repository != 'JetBrains/intellij-plugin-template'
|
||||||
|
steps:
|
||||||
|
|
||||||
|
# Check out current repository
|
||||||
|
- name: Fetch Sources
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# Cleanup project
|
||||||
|
- name: Cleanup
|
||||||
|
run: |
|
||||||
|
export LC_CTYPE=C
|
||||||
|
export LANG=C
|
||||||
|
|
||||||
|
# Prepare variables
|
||||||
|
NAME="${GITHUB_REPOSITORY##*/}"
|
||||||
|
SAFE_NAME=$(echo $NAME | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
|
||||||
|
ACTOR=$(echo $GITHUB_ACTOR | tr '[:upper:]' '[:lower:]')
|
||||||
|
GROUP="com.github.$ACTOR.$SAFE_NAME"
|
||||||
|
|
||||||
|
# Replace placeholders in the template-cleanup files
|
||||||
|
sed -i '' "s/%NAME%/$NAME/g" .github/template-cleanup/*
|
||||||
|
sed -i '' "s/%REPOSITORY%/${GITHUB_REPOSITORY/\//\\/}/g" .github/template-cleanup/*
|
||||||
|
sed -i '' "s/%GROUP%/$GROUP/g" .github/template-cleanup/*
|
||||||
|
|
||||||
|
# Replace template package name in project files with $GROUP
|
||||||
|
sed -i '' "s/org.jetbrains.plugins.template/$GROUP/g" gradle.properties
|
||||||
|
find . -type f -exec sed -i '' "s/org.jetbrains.plugins.template/$GROUP/g" {} +
|
||||||
|
|
||||||
|
# Move content
|
||||||
|
mkdir -p src/main/kotlin/${GROUP//.//}
|
||||||
|
cp -R .github/template-cleanup/* .
|
||||||
|
cp -R src/main/kotlin/org/jetbrains/plugins/template/* src/main/kotlin/${GROUP//.//}/
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
rm -rf .github/readme
|
||||||
|
rm -rf .github/template-cleanup
|
||||||
|
rm -rf src/main/kotlin/org
|
||||||
|
rm .github/workflows/template-cleanup.yml
|
||||||
|
|
||||||
|
# Commit modified files
|
||||||
|
- name: Commit files
|
||||||
|
run: |
|
||||||
|
git config --local user.email "action@github.com"
|
||||||
|
git config --local user.name "GitHub Action"
|
||||||
|
git commit -m "Template cleanup" -a
|
||||||
|
|
||||||
|
# Push changes
|
||||||
|
- name: Push changes
|
||||||
|
uses: ad-m/github-push-action@master
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
38
README.md
38
README.md
@ -3,13 +3,15 @@
|
|||||||
[![official JetBrains project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
|
[![official JetBrains project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
|
||||||
![Build](https://github.com/hsz/intellij-plugin-template/workflows/Build/badge.svg)
|
![Build](https://github.com/hsz/intellij-plugin-template/workflows/Build/badge.svg)
|
||||||
|
|
||||||
IntelliJ Plugin Template is a repository that provides a pure boilerplate for creating a plugin project with ease
|
<!-- Plugin description -->
|
||||||
designed as a GitHub template repository (check the [Creating a repository from a template][gh-template] article).
|
**IntelliJ Plugin Template** is a repository that provides a pure boilerplate for creating a plugin project with ease
|
||||||
|
designed as a **GitHub Template Repository** (check the [Creating a repository from a template][gh-template] article).
|
||||||
The main goal for this Template is to speed up the setup phase of the plugin development for the new as well as existing
|
The main goal for this Template is to speed up the setup phase of the plugin development for the new as well as existing
|
||||||
developers by preconfiguring the project scaffold, CI and linking to the proper documentation pages as well as keeping
|
developers by preconfiguring the project scaffold, CI and linking to the proper documentation pages and keeping
|
||||||
everything in the most straightforward manner.
|
everything in the most straightforward manner.
|
||||||
|
<!-- Plugin description end -->
|
||||||
|
|
||||||
We can detail here the following parts:
|
We can highlight here the following parts:
|
||||||
|
|
||||||
- Gradle configuration
|
- Gradle configuration
|
||||||
- Sample code:
|
- Sample code:
|
||||||
@ -21,9 +23,21 @@ We can detail here the following parts:
|
|||||||
- CI based on GitHub actions
|
- CI based on GitHub actions
|
||||||
- Release and changelog maintenance flow
|
- Release and changelog maintenance flow
|
||||||
|
|
||||||
## Getting started
|
## Getting Started
|
||||||
|
|
||||||
TODO
|
Before diving into the plugin development and everything that happens around, it is worth mentioning the fundamental
|
||||||
|
idea behind the GitHub Templates: by creating a new project using the current template, you start with no history
|
||||||
|
and no reference to this repository - it is the cut corner for creating a new repository with copy-pasting the content
|
||||||
|
or cloning repositories and clearing the history by your own.
|
||||||
|
|
||||||
|
The only thing that you have to do is clicking the **Use this template** button.
|
||||||
|
|
||||||
|
![Use this template][file:getting-started_use-this-template.png]
|
||||||
|
|
||||||
|
After creating your blank project from the template, there will be the [Template Cleanup][file:template_cleanup.yml]
|
||||||
|
workflow triggered to override or remove template-specific configuration, like plugin name, current changelog, etc.
|
||||||
|
|
||||||
|
As a last step, it is required to manually specify the `pluginName` and `pluginGroup` in the `gradle.properties` file.
|
||||||
|
|
||||||
## Gradle
|
## Gradle
|
||||||
|
|
||||||
@ -39,7 +53,10 @@ TODO
|
|||||||
|
|
||||||
## Continuous Integration
|
## Continuous Integration
|
||||||
|
|
||||||
TODO
|
Unit tests
|
||||||
|
Detekt
|
||||||
|
verifyPlugin
|
||||||
|
intellij-plugin-verifier
|
||||||
|
|
||||||
## Release Flow
|
## Release Flow
|
||||||
|
|
||||||
@ -55,6 +72,10 @@ and inside of the Plugin Manager's item details.
|
|||||||
There are many different methods of handling the project's changelog. One of them, used in the current template project,
|
There are many different methods of handling the project's changelog. One of them, used in the current template project,
|
||||||
is the [Keep a Changelog][keep-a-changelog] approach.
|
is the [Keep a Changelog][keep-a-changelog] approach.
|
||||||
|
|
||||||
|
# Publishing Plugin
|
||||||
|
|
||||||
|
Cannot find org.jetbrains.plugins.template. Note that you need to upload the plugin to the repository at least once manually (to specify options like the license, repository URL etc.). Follow the instructions: https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/publishing_plugin.html
|
||||||
|
|
||||||
## Useful Links
|
## Useful Links
|
||||||
|
|
||||||
- [IntelliJ Platform SDK DevGuide][sdk-docs]
|
- [IntelliJ Platform SDK DevGuide][sdk-docs]
|
||||||
@ -73,3 +94,6 @@ is the [Keep a Changelog][keep-a-changelog] approach.
|
|||||||
[slack]: https://plugins.jetbrains.com/slack
|
[slack]: https://plugins.jetbrains.com/slack
|
||||||
[forum]: https://intellij-support.jetbrains.com/hc/en-us/community/topics/200366979-IntelliJ-IDEA-Open-API-and-Plugin-Development
|
[forum]: https://intellij-support.jetbrains.com/hc/en-us/community/topics/200366979-IntelliJ-IDEA-Open-API-and-Plugin-Development
|
||||||
[keep-a-changelog]: https://keepachangelog.com
|
[keep-a-changelog]: https://keepachangelog.com
|
||||||
|
|
||||||
|
[file:getting-started_use-this-template.png]: ./.github/readme/getting-started_use-this-template.png
|
||||||
|
[file:template_cleanup.yml]: ./.github/workflows/template-cleanup.yml
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import io.gitlab.arturbosch.detekt.Detekt
|
import io.gitlab.arturbosch.detekt.Detekt
|
||||||
import org.jetbrains.changelog.closure
|
import org.jetbrains.changelog.closure
|
||||||
|
import org.jetbrains.changelog.markdownToHTML
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
@ -10,7 +11,7 @@ plugins {
|
|||||||
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
|
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
|
||||||
id("org.jetbrains.intellij") version "0.4.21"
|
id("org.jetbrains.intellij") version "0.4.21"
|
||||||
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
|
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
|
||||||
id("org.jetbrains.changelog") version "0.3.1"
|
id("org.jetbrains.changelog") version "0.3.2"
|
||||||
// detekt linter - read more: https://detekt.github.io/detekt/kotlindsl.html
|
// detekt linter - read more: https://detekt.github.io/detekt/kotlindsl.html
|
||||||
id("io.gitlab.arturbosch.detekt") version "1.10.0-RC1"
|
id("io.gitlab.arturbosch.detekt") version "1.10.0-RC1"
|
||||||
}
|
}
|
||||||
@ -82,6 +83,15 @@ tasks {
|
|||||||
version(pluginVersion)
|
version(pluginVersion)
|
||||||
sinceBuild(pluginSinceBuild)
|
sinceBuild(pluginSinceBuild)
|
||||||
untilBuild(pluginUntilBuild)
|
untilBuild(pluginUntilBuild)
|
||||||
|
|
||||||
|
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
|
||||||
|
pluginDescription(closure {
|
||||||
|
File("./README.md").readText().lines().run {
|
||||||
|
subList(indexOf("<!-- Plugin description -->") + 1, indexOf("<!-- Plugin description end -->"))
|
||||||
|
}.joinToString("\n").run { markdownToHTML(this) }
|
||||||
|
})
|
||||||
|
|
||||||
|
// Get the latest available change notes from the changelog file
|
||||||
changeNotes(closure {
|
changeNotes(closure {
|
||||||
changelog.getLatest().toHTML()
|
changelog.getLatest().toHTML()
|
||||||
})
|
})
|
||||||
|
6
settings.gradle.kts
Normal file
6
settings.gradle.kts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
@ -5,9 +5,9 @@ import org.jetbrains.annotations.NonNls
|
|||||||
import org.jetbrains.annotations.PropertyKey
|
import org.jetbrains.annotations.PropertyKey
|
||||||
|
|
||||||
@NonNls
|
@NonNls
|
||||||
private const val BUNDLE = "messages.TemplateBundle"
|
private const val BUNDLE = "messages.MyBundle"
|
||||||
|
|
||||||
object TemplateBundle : DynamicBundle(BUNDLE) {
|
object MyBundle : DynamicBundle(BUNDLE) {
|
||||||
|
|
||||||
@Suppress("SpreadOperator")
|
@Suppress("SpreadOperator")
|
||||||
@JvmStatic
|
@JvmStatic
|
@ -1,10 +1,10 @@
|
|||||||
package org.jetbrains.plugins.template.services
|
package org.jetbrains.plugins.template.services
|
||||||
|
|
||||||
import org.jetbrains.plugins.template.TemplateBundle
|
import org.jetbrains.plugins.template.MyBundle
|
||||||
|
|
||||||
class MyApplicationService {
|
class MyApplicationService {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
println(TemplateBundle.message("applicationService"))
|
println(MyBundle.message("applicationService"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package org.jetbrains.plugins.template.services
|
package org.jetbrains.plugins.template.services
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import org.jetbrains.plugins.template.TemplateBundle
|
import org.jetbrains.plugins.template.MyBundle
|
||||||
|
|
||||||
class MyProjectService(project: Project) {
|
class MyProjectService(project: Project) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
println(TemplateBundle.message("projectService", project.name))
|
println(MyBundle.message("projectService", project.name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
<id>org.jetbrains.plugins.template</id>
|
<id>org.jetbrains.plugins.template</id>
|
||||||
<name>Template</name>
|
<name>Template</name>
|
||||||
<vendor>JetBrains</vendor>
|
<vendor>JetBrains</vendor>
|
||||||
<description>Demonstrates various aspects of interacting with project model</description>
|
|
||||||
|
|
||||||
<!-- Product and plugin compatibility requirements -->
|
<!-- Product and plugin compatibility requirements -->
|
||||||
<!-- https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html -->
|
<!-- https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html -->
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
name=Template Plugin
|
name=My Plugin
|
||||||
applicationService=Application service
|
applicationService=Application service
|
||||||
projectService=Project service: {0}
|
projectService=Project service: {0}
|
Loading…
Reference in New Issue
Block a user