GitHub Actions - template cleanup workflow

This commit is contained in:
Jakub Chrzanowski
2020-06-17 21:06:57 +02:00
parent 9cd83d4719
commit e4a1106495
14 changed files with 168 additions and 22 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

7
.github/template-cleanup/CHANGELOG.md vendored Normal file
View 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
View 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).

View File

@@ -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:

View File

@@ -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
View 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 }}