Skip to content
This repository was archived by the owner on May 8, 2024. It is now read-only.

Commit 09ec1c0

Browse files
Feature: Created workflow to generate release notes and publish plugin (#23)
* feat: changed workflows and added a new one for publishing on the marketplace Signed-off-by: Adroaldo Neto <adroaldo.neto@zup.com.br> * chore: removed unused secrets Signed-off-by: Adroaldo Neto <adroaldo.neto@zup.com.br> * chore: added new title to changelog and changed workflow variables to lowercase Signed-off-by: Adroaldo Neto <adroaldo.neto@zup.com.br> * chore: changed reusable workflow branch Signed-off-by: Adroaldo Neto <adroaldo.neto@zup.com.br> Signed-off-by: Adroaldo Neto <adroaldo.neto@zup.com.br>
1 parent 2218a99 commit 09ec1c0

File tree

7 files changed

+196
-13
lines changed

7 files changed

+196
-13
lines changed

.github/release.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Copyright 2022 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
changelog:
18+
exclude:
19+
labels:
20+
- ignore-for-release
21+
categories:
22+
- title: Breaking Changes 💥
23+
labels:
24+
- breaking-change
25+
- title: Exciting New Features 🎉
26+
labels:
27+
- enhancement
28+
- title: Bug Fixes 🛠
29+
labels:
30+
- bug
31+
- title: Other Changes
32+
labels:
33+
- "*"

.github/workflows/check-callback.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ name: Check callback
1818

1919
on:
2020
repository_dispatch:
21-
type: [SECURITY, RELEASE, TAG]
21+
type: [SECURITY, RELEASE, RELEASED]
2222

2323
jobs:
2424
CHECK_CALLBACK:
@@ -54,4 +54,12 @@ jobs:
5454
"state": "error",
5555
"description": "Internal error",
5656
"target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
57-
}'
57+
}'
58+
59+
PUSBLISH:
60+
if: ${{ success() && github.event.event_type == 'RELEASED' }}
61+
uses: stack-spot/stackspot-intellij-extension/.github/workflows/publish-release.yml@release-0.1.4
62+
secrets:
63+
accessToken: ${{ secrets.ACCESS_TOKEN }}
64+
publishToken: ${{ secrets.PUBLISH_TOKEN }}
65+
marketplaceChannel: ${{ secrets.MARKETPLACE_CHANNEL }}

.github/workflows/deploy-pre-release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ name: Deploy pre release
1919
on:
2020
push:
2121
branches:
22-
- release-*
22+
- 'release-*'
23+
- '!changelog-update-*'
2324

2425
jobs:
2526
DISPATCH_EVENT:

.github/workflows/deploy-prod.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
name: Deploy production
1818

1919
on:
20-
push:
21-
tags:
22-
- v*.*.*
20+
release:
21+
types: [released]
2322

2423
jobs:
2524
DISPATCH_EVENT:
@@ -36,7 +35,7 @@ jobs:
3635
-o response.json \
3736
--silent \
3837
--data '{
39-
"event_type": "TAG",
38+
"event_type": "RELEASED",
4039
"client_payload": {
4140
"ref": "${{ github.ref }}",
4241
"statuses_href": "'"$STATUSES_HREF"'"
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#
2+
# Copyright 2022 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
name: Publish Release
18+
19+
on:
20+
workflow_call:
21+
secrets:
22+
accessToken:
23+
required: true
24+
publishToken:
25+
required: true
26+
marketplaceChannel:
27+
required: true
28+
29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.ref }}
31+
cancel-in-progress: true
32+
33+
jobs:
34+
EXPORT_PROPERTIES:
35+
runs-on: ubuntu-latest
36+
outputs:
37+
changelog: ${{ steps.properties.outputs.changelog }}
38+
steps:
39+
# Set environment variables
40+
- name: Export Properties
41+
id: properties
42+
run: |
43+
CHANGELOG="$(cat << 'EOM' | sed -e "/## What's Changed/d" -e 's/^[[:space:]]*$//g' -e '/./,$!d'
44+
${{ github.event.release.body }}
45+
EOM
46+
)"
47+
48+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
49+
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
50+
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
51+
CHANGELOG="${CHANGELOG//'**Full Changelog**'/'Full Changelog'}"
52+
53+
echo "::set-output name=changelog::$CHANGELOG"
54+
55+
# Prepare and publish the plugin to the Marketplace repository
56+
PUBLISH:
57+
name: Publish Plugin
58+
runs-on: ubuntu-latest
59+
steps:
60+
61+
# Check out current repository
62+
- name: Checkout
63+
uses: actions/checkout@v3
64+
with:
65+
ref: ${{ github.event.release.tag_name }}
66+
67+
# Publish the plugin to the Marketplace
68+
- name: Publish Plugin
69+
env:
70+
PUBLISH_TOKEN: ${{ secrets.publishToken }}
71+
MARKETPLACE_CHANNEL: ${{ secrets.marketplaceChannel }}
72+
run: |
73+
TAG=${{ github.event.release.tag_name }}
74+
TAG="${TAG//v/""}"
75+
./gradlew publishPlugin -Dproject_version=$TAG
76+
77+
# Upload artifact as a release asset
78+
- name: Upload Release Asset
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.accessToken }}
81+
run: |
82+
gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
83+
84+
CHANGELOG:
85+
needs:
86+
- EXPORT_PROPERTIES
87+
runs-on: ubuntu-latest
88+
steps:
89+
# Check out current repository
90+
- name: Checkout
91+
uses: actions/checkout@v3
92+
with:
93+
ref: ${{ github.event.release.tag_name }}
94+
95+
# Update Unreleased section with the current release note
96+
- name: Patch Changelog
97+
if: ${{ needs.EXPORT_PROPERTIES.outputs.changelog != '' }}
98+
env:
99+
CHANGELOG: ${{ needs.EXPORT_PROPERTIES.outputs.changelog }}
100+
run: |
101+
./gradlew patchChangelog --release-note="$CHANGELOG"
102+
103+
# Create pull request
104+
- name: Create Pull Request
105+
if: ${{ needs.EXPORT_PROPERTIES.outputs.changelog != '' }}
106+
env:
107+
GITHUB_TOKEN: ${{ secrets.accessToken }}
108+
run: |
109+
VERSION="${{ github.event.release.tag_name }}"
110+
BRANCH="changelog-update-$VERSION"
111+
112+
git config user.email "action@github.com"
113+
git config user.name "GitHub Action"
114+
115+
git checkout -b $BRANCH
116+
git commit -asm "Changelog update - $VERSION"
117+
git push --set-upstream origin $BRANCH
118+
119+
gh pr create \
120+
--title "Changelog update - \`$VERSION\`" \
121+
--body "current pull request contains patched \`changelog.md\` file for the \`$version\` version." \
122+
--base "${{ github.event.release.target_commitish }}" \
123+
--head $BRANCH \
124+
--label ignore-for-release

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Changelog
2+
3+
## Releases
4+

build.gradle.kts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
import org.jetbrains.changelog.date
2+
13
plugins {
24
id("java")
35
id("org.jetbrains.kotlin.jvm") version "1.7.10"
46
id("org.jetbrains.intellij") version "1.8.0"
7+
8+
// Gradle Changelog Plugin
9+
id("org.jetbrains.changelog") version "1.3.1"
510
}
611

712
group = "com.stackspot"
@@ -25,6 +30,20 @@ intellij {
2530
)
2631
}
2732

33+
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
34+
changelog {
35+
val regex =
36+
Regex("""^v((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)${'$'}""")
37+
headerParserRegex.set(regex)
38+
header.set(provider { "[v${version.get()}] - ${date()}" })
39+
40+
unreleasedTerm.set("Releases")
41+
itemPrefix.set("*")
42+
version.set(version)
43+
44+
groups.set(emptyList())
45+
}
46+
2847
tasks {
2948
// Set the JVM compatibility versions
3049
withType<JavaCompile> {
@@ -40,13 +59,8 @@ tasks {
4059
untilBuild.set("222.*")
4160
}
4261

43-
signPlugin {
44-
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
45-
privateKey.set(System.getenv("PRIVATE_KEY"))
46-
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
47-
}
48-
4962
publishPlugin {
5063
token.set(System.getenv("PUBLISH_TOKEN"))
64+
channels.set(listOf(System.getenv("CHANNEL")))
5165
}
5266
}

0 commit comments

Comments
 (0)