Skip to content

Commit ebb264e

Browse files
authored
Merge pull request #12 from bluelhf/update-gradle
Update gradle, actions and buildscript; removes Verifier and Qodana from actions
2 parents aaa2496 + f93fda3 commit ebb264e

12 files changed

Lines changed: 346 additions & 248 deletions

.github/workflows/build.yml

Lines changed: 102 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,62 @@
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.
1+
# GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps:
2+
# - Validate Gradle Wrapper.
3+
# - Run 'test' and 'verifyPlugin' tasks.
4+
# - Run Qodana inspections.
5+
# - Run the 'buildPlugin' task and prepare artifact for further tests.
6+
# - Run the 'runPluginVerifier' task.
7+
# - Create a draft release.
88
#
9-
# Workflow is triggered on push and pull_request events.
9+
# The workflow is triggered on push and pull_request events.
1010
#
1111
# GitHub Actions reference: https://help.github.com/en/actions
1212
#
1313
## JBIJPPTPL
1414

1515
name: Build
1616
on:
17-
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
17+
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g., for dependabot pull requests)
1818
push:
19-
branches: [main]
19+
branches: [ main ]
2020
# Trigger the workflow on any pull request
2121
pull_request:
2222

23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
25+
cancel-in-progress: true
26+
2327
jobs:
2428

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
29+
# Prepare the environment and build the plugin
2830
build:
2931
name: Build
3032
runs-on: ubuntu-latest
31-
outputs:
32-
version: ${{ steps.properties.outputs.version }}
33-
changelog: ${{ steps.properties.outputs.changelog }}
3433
steps:
3534

36-
# Check out current repository
37-
- name: Fetch Sources
38-
uses: actions/checkout@v2.4.0
35+
# Free GitHub Actions Environment Disk Space
36+
- name: Maximize Build Space
37+
uses: jlumbroso/free-disk-space@v1.3.1
38+
with:
39+
tool-cache: false
40+
large-packages: false
3941

40-
# Validate wrapper
41-
- name: Gradle Wrapper Validation
42-
uses: gradle/wrapper-validation-action@v1.0.4
42+
# Check out the current repository
43+
- name: Fetch Sources
44+
uses: actions/checkout@v5
4345

44-
# Setup Java 11 environment for the next steps
46+
# Set up the Java environment for the next steps
4547
- name: Setup Java
46-
uses: actions/setup-java@v2
48+
uses: actions/setup-java@v5
4749
with:
4850
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
51+
java-version: 21
7552

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
53+
# Setup Gradle
54+
- name: Setup Gradle
55+
uses: gradle/actions/setup-gradle@v5
8356

84-
# Cache Plugin Verifier IDEs
85-
- name: Setup Plugin Verifier IDEs Cache
86-
uses: actions/cache@v2.1.7
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
57+
# Build plugin
58+
- name: Build plugin
59+
run: ./gradlew buildPlugin
10260

10361
# Prepare plugin archive content for creating artifact
10462
- name: Prepare Plugin Artifact
@@ -109,29 +67,81 @@ jobs:
10967
FILENAME=`ls *.zip`
11068
unzip "$FILENAME" -d content
11169
112-
echo "::set-output name=filename::${FILENAME:0:-4}"
70+
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
11371
114-
# Store already-built plugin as an artifact for downloading
72+
# Store an already-built plugin as an artifact for downloading
11573
- name: Upload artifact
116-
uses: actions/upload-artifact@v2.2.4
74+
uses: actions/upload-artifact@v5
11775
with:
11876
name: ${{ steps.artifact.outputs.filename }}
11977
path: ./build/distributions/content/*/*
12078

79+
# Run tests and upload a code coverage report
80+
test:
81+
name: Test
82+
needs: [ build ]
83+
runs-on: ubuntu-latest
84+
steps:
85+
86+
# Free GitHub Actions Environment Disk Space
87+
- name: Maximize Build Space
88+
uses: jlumbroso/free-disk-space@v1.3.1
89+
with:
90+
tool-cache: false
91+
large-packages: false
92+
93+
# Check out the current repository
94+
- name: Fetch Sources
95+
uses: actions/checkout@v5
96+
97+
# Set up the Java environment for the next steps
98+
- name: Setup Java
99+
uses: actions/setup-java@v5
100+
with:
101+
distribution: zulu
102+
java-version: 21
103+
104+
# Setup Gradle
105+
- name: Setup Gradle
106+
uses: gradle/actions/setup-gradle@v5
107+
with:
108+
cache-read-only: true
109+
110+
# Run tests
111+
- name: Run Tests
112+
run: ./gradlew check
113+
114+
# Collect Tests Result of failed tests
115+
- name: Collect Tests Result
116+
if: ${{ failure() }}
117+
uses: actions/upload-artifact@v5
118+
with:
119+
name: tests-result
120+
path: ${{ github.workspace }}/build/reports/tests
121+
122+
# Upload the Kover report to CodeCov
123+
- name: Upload Code Coverage Report
124+
uses: codecov/codecov-action@v5
125+
with:
126+
files: ${{ github.workspace }}/build/reports/kover/report.xml
127+
token: ${{ secrets.CODECOV_TOKEN }}
128+
121129
# Prepare a draft release for GitHub Releases page for the manual verification
122-
# If accepted and published, release workflow would be triggered
130+
# If accepted and published, the release workflow would be triggered
123131
releaseDraft:
124-
name: Release Draft
132+
name: Release draft
125133
if: github.event_name != 'pull_request'
126-
needs: build
134+
needs: [ build, test ]
127135
runs-on: ubuntu-latest
136+
permissions:
137+
contents: write
128138
steps:
129139

130-
# Check out current repository
140+
# Check out the current repository
131141
- name: Fetch Sources
132-
uses: actions/checkout@v2.4.0
142+
uses: actions/checkout@v5
133143

134-
# Remove old release drafts by using the curl request for the available releases with draft flag
144+
# Remove old release drafts by using the curl request for the available releases with a draft flag
135145
- name: Remove Old Release Drafts
136146
env:
137147
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -140,15 +150,16 @@ jobs:
140150
--jq '.[] | select(.draft == true) | .id' \
141151
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
142152
143-
# Create new release draft - which is not publicly visible and requires manual acceptance
153+
# Create a new release draft which is not publicly visible and requires manual acceptance
144154
- name: Create Release Draft
145155
env:
146156
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147157
run: |
148-
gh release create v${{ needs.build.outputs.version }} \
158+
VERSION=$(./gradlew properties --property version --quiet --console=plain | tail -n 1 | cut -f2- -d ' ')
159+
RELEASE_NOTE="./build/tmp/release_note.txt"
160+
./gradlew getChangelog --unreleased --no-header --quiet --console=plain --output-file=$RELEASE_NOTE
161+
162+
gh release create $VERSION \
149163
--draft \
150-
--title "v${{ needs.build.outputs.version }}" \
151-
--notes "$(cat << 'EOM'
152-
${{ needs.build.outputs.changelog }}
153-
EOM
154-
)"
164+
--title $VERSION \
165+
--notes-file $RELEASE_NOTE

.github/workflows/release.yml

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
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.
1+
# GitHub Actions Workflow created for handling the release process based on the draft release prepared with the Build workflow.
2+
# Running the publishPlugin task requires all the following secrets to be provided: PUBLISH_TOKEN, PRIVATE_KEY, PRIVATE_KEY_PASSWORD, CERTIFICATE_CHAIN.
3+
# See https://plugins.jetbrains.com/docs/intellij/plugin-signing.html for more information.
34

45
name: Release
56
on:
@@ -8,70 +9,77 @@ on:
89

910
jobs:
1011

11-
# Prepare and publish the plugin to the Marketplace repository
12+
# Prepare and publish the plugin to JetBrains Marketplace repository
1213
release:
1314
name: Publish Plugin
1415
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
pull-requests: write
1519
steps:
1620

17-
# Check out current repository
21+
# Free GitHub Actions Environment Disk Space
22+
- name: Maximize Build Space
23+
uses: jlumbroso/free-disk-space@v1.3.1
24+
with:
25+
tool-cache: false
26+
large-packages: false
27+
28+
# Check out the current repository
1829
- name: Fetch Sources
19-
uses: actions/checkout@v2.4.0
30+
uses: actions/checkout@v5
2031
with:
2132
ref: ${{ github.event.release.tag_name }}
2233

23-
# Setup Java 11 environment for the next steps
34+
# Set up the Java environment for the next steps
2435
- name: Setup Java
25-
uses: actions/setup-java@v2
36+
uses: actions/setup-java@v5
2637
with:
2738
distribution: zulu
28-
java-version: 11
29-
cache: gradle
39+
java-version: 21
3040

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-
CHANGELOG="${CHANGELOG//'%'/'%25'}"
42-
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
43-
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
44-
45-
echo "::set-output name=changelog::$CHANGELOG"
46-
47-
# Update Unreleased section with the current release note
41+
# Setup Gradle
42+
- name: Setup Gradle
43+
uses: gradle/actions/setup-gradle@v5
44+
with:
45+
cache-read-only: true
46+
47+
# Update the Unreleased section with the current release note
4848
- name: Patch Changelog
49-
if: ${{ steps.properties.outputs.changelog != '' }}
49+
if: ${{ github.event.release.body != '' }}
5050
env:
51-
CHANGELOG: ${{ steps.properties.outputs.changelog }}
51+
CHANGELOG: ${{ github.event.release.body }}
5252
run: |
53-
./gradlew patchChangelog --release-note="$CHANGELOG"
53+
RELEASE_NOTE="./build/tmp/release_note.txt"
54+
mkdir -p "$(dirname "$RELEASE_NOTE")"
55+
echo "$CHANGELOG" > $RELEASE_NOTE
56+
57+
./gradlew patchChangelog --release-note-file=$RELEASE_NOTE
5458
55-
# Publish the plugin to the Marketplace
59+
# Publish the plugin to JetBrains Marketplace
5660
- name: Publish Plugin
5761
env:
5862
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
63+
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
64+
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
65+
PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
5966
run: ./gradlew publishPlugin
6067

61-
# Upload artifact as a release asset
68+
# Upload an artifact as a release asset
6269
- name: Upload Release Asset
6370
env:
6471
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6572
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
6673

67-
# Create pull request
74+
# Create a pull request
6875
- name: Create Pull Request
69-
if: ${{ steps.properties.outputs.changelog != '' }}
76+
if: ${{ github.event.release.body != '' }}
7077
env:
7178
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7279
run: |
7380
VERSION="${{ github.event.release.tag_name }}"
7481
BRANCH="changelog-update-$VERSION"
82+
LABEL="release changelog"
7583
7684
git config user.email "action@github.com"
7785
git config user.name "GitHub Action"
@@ -80,8 +88,13 @@ jobs:
8088
git commit -am "Changelog update - $VERSION"
8189
git push --set-upstream origin $BRANCH
8290
91+
gh label create "$LABEL" \
92+
--description "Pull requests with release changelog update" \
93+
--force \
94+
|| true
95+
8396
gh pr create \
8497
--title "Changelog update - \`$VERSION\`" \
8598
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
86-
--base main \
99+
--label "$LABEL" \
87100
--head $BRANCH

0 commit comments

Comments
 (0)