Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: publish plugin using gitHub Action #103

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/IJ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
IJ: [ 2022.3, 2023.1, 2023.2, 2023.3, 2024.1, 2024.2 ]
IJ: [ 2022.3, 2023.1, 2023.2, 2023.3, 2024.1, 2024.2, 2024.3 ]
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
Expand Down
144 changes: 111 additions & 33 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,126 @@
name: Generate changelog and plugin archive for new release
name: Release Plugin
run-name: Release ${{ inputs.release_version }}

#Only one job at a time
concurrency: release

on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
publishToMarketPlace:
description: 'Publish to JetBrains Marketplace ?'
required: true
type: choice
options:
- 'true'
- 'false'
default: 'false'
release_version:
description: 'Release version'
required: true
type: string

jobs:
build:
# Prepare and publish the plugin to JetBrains Marketplace repository
release:
name: Publish new release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v4

# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: 11
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew buildPlugin
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
distribution: 'temurin'
java-version: 17

# Setup Gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
with:
add-job-summary: 'on-failure'
add-job-summary-as-pr-comment: 'on-failure'
validate-wrappers: true
gradle-home-cache-cleanup: true

- name: Tag Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.email "action@github.com"
git config user.name "GitHub Action"
if git diff --quiet; then
echo "No changes to commit."
else
git commit -sam "chore(skip-release): set version to ${{ inputs.release_version }}"
fi
git tag ${{ inputs.release_version }}
git push origin ${{ inputs.release_version }}

- name: Set Release Version
shell: bash
run: |
CURRENT_VERSION=$(grep "projectVersion=" gradle.properties | cut -d'=' -f2)
NEW_VERSION=${{ inputs.release_version }}.${{ github.run_number }}
awk -v current="$CURRENT_VERSION" -v new="$NEW_VERSION" 'BEGIN {FS=OFS="="} $1 == "projectVersion" { $2 = new }1' gradle.properties > tmpfile && mv tmpfile gradle.properties
echo "Release version: $NEW_VERSION"
echo "PLUGIN_VERSION=${NEW_VERSION}" >> $GITHUB_ENV

# Publish the plugin to JetBrains Marketplace
- name: Publish Plugin to JetBrains Marketplace
if: ${{ inputs.publishToMarketPlace == 'true' }}
env:
PUBLISH_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }}
run: |
./gradlew publishPlugin -PjetBrainsToken=$PUBLISH_TOKEN -PprojectVersion=$PLUGIN_VERSION -PjetBrainsChannel=stable
echo "Published $PLUGIN_VERSION to the Jetbrains Marketplace"

# Set next SNAPSHOT version
- name: Increment Plugin Version
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CURRENT_VERSION=$(grep "projectVersion=" gradle.properties | cut -d'=' -f2)
IFS="-" read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
IFS="." read -ra VERSION_NUM <<< "${VERSION_PARTS[0]}"
((VERSION_NUM[2]+=1))
NEW_VERSION="${VERSION_NUM[0]}.${VERSION_NUM[1]}.${VERSION_NUM[2]}-SNAPSHOT"
awk -v new_version="$NEW_VERSION" '/projectVersion=/{sub(/=.*/, "=" new_version)}1' gradle.properties > tmpfile && mv tmpfile gradle.properties
echo "Set $NEW_VERSION in gradle.properties"
git checkout -b $NEW_VERSION
git commit -sam "chore(skip-release): set version to $NEW_VERSION"
git push -u origin $NEW_VERSION
gh pr create -B main -H $NEW_VERSION --title "chore(skip-release): set version to $NEW_VERSION" --body 'Created by Github action'

- name: Simple conventional changelog
uses: redhat-developer/simple-conventional-changelog@0a6db1ac3910c2cf66f2e1a530951dba1ece8540 #0.0.12
id: changelog
with:
token: ${{ secrets.GITHUB_TOKEN }}
current-tag: ${{ steps.get_version.outputs.VERSION }}
current-tag: ${{ inputs.release_version }}
types-mapping: 'feat:Features,fix:Bug Fixes,docs:Documentation,refactor:Refactoring,chore:Other'
- run: |
echo '${{ steps.changelog.outputs.changelog }}'
- name: Create Release
id: create_release
uses: actions/create-release@v1

# Create a new GitHub release
- name: Create Github Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
release_name: ${{ steps.get_version.outputs.VERSION }}
body: ${{ steps.changelog.outputs.changelog }}
- name: Attach zip to release
uses: actions/upload-release-asset@v1
run: |
gh release create ${{ inputs.release_version }} \
--title "${{ inputs.release_version }}" \
--notes "$(cat << 'EOM'
${{ steps.changelog.outputs.changelog }}
EOM
)"

- name: Upload Release Asset
if: ${{ inputs.publishToMarketPlace == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: '${{ github.workspace }}/build/distributions/Telemetry by Red Hat-${{ steps.get_version.outputs.VERSION }}.zip'
asset_name: 'Telemetry by Red Hat-${{ steps.get_version.outputs.VERSION }}.zip'
asset_content_type: application/zip
run: gh release upload ${{ inputs.release_version }} ./build/distributions/*
65 changes: 0 additions & 65 deletions Jenkinsfile

This file was deleted.

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![JetBrains plugins][plugin-version-svg]][plugin-repo]
[![JetBrains plugins][plugin-downloads-svg]][plugin-repo]

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

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

Success may be used to indicate particular outcomes.
```java
telemetry.success("found the magic cauldron")
telemetry.success("found the magic cauldron");
```
Errors are passed along similarly. Error and success are both mutually exclusive.
```java
telemetry.error("Gargamel was there")
telemetry.error("Gargamel was there");
```
A duration may be provided to indicate how long an operation took. You start by signaling when the action started.
```java
telemetry.started()
telemetry.started();
```
Once the action is finished you provide the end time to the message.
```java
telemetry.finished(LocalDateTime.now())
telemetry.finished(LocalDateTime.now());
```
Not providing it won't harm, it'll done automatically for you.
Not providing it won't harm, it'll be done automatically for you.

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

### Add a link to telemetry preferences
Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ java {

repositories {
mavenLocal()
maven { url = uri("https://repository.jboss.org") }
mavenCentral()
intellijPlatform {
defaultRepositories()
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ nexusPassword=invalid
sinceIdeaBuild=211

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

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion=8.5
Expand Down
Loading