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

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