Skip to content

Commit cef6b30

Browse files
sbouchetadietish
authored andcommitted
chore: publish plugin using gitHub Action
also update to IJ-2024.3 Signed-off-by: Stephane Bouchet <[email protected]>
1 parent 93c312e commit cef6b30

File tree

6 files changed

+121
-109
lines changed

6 files changed

+121
-109
lines changed

.github/workflows/IJ.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
IJ: [ 2022.3, 2023.1, 2023.2, 2023.3, 2024.1, 2024.2 ]
17+
IJ: [ 2022.3, 2023.1, 2023.2, 2023.3, 2024.1, 2024.2, 2024.3 ]
1818
steps:
1919
- uses: actions/checkout@v4
2020
- name: Set up JDK 17

.github/workflows/release.yml

+111-33
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,126 @@
1-
name: Generate changelog and plugin archive for new release
1+
name: Release Plugin
2+
run-name: Release ${{ inputs.release_version }}
3+
4+
#Only one job at a time
5+
concurrency: release
6+
27
on:
3-
push:
4-
tags:
5-
- '*'
8+
workflow_dispatch:
9+
inputs:
10+
publishToMarketPlace:
11+
description: 'Publish to JetBrains Marketplace ?'
12+
required: true
13+
type: choice
14+
options:
15+
- 'true'
16+
- 'false'
17+
default: 'false'
18+
release_version:
19+
description: 'Release version'
20+
required: true
21+
type: string
22+
623
jobs:
7-
build:
24+
# Prepare and publish the plugin to JetBrains Marketplace repository
25+
release:
26+
name: Publish new release
827
runs-on: ubuntu-latest
28+
permissions:
29+
contents: write
30+
pull-requests: write
931
steps:
10-
- uses: actions/checkout@v2
11-
- name: Set up JDK 11
12-
uses: actions/setup-java@v1
32+
# Check out current repository
33+
- name: Fetch Sources
34+
uses: actions/checkout@v4
35+
36+
# Set up Java environment for the next steps
37+
- name: Setup Java
38+
uses: actions/setup-java@v4
1339
with:
14-
java-version: 11
15-
- name: Grant execute permission for gradlew
16-
run: chmod +x gradlew
17-
- name: Build with Gradle
18-
run: ./gradlew buildPlugin
19-
- name: Get the version
20-
id: get_version
21-
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
40+
distribution: 'temurin'
41+
java-version: 17
42+
43+
# Setup Gradle
44+
- name: Setup Gradle
45+
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
46+
with:
47+
add-job-summary: 'on-failure'
48+
add-job-summary-as-pr-comment: 'on-failure'
49+
validate-wrappers: true
50+
gradle-home-cache-cleanup: true
51+
52+
- name: Tag Release
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
run: |
56+
git config user.email "[email protected]"
57+
git config user.name "GitHub Action"
58+
if git diff --quiet; then
59+
echo "No changes to commit."
60+
else
61+
git commit -sam "chore(skip-release): set version to ${{ inputs.release_version }}"
62+
fi
63+
git tag ${{ inputs.release_version }}
64+
git push origin ${{ inputs.release_version }}
65+
66+
- name: Set Release Version
67+
shell: bash
68+
run: |
69+
CURRENT_VERSION=$(grep "projectVersion=" gradle.properties | cut -d'=' -f2)
70+
NEW_VERSION=${{ inputs.release_version }}.${{ github.run_number }}
71+
awk -v current="$CURRENT_VERSION" -v new="$NEW_VERSION" 'BEGIN {FS=OFS="="} $1 == "projectVersion" { $2 = new }1' gradle.properties > tmpfile && mv tmpfile gradle.properties
72+
echo "Release version: $NEW_VERSION"
73+
echo "PLUGIN_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
74+
75+
# Publish the plugin to JetBrains Marketplace
76+
- name: Publish Plugin to JetBrains Marketplace
77+
if: ${{ inputs.publishToMarketPlace == 'true' }}
78+
env:
79+
PUBLISH_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }}
80+
run: |
81+
./gradlew publishPlugin -PjetBrainsToken=$PUBLISH_TOKEN -PprojectVersion=$PLUGIN_VERSION -PjetBrainsChannel=stable
82+
echo "Published $PLUGIN_VERSION to the Jetbrains Marketplace"
83+
84+
# Set next SNAPSHOT version
85+
- name: Increment Plugin Version
86+
shell: bash
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
run: |
90+
CURRENT_VERSION=$(grep "projectVersion=" gradle.properties | cut -d'=' -f2)
91+
IFS="-" read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
92+
IFS="." read -ra VERSION_NUM <<< "${VERSION_PARTS[0]}"
93+
((VERSION_NUM[2]+=1))
94+
NEW_VERSION="${VERSION_NUM[0]}.${VERSION_NUM[1]}.${VERSION_NUM[2]}-SNAPSHOT"
95+
awk -v new_version="$NEW_VERSION" '/projectVersion=/{sub(/=.*/, "=" new_version)}1' gradle.properties > tmpfile && mv tmpfile gradle.properties
96+
echo "Set $NEW_VERSION in gradle.properties"
97+
git checkout -b $NEW_VERSION
98+
git commit -sam "chore(skip-release): set version to $NEW_VERSION"
99+
git push -u origin $NEW_VERSION
100+
gh pr create -B main -H $NEW_VERSION --title "chore(skip-release): set version to $NEW_VERSION" --body 'Created by Github action'
101+
22102
- name: Simple conventional changelog
23103
uses: redhat-developer/simple-conventional-changelog@0a6db1ac3910c2cf66f2e1a530951dba1ece8540 #0.0.12
24104
id: changelog
25105
with:
26106
token: ${{ secrets.GITHUB_TOKEN }}
27-
current-tag: ${{ steps.get_version.outputs.VERSION }}
107+
current-tag: ${{ inputs.release_version }}
28108
types-mapping: 'feat:Features,fix:Bug Fixes,docs:Documentation,refactor:Refactoring,chore:Other'
29-
- run: |
30-
echo '${{ steps.changelog.outputs.changelog }}'
31-
- name: Create Release
32-
id: create_release
33-
uses: actions/create-release@v1
109+
110+
# Create a new GitHub release
111+
- name: Create Github Release
34112
env:
35113
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36-
with:
37-
tag_name: ${{ steps.get_version.outputs.VERSION }}
38-
release_name: ${{ steps.get_version.outputs.VERSION }}
39-
body: ${{ steps.changelog.outputs.changelog }}
40-
- name: Attach zip to release
41-
uses: actions/upload-release-asset@v1
114+
run: |
115+
gh release create ${{ inputs.release_version }} \
116+
--title "${{ inputs.release_version }}" \
117+
--notes "$(cat << 'EOM'
118+
${{ steps.changelog.outputs.changelog }}
119+
EOM
120+
)"
121+
122+
- name: Upload Release Asset
123+
if: ${{ inputs.publishToMarketPlace == 'true' }}
42124
env:
43125
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44-
with:
45-
upload_url: ${{ steps.create_release.outputs.upload_url }}
46-
asset_path: '${{ github.workspace }}/build/distributions/Telemetry by Red Hat-${{ steps.get_version.outputs.VERSION }}.zip'
47-
asset_name: 'Telemetry by Red Hat-${{ steps.get_version.outputs.VERSION }}.zip'
48-
asset_content_type: application/zip
126+
run: gh release upload ${{ inputs.release_version }} ./build/distributions/*

Jenkinsfile

-65
This file was deleted.

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![JetBrains plugins][plugin-version-svg]][plugin-repo]
88
[![JetBrains plugins][plugin-downloads-svg]][plugin-repo]
99

10-
This library provides Telemetry APIs specifically meant to be used by IDEA plugins developped by Red Hat.
10+
This library provides Telemetry APIs specifically meant to be used by IDEA plugins developed by Red Hat.
1111
## Telemetry reporting
1212
With your approval, plugins published by Red Hat collect anonymous
1313
[usage data](https://github.com/redhat-developer/intellij-redhat-telemetry/blob/master/USAGE_DATA.md)
@@ -77,7 +77,7 @@ You can then chain properties with their values to the point where you can send
7777
telemetry
7878
.property("kindness", "smurfette")
7979
.property("magic", "papa smurf")
80-
.send();
80+
.send();
8181
```
8282

8383
### Send special properties
@@ -86,28 +86,28 @@ There's no need for you to send those messages, it's all done for you behind the
8686

8787
Success may be used to indicate particular outcomes.
8888
```java
89-
telemetry.success("found the magic cauldron")
89+
telemetry.success("found the magic cauldron");
9090
```
9191
Errors are passed along similarly. Error and success are both mutually exclusive.
9292
```java
93-
telemetry.error("Gargamel was there")
93+
telemetry.error("Gargamel was there");
9494
```
9595
A duration may be provided to indicate how long an operation took. You start by signaling when the action started.
9696
```java
97-
telemetry.started()
97+
telemetry.started();
9898
```
9999
Once the action is finished you provide the end time to the message.
100100
```java
101-
telemetry.finished(LocalDateTime.now())
101+
telemetry.finished(LocalDateTime.now());
102102
```
103-
Not providing it won't harm, it'll done automatically for you.
103+
Not providing it won't harm, it'll be done automatically for you.
104104

105105
### Retrieve the anonymous User Id
106106
Each message sends an anonymous user id along with the other payloads.
107107
This type 4 UUID is automatically created and stored in a file at `~/.redhat/anonymousId`
108108
To retrieve it you can query the class `UserId`.
109109
```java
110-
String userId = UserId.INSTANCE.get()
110+
String userId = UserId.INSTANCE.get();
111111
```
112112

113113
### Add a link to telemetry preferences

build.gradle.kts

-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ java {
133133

134134
repositories {
135135
mavenLocal()
136-
maven { url = uri("https://repository.jboss.org") }
137136
mavenCentral()
138137
intellijPlatform {
139138
defaultRepositories()

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ nexusPassword=invalid
88
sinceIdeaBuild=211
99

1010
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
11-
ideaVersion=2024.2
11+
ideaVersion=2024.3
1212

1313
# Gradle Releases -> https://github.com/gradle/gradle/releases
1414
gradleVersion=8.5

0 commit comments

Comments
 (0)