Skip to content

Commit b86aafb

Browse files
committed
build: rework build scripts
1 parent 69d4ce1 commit b86aafb

File tree

8 files changed

+436
-114
lines changed

8 files changed

+436
-114
lines changed

.github/dependabot.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Dependabot configuration:
2+
# https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates
3+
4+
version: 2
5+
updates:
6+
# Maintain dependencies for Gradle dependencies
7+
- package-ecosystem: "gradle"
8+
directory: "/"
9+
target-branch: "next"
10+
schedule:
11+
interval: "daily"
12+
# Maintain dependencies for GitHub Actions
13+
- package-ecosystem: "github-actions"
14+
directory: "/"
15+
target-branch: "next"
16+
schedule:
17+
interval: "daily"

.github/workflows/build.yml

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

.github/workflows/release.yml

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# GitHub Actions Workflow created for handling the release process based on the draft release prepared
2+
# with the Build workflow. Running the publishPlugin task requires the PUBLISH_TOKEN secret provided.
3+
4+
name: Release
5+
on:
6+
release:
7+
types: [prereleased, released]
8+
9+
jobs:
10+
11+
# Prepare and publish the plugin to the Marketplace repository
12+
release:
13+
name: Publish Plugin
14+
runs-on: ubuntu-latest
15+
steps:
16+
17+
# Check out current repository
18+
- name: Fetch Sources
19+
uses: actions/[email protected]
20+
with:
21+
ref: ${{ github.event.release.tag_name }}
22+
23+
# Setup Java 11 environment for the next steps
24+
- name: Setup Java
25+
uses: actions/setup-java@v2
26+
with:
27+
distribution: zulu
28+
java-version: 11
29+
cache: gradle
30+
31+
# Set environment variables
32+
- name: Export Properties
33+
id: properties
34+
shell: bash
35+
run: |
36+
CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d'
37+
${{ github.event.release.body }}
38+
EOM
39+
)"
40+
41+
echo "::set-output name=changelog::$CHANGELOG"
42+
43+
# Update Unreleased section with the current release note
44+
- name: Patch Changelog
45+
if: ${{ steps.properties.outputs.changelog != '' }}
46+
run: |
47+
./gradlew patchChangelog --release-note "$(cat << 'EOM'
48+
${{ steps.properties.outputs.changelog }}
49+
EOM
50+
)"
51+
52+
# Publish JAR to Maven Central
53+
- name: Publish library
54+
env:
55+
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
56+
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
57+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
58+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
59+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
60+
run: ./gradlew publish \
61+
-PmavenCentralUsername=$MAVEN_CENTRAL_USERNAME \
62+
-PmavenCentralPassword=$MAVEN_CENTRAL_PASSWORD \
63+
-PsigningKey=$SIGNING_KEY \
64+
-PsigningPassword=$SIGNING_PASSWORD
65+
66+
# Publish the plugin to the Marketplace
67+
- name: Publish Plugin
68+
env:
69+
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
70+
run: ./gradlew publishPlugin
71+
72+
# Upload artifact as a release asset
73+
- name: Upload Release Asset
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
77+
78+
# Create pull request
79+
- name: Create Pull Request
80+
if: ${{ steps.properties.outputs.changelog != '' }}
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
run: |
84+
VERSION="${{ github.event.release.tag_name }}"
85+
BRANCH="changelog-update-$VERSION"
86+
87+
git config user.email "[email protected]"
88+
git config user.name "GitHub Action"
89+
90+
git checkout -b $BRANCH
91+
git commit -am "Changelog update - $VERSION"
92+
git push --set-upstream origin $BRANCH
93+
94+
gh pr create \
95+
--title "Changelog update - \`$VERSION\`" \
96+
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
97+
--base main \
98+
--head $BRANCH

0 commit comments

Comments
 (0)