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:
|
||||
# - test using Gradle tasks, such as tes and verifyPlugin,
|
||||
# - test building process by preparing the artifact using buildPlugin Gradle task,
|
||||
# - run IntelliJ Plugin Verifier.
|
||||
# GitHub Actions Workflow created for testing and preparing the plugin release in following steps:
|
||||
# - validate Gradle Wrapper,
|
||||
# - run test and verifyPlugin tasks,
|
||||
# - 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:
|
||||
# - GitHub Actions: https://help.github.com/en/actions
|
||||
@ -156,7 +158,7 @@ jobs:
|
||||
# If accepted and published, release workflow would be triggered.
|
||||
releaseDraft:
|
||||
name: Release Draft
|
||||
# if: github.ref == 'refs/heads/master'
|
||||
if: github.ref == 'refs/heads/master'
|
||||
needs: [build, verify]
|
||||
runs-on: ubuntu-latest
|
||||
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
|
||||
on:
|
||||
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)
|
||||
![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
|
||||
designed as a GitHub template repository (check the [Creating a repository from a template][gh-template] article).
|
||||
<!-- Plugin description -->
|
||||
**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
|
||||
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.
|
||||
<!-- Plugin description end -->
|
||||
|
||||
We can detail here the following parts:
|
||||
We can highlight here the following parts:
|
||||
|
||||
- Gradle configuration
|
||||
- Sample code:
|
||||
@ -21,9 +23,21 @@ We can detail here the following parts:
|
||||
- CI based on GitHub actions
|
||||
- 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
|
||||
|
||||
@ -39,7 +53,10 @@ TODO
|
||||
|
||||
## Continuous Integration
|
||||
|
||||
TODO
|
||||
Unit tests
|
||||
Detekt
|
||||
verifyPlugin
|
||||
intellij-plugin-verifier
|
||||
|
||||
## 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,
|
||||
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
|
||||
|
||||
- [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
|
||||
[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
|
||||
|
||||
[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 org.jetbrains.changelog.closure
|
||||
import org.jetbrains.changelog.markdownToHTML
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
@ -10,7 +11,7 @@ plugins {
|
||||
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
|
||||
id("org.jetbrains.intellij") version "0.4.21"
|
||||
// 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
|
||||
id("io.gitlab.arturbosch.detekt") version "1.10.0-RC1"
|
||||
}
|
||||
@ -82,6 +83,15 @@ tasks {
|
||||
version(pluginVersion)
|
||||
sinceBuild(pluginSinceBuild)
|
||||
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 {
|
||||
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
|
||||
|
||||
@NonNls
|
||||
private const val BUNDLE = "messages.TemplateBundle"
|
||||
private const val BUNDLE = "messages.MyBundle"
|
||||
|
||||
object TemplateBundle : DynamicBundle(BUNDLE) {
|
||||
object MyBundle : DynamicBundle(BUNDLE) {
|
||||
|
||||
@Suppress("SpreadOperator")
|
||||
@JvmStatic
|
@ -1,10 +1,10 @@
|
||||
package org.jetbrains.plugins.template.services
|
||||
|
||||
import org.jetbrains.plugins.template.TemplateBundle
|
||||
import org.jetbrains.plugins.template.MyBundle
|
||||
|
||||
class MyApplicationService {
|
||||
|
||||
init {
|
||||
println(TemplateBundle.message("applicationService"))
|
||||
println(MyBundle.message("applicationService"))
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package org.jetbrains.plugins.template.services
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.plugins.template.TemplateBundle
|
||||
import org.jetbrains.plugins.template.MyBundle
|
||||
|
||||
class MyProjectService(project: Project) {
|
||||
|
||||
init {
|
||||
println(TemplateBundle.message("projectService", project.name))
|
||||
println(MyBundle.message("projectService", project.name))
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
<id>org.jetbrains.plugins.template</id>
|
||||
<name>Template</name>
|
||||
<vendor>JetBrains</vendor>
|
||||
<description>Demonstrates various aspects of interacting with project model</description>
|
||||
|
||||
<!-- Product and plugin compatibility requirements -->
|
||||
<!-- 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
|
||||
projectService=Project service: {0}
|
Loading…
Reference in New Issue
Block a user