Skip to content

Commit 7cfd5af

Browse files
committed
impl: workflow actions for release
- patch unreleased section in the changelog with version and release date - publish the plugin to the marketplace (disabled for now) - promote draft artefact as released
1 parent 2b5708f commit 7cfd5af

File tree

2 files changed

+96
-2
lines changed

2 files changed

+96
-2
lines changed

.github/workflows/release.yml

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

build.gradle.kts

+5-2
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,14 @@ val pluginZip by tasks.creating(Zip::class) {
150150
archiveBaseName.set(pluginName)
151151
}
152152

153-
val uploadPlugin by tasks.creating {
153+
val publishPlugin by tasks.creating {
154154
dependsOn(pluginZip)
155155

156156
doLast {
157-
val instance = PluginRepositoryFactory.create("https://plugins.jetbrains.com", project.property("pluginMarketplaceToken").toString())
157+
val instance = PluginRepositoryFactory.create(
158+
"https://plugins.jetbrains.com",
159+
project.property("PUBLISH_TOKEN").toString()
160+
)
158161

159162
// first upload
160163
// instance.uploader.uploadNewPlugin(pluginZip.outputs.files.singleFile, listOf("toolbox", "gateway"), LicenseUrl.APACHE_2_0, ProductFamily.TOOLBOX)

0 commit comments

Comments
 (0)