Skip to content

Commit 0200716

Browse files
committed
ci(release): release through a release PR, with change notes on both variants (#140)
Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 49c9c38 commit 0200716

5 files changed

Lines changed: 93 additions & 77 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 59 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# - Run Qodana inspections.
55
# - Run the 'buildPlugin' task and prepare artifact for further tests.
66
# - Run the 'runPluginVerifier' task.
7-
# - Create a draft release.
7+
# - Tag a released version, or keep the next release in a pull request.
88
#
99
# The workflow is triggered on push and pull_request events.
1010
#
@@ -234,40 +234,73 @@ jobs:
234234
name: pluginVerifier-result-${{ matrix.phpApi }}
235235
path: ${{ github.workspace }}/${{ matrix.buildDir }}/reports/pluginVerifier
236236

237-
# Prepare a draft release for GitHub Releases page for the manual verification
238-
# If accepted and published, the release workflow would be triggered
239-
releaseDraft:
240-
name: Release draft
237+
# A version whose changelog section is on main gets its tag and GitHub release (which runs release.yml); the rest of
238+
# [Unreleased] is kept in a "release: <next>" pull request. Versions are <year>.<N>: N grows, a new year starts at 0.
239+
releasePr:
240+
name: Release PR
241241
if: github.event_name != 'pull_request'
242242
needs: [ build, test, inspectCode, verify ]
243243
runs-on: ubuntu-latest
244244
permissions:
245245
contents: write
246+
pull-requests: write
247+
env:
248+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
249+
BRANCH: release/next
246250
steps:
247251

248252
# Check out the current repository
249253
- name: Fetch Sources
250254
uses: actions/checkout@v7
251255

252-
# Remove old release drafts by using the curl request for the available releases with a draft flag
253-
- name: Remove Old Release Drafts
254-
env:
255-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
256-
run: |
257-
gh api repos/{owner}/{repo}/releases \
258-
--jq '.[] | select(.draft == true) | .id' \
259-
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
260-
261-
# Create a new release draft which is not publicly visible and requires manual acceptance
262-
- name: Create Release Draft
263-
env:
264-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
256+
# Set up the Java environment for the next steps
257+
- name: Setup Java
258+
uses: actions/setup-java@v6
259+
with:
260+
distribution: zulu
261+
java-version: 21
262+
263+
# Setup Gradle
264+
- name: Setup Gradle
265+
uses: gradle/actions/setup-gradle@v6.4.0
266+
with:
267+
cache-read-only: true
268+
269+
- name: Release or Update Release PR
265270
run: |
266-
VERSION=$(./gradlew properties --property version --quiet --console=plain | tail -n 1 | cut -f2- -d ' ')
267-
RELEASE_NOTE="./build/tmp/release_note.txt"
268-
./gradlew getChangelog --unreleased --no-header --quiet --console=plain --output-file=$RELEASE_NOTE
269-
270-
gh release create $VERSION \
271-
--draft \
272-
--title $VERSION \
273-
--notes-file $RELEASE_NOTE
271+
GRADLE="./gradlew --quiet --console=plain"
272+
NOTES="./build/tmp/release_note.txt"
273+
mkdir -p "$(dirname "$NOTES")"
274+
CURRENT=$($GRADLE properties --property pluginVersion | tail -n 1 | cut -f2- -d ' ')
275+
276+
if grep -Fq "## [$CURRENT]" CHANGELOG.md; then
277+
if ! git ls-remote --exit-code --tags origin "refs/tags/v$CURRENT" > /dev/null; then
278+
$GRADLE getChangelog --project-version="$CURRENT" --no-header --no-links --output-file="$NOTES"
279+
gh release create "v$CURRENT" --target "$GITHUB_SHA" --title "$CURRENT" --notes-file "$NOTES"
280+
fi
281+
YEAR=$(date -u +%Y)
282+
if [ "${CURRENT%%.*}" = "$YEAR" ]; then NEXT="$YEAR.$(( ${CURRENT#*.} + 1 ))"; else NEXT="$YEAR.0"; fi
283+
else
284+
NEXT="$CURRENT"
285+
fi
286+
287+
$GRADLE getChangelog --unreleased --no-header --no-empty-sections --no-links --output-file="$NOTES"
288+
if ! grep -q '^- ' "$NOTES"; then
289+
echo "Nothing unreleased"
290+
exit 0
291+
fi
292+
293+
sed -i "s/^pluginVersion = .*/pluginVersion = $NEXT/" gradle.properties
294+
$GRADLE patchChangelog
295+
296+
git config user.email "action@github.com"
297+
git config user.name "GitHub Action"
298+
git checkout -B "$BRANCH"
299+
git commit -qam "release: $NEXT"
300+
git push --force origin "$BRANCH"
301+
302+
if [ "$(gh pr view "$BRANCH" --json state --jq .state 2>/dev/null)" = "OPEN" ]; then
303+
gh pr edit "$BRANCH" --title "release: $NEXT" --body-file "$NOTES"
304+
else
305+
gh pr create --base main --head "$BRANCH" --title "release: $NEXT" --body-file "$NOTES"
306+
fi

‎.github/workflows/release.yml‎

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# GitHub Actions Workflow created for handling the release process based on the draft release prepared with the Build workflow.
1+
# Publishes a release that the Build workflow tagged once its release pull request was merged.
22
# Running the publishPlugin task requires all the following secrets to be provided: PUBLISH_TOKEN, PRIVATE_KEY, PRIVATE_KEY_PASSWORD, CERTIFICATE_CHAIN.
33
# See https://plugins.jetbrains.com/docs/intellij/plugin-signing.html for more information.
44

@@ -65,8 +65,7 @@ jobs:
6565
name: Publish Plugin
6666
runs-on: ubuntu-latest
6767
permissions:
68-
contents: write
69-
pull-requests: write
68+
contents: read
7069
steps:
7170

7271
# Free GitHub Actions Environment Disk Space
@@ -95,18 +94,6 @@ jobs:
9594
with:
9695
cache-read-only: true
9796

98-
# Update the Unreleased section with the current release note
99-
- name: Patch Changelog
100-
if: ${{ github.event.release.body != '' }}
101-
env:
102-
CHANGELOG: ${{ github.event.release.body }}
103-
run: |
104-
RELEASE_NOTE="./build/tmp/release_note.txt"
105-
mkdir -p "$(dirname "$RELEASE_NOTE")"
106-
echo "$CHANGELOG" > $RELEASE_NOTE
107-
108-
./gradlew patchChangelog --release-note-file=$RELEASE_NOTE
109-
11097
# Publish the plugin to JetBrains Marketplace
11198
- name: Publish Plugin
11299
env:
@@ -116,33 +103,3 @@ jobs:
116103
PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
117104
# publishPlugin releases every variant listed in `phpApis`; the Marketplace serves each IDE its match.
118105
run: ./gradlew publishPlugin
119-
120-
# Create a pull request
121-
- name: Create Pull Request
122-
if: ${{ github.event.release.body != '' }}
123-
env:
124-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125-
run: |
126-
VERSION="${{ github.event.release.tag_name }}"
127-
BRANCH="changelog-update-$VERSION"
128-
LABEL="release changelog"
129-
130-
git config user.email "action@github.com"
131-
git config user.name "GitHub Action"
132-
133-
git diff --quiet CHANGELOG.md && exit 0
134-
135-
git checkout -b $BRANCH
136-
git commit -am "Changelog update - $VERSION"
137-
git push --set-upstream origin $BRANCH
138-
139-
gh label create "$LABEL" \
140-
--description "Pull requests with release changelog update" \
141-
--force \
142-
|| true
143-
144-
gh pr create \
145-
--title "Changelog update - \`$VERSION\`" \
146-
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
147-
--label "$LABEL" \
148-
--head $BRANCH

‎CLAUDE.md‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -777,11 +777,14 @@ The test task canonicalizes its temporary directory so VFS and filesystem paths
777777
## CI/CD
778778

779779
- **build.yml** (push to `main`, all PRs): `buildPlugin` → `check` (Kover XML → Codecov) → Qodana →
780-
`verifyPlugin` → release draft. Build and verify run for 252, 262 and `openide`; tests for 262 and `openide` on
780+
`verifyPlugin` → release PR. Build and verify run for 252, 262 and `openide`; tests for 262 and `openide` on
781781
Ubuntu and Windows, where Windows does not fail the run until its known failures are fixed (#120, #122).
782782
Gradle provisions the OpenIDE variant's Java 25 toolchain itself.
783-
- **release.yml** (on GitHub release): publish to JetBrains Marketplace, patch the changelog, open a PR back;
784-
a matrix builds 252, 262 and `openide` and attaches each ZIP to the release.
783+
- **Release PR** (the last `build.yml` job, on `main`): a `pluginVersion` whose `## [version]` section is on `main`
784+
is released — tag `v<version>` plus a GitHub release; a non-empty `[Unreleased]` is kept in the `release/next` PR
785+
(version bumped, changelog patched), rebuilt on every push. The PR is opened by `GITHUB_TOKEN`, so no checks run on it.
786+
- **release.yml** (on GitHub release): publish to JetBrains Marketplace; a matrix builds 252, 262 and `openide` and
787+
attaches each ZIP to the release.
785788
- **run-ui-tests.yml** (manual): UI tests on Ubuntu / Windows / macOS via robot-server.
786789

787790
## Conventions
@@ -791,6 +794,7 @@ The test task canonicalizes its temporary directory so VFS and filesystem paths
791794
- Icons follow IntelliJ conventions: SVG with a `_dark` variant
792795
- Register shared extension points in `plugin.xml` (coverage-only ones in `coverage.xml`). PHP-specific registrations
793796
belong in the selected implementation's `META-INF/testo-php.xml` or `testo-php-coverage.xml`.
794-
- Version follows SemVer; `pluginVersion` in `gradle.properties` is the single source of truth
797+
- Version is `<year>.<N>`: every release bumps N, a new year starts at `<year>.0`, never a third component;
798+
`pluginVersion` in `gradle.properties` is the single source of truth, bumped only by the release PR
795799
- Notable user-visible changes go into `CHANGELOG.md` under `## [Unreleased]` (Keep a Changelog format) —
796-
the release workflow consumes that section
800+
the release PR consumes that section, and only it writes a version section

‎build.gradle.kts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.jetbrains.changelog.Changelog
12
import org.jetbrains.changelog.markdownToHTML
23
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
34
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
@@ -129,6 +130,19 @@ intellijPlatform {
129130
}
130131
}
131132

133+
// Both variants take the notes of the bare pluginVersion: the changelog knows no API suffix.
134+
val changelog = project.changelog
135+
changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion ->
136+
with(changelog) {
137+
renderItem(
138+
(getOrNull(pluginVersion) ?: getUnreleased())
139+
.withHeader(false)
140+
.withEmptySections(false),
141+
Changelog.OutputType.HTML,
142+
)
143+
}
144+
}
145+
132146
ideaVersion {
133147
sinceBuild = apiProperty("pluginSinceBuild")
134148
untilBuild = apiProperty("pluginUntilBuild").map { it.trim() }.filter { it.isNotEmpty() }
@@ -168,6 +182,14 @@ intellijPlatform {
168182
}
169183
}
170184

185+
changelog {
186+
version = providers.gradleProperty("pluginVersion")
187+
// pluginVersion has two components, which the default SemVer-only header parser rejects.
188+
headerParserRegex = """(\d+(?:\.\d+){1,3}(?:-[\w.]+)?)""".toRegex()
189+
groups.empty()
190+
repositoryUrl = providers.gradleProperty("pluginRepositoryUrl")
191+
}
192+
171193
// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
172194
kover {
173195
// The OpenIDE tests render file templates, and Velocity reads its own constants by reflection: the counter field

‎gradle.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pluginGroup = com.github.xepozz.testo
44
pluginName = Testo
55
pluginRepositoryUrl = https://github.com/j-plugins/testo-plugin
66
# SemVer format -> https://semver.org
7-
pluginVersion = 2026.16
7+
pluginVersion = 2026.17
88

99
# Two artifacts because 2026.2 changed the platform module topology, not the source (which is now identical for both):
1010
# smRunner/testRunner/ui.jcef split out of the monolith and must be requested by name on 262, but that name does not

0 commit comments

Comments
 (0)