Skip to content

Commit a6d5e4c

Browse files
committed
IJMP-1844 Added releases automation
Signed-off-by: Uladzislau <leksilonchikk@gmail.com>
1 parent d832e7b commit a6d5e4c

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed

.github/workflows/release.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
steps:
13+
14+
- name: Checkout the plugin GitHub repository
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Java
18+
uses: actions/setup-java@v4
19+
with:
20+
distribution: zulu
21+
java-version: 17
22+
23+
- name: Setup Gradle
24+
uses: gradle/actions/setup-gradle@v3
25+
with:
26+
gradle-home-cache-cleanup: true
27+
28+
- name: Fetch Gradle properties
29+
id: properties
30+
shell: bash
31+
run: |
32+
PROPERTIES="$(./gradlew properties --console=plain -q)"
33+
PLUGIN_VERSION_FULL="$(echo "$PROPERTIES" | grep "^pluginVersion:" | cut -f2- -d ' ')"
34+
CURR_COMMIT="$(git rev-parse HEAD)"
35+
36+
echo "pluginVersionFull: $PLUGIN_VERSION_FULL"
37+
echo "currCommit: $CURR_COMMIT"
38+
39+
echo "pluginVersionFull=$PLUGIN_VERSION_FULL" >> $GITHUB_OUTPUT
40+
echo "currCommit=$CURR_COMMIT" >> $GITHUB_OUTPUT
41+
42+
- name: Publish Plugin
43+
env:
44+
ZOWE_INTELLIJ_MARKET_TOKEN: ${{ secrets.ZOWE_INTELLIJ_MARKET_TOKEN }}
45+
INTELLIJ_SIGNING_CERTIFICATE_CHAIN: ${{ secrets.INTELLIJ_SIGNING_CERTIFICATE_CHAIN }}
46+
INTELLIJ_SIGNING_PRIVATE_KEY: ${{ secrets.INTELLIJ_SIGNING_PRIVATE_KEY }}
47+
INTELLIJ_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.INTELLIJ_SIGNING_PRIVATE_KEY_PASSWORD }}
48+
run: ./gradlew publishPlugin
49+
50+
- name: Prepare release notes
51+
id: release_notes
52+
shell: bash
53+
run: |
54+
CHANGELOG="$(./gradlew getChangelog -q)"
55+
56+
echo 'version_release_notes<<EOF' >> $GITHUB_OUTPUT
57+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
58+
echo 'EOF' >> $GITHUB_OUTPUT
59+
60+
echo "Release notes to be added:"
61+
echo "$CHANGELOG"
62+
63+
- name: Create new tag and release
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
run: |
67+
git tag ${{ steps.properties.outputs.pluginVersionFull }}
68+
git push origin ${{ steps.properties.outputs.pluginVersionFull }}
69+
gh release create ${{ steps.properties.outputs.pluginVersionFull }} --title ${{ steps.properties.outputs.pluginVersionFull }} --target ${{ steps.properties.outputs.currCommit }} -F- <<EOF
70+
${{ steps.release_notes.outputs.version_release_notes }}
71+
EOF
72+
73+
- name: Upload Release Built Artifact
74+
continue-on-error: true
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
run: gh release upload ${{ steps.properties.outputs.pluginVersionFull }} ./build/distributions/*
78+
79+
- name: Create Pull Request
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
run: |
83+
VERSION="${{ steps.properties.outputs.pluginVersionFull }}"
84+
BRANCH="release-changelog-update-$VERSION"
85+
86+
git config user.email "action@github.com"
87+
git config user.name "GitHub Action"
88+
89+
git checkout -b $BRANCH
90+
git commit -am ":moyai: ${VERSION}" -m "[skip ci]"
91+
git push --set-upstream origin $BRANCH
92+
93+
gh pr create \
94+
--title ":moyai: \`$VERSION\`" \
95+
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
96+
--base "release/v$VERSION" \
97+
--head $BRANCH
98+
99+
- name: Close Milestone
100+
continue-on-error: true
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
run: |
104+
gh api repos/{owner}/{repo}/milestones \
105+
--jq '.[] | select(.title == "${{ steps.properties.outputs.pluginVersionFull }}") | .number' \
106+
| xargs -I '{}' gh api -X PATCH repos/{owner}/{repo}/milestones/{} -F state='closed'

build.gradle.kts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,30 @@ tasks {
152152
jvmTarget = JavaVersion.VERSION_17.toString()
153153
}
154154
}
155+
156+
signPlugin {
157+
certificateChain.set(environment("INTELLIJ_SIGNING_CERTIFICATE_CHAIN").map { it })
158+
privateKey.set(environment("INTELLIJ_SIGNING_PRIVATE_KEY").map { it })
159+
password.set(environment("INTELLIJ_SIGNING_PRIVATE_KEY_PASSWORD").map { it })
160+
}
161+
162+
publishPlugin {
163+
dependsOn("patchChangelog")
164+
token.set(environment("ZOWE_INTELLIJ_MARKET_TOKEN").map { it })
165+
// The pluginVersion is based on the SemVer (https://semver.org)
166+
// Read more: https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
167+
channels.set(
168+
properties("pluginVersion")
169+
.map {
170+
listOf(
171+
it.substringAfter('-', "")
172+
.substringAfter('-', "")
173+
.substringBefore('.')
174+
.ifEmpty { "stable" }
175+
)
176+
}
177+
.map { it })
178+
}
155179
}
156180

157181
sourceSets {

0 commit comments

Comments
 (0)