-
Notifications
You must be signed in to change notification settings - Fork 2
Set-up the build and release workflows #3
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b61778b
Set-up the release process
azatsarynnyy 5a3f572
Fix zip path
azatsarynnyy 8147499
Delete .DS_Store
azatsarynnyy 65213ab
Fix Copilot's review notes
azatsarynnyy c58c8e3
Fix the release job
azatsarynnyy d62a0e3
Update the release instruction in the README.md
azatsarynnyy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| # GitHub Actions Workflow is created for testing and preparing the plugin release draft. | ||
|
|
||
| name: Build | ||
| on: | ||
| # Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g., for dependabot pull requests) | ||
| push: | ||
| branches: [ main ] | ||
| # Trigger the workflow on any pull request | ||
| pull_request: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
|
|
||
| # Prepare environment and build the plugin | ||
| build: | ||
| name: Build | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| version: ${{ steps.properties.outputs.version }} | ||
| steps: | ||
|
|
||
| # Check out the current repository | ||
| - name: Fetch Sources | ||
| uses: actions/checkout@v6 | ||
|
|
||
| # Set up Java environment for the next steps | ||
| - name: Setup Java | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: zulu | ||
| java-version: 21 | ||
|
|
||
| # Setup Gradle | ||
| - name: Setup Gradle | ||
| uses: gradle/actions/setup-gradle@v6 | ||
|
|
||
| # Set environment variables | ||
| - name: Export Properties | ||
| id: properties | ||
| shell: bash | ||
| run: | | ||
| VERSION="$(grep '^version = ' plugin/build.gradle.kts | cut -d'"' -f2)" | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| # Build plugin | ||
| - name: Build plugin | ||
| run: ./gradlew packagePlugin | ||
|
|
||
| # Prepare plugin archive content for creating artifact | ||
| - name: Prepare Plugin Artifact | ||
| id: artifact | ||
| shell: bash | ||
| run: | | ||
| cd ${{ github.workspace }}/plugin/build/distributions | ||
| FILENAME=`ls *.zip` | ||
| unzip "$FILENAME" -d content | ||
|
|
||
| echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT | ||
|
|
||
| # Store already-built plugin as an artifact for downloading | ||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: ${{ steps.artifact.outputs.filename }} | ||
| path: ./plugin/build/distributions/content/*/* | ||
|
azatsarynnyy marked this conversation as resolved.
|
||
|
|
||
| # Prepare a draft release for GitHub Releases page for the manual verification. | ||
| # If accepted and published, release workflow would be triggered. | ||
| releaseDraft: | ||
| name: Release draft | ||
| if: github.event_name != 'pull_request' | ||
| needs: [ build ] | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
|
|
||
| # Check out the current repository | ||
| - name: Fetch Sources | ||
| uses: actions/checkout@v6 | ||
|
|
||
| # Remove old release drafts by using the curl request for the available releases with a draft flag | ||
| - name: Remove Old Release Drafts | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh api repos/{owner}/{repo}/releases \ | ||
| --jq '.[] | select(.draft == true) | .id' \ | ||
| | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{} | ||
|
|
||
| # Create a new release draft which is not publicly visible and requires manual acceptance | ||
| - name: Create Release Draft | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh release create "v${{ needs.build.outputs.version }}" \ | ||
| --draft \ | ||
| --title "v${{ needs.build.outputs.version }}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # GitHub Actions Workflow created for handling the release process based on the draft release prepared with the Build workflow. | ||
|
|
||
| name: Release | ||
| on: | ||
| release: | ||
| types: [prereleased, released] | ||
|
|
||
| jobs: | ||
|
|
||
| # Prepare and publish the plugin to JetBrains Marketplace | ||
| release: | ||
| name: Publish Plugin | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| steps: | ||
|
|
||
| # Check out the current repository | ||
| - name: Fetch Sources | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ github.event.release.tag_name }} | ||
|
|
||
| # Set up Java environment for the next steps | ||
| - name: Setup Java | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: zulu | ||
| java-version: 21 | ||
|
|
||
| # Setup Gradle | ||
| - name: Setup Gradle | ||
| uses: gradle/actions/setup-gradle@v6 | ||
|
|
||
| # Publish the plugin to JetBrains Marketplace | ||
| - name: Publish Plugin | ||
| env: | ||
| JETBRAINS_MARKETPLACE_PUBLISH_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }} | ||
| run: ./gradlew publishPlugin | ||
|
|
||
| # Upload artifact as a release asset | ||
| - name: Upload Release Asset | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: gh release upload ${{ github.event.release.tag_name }} ./plugin/build/distributions/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
build-logic/src/main/kotlin/toolbox/buildlogic/PublishToolboxPlugin.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| /* | ||
| * Copyright (c) 2026 Red Hat, Inc. | ||
| * This program and the accompanying materials are made | ||
| * available under the terms of the Eclipse Public License 2.0 | ||
| * which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * Red Hat, Inc. - initial API and implementation | ||
| */ | ||
| package com.redhat.devtools.toolbox.buildlogic | ||
|
|
||
| import org.gradle.api.DefaultTask | ||
| import org.gradle.api.Plugin | ||
| import org.gradle.api.Project | ||
| import org.gradle.api.file.RegularFileProperty | ||
| import org.gradle.api.provider.Property | ||
| import org.gradle.api.tasks.Input | ||
| import org.gradle.api.tasks.InputFile | ||
| import org.gradle.api.tasks.TaskAction | ||
| import org.gradle.api.tasks.bundling.Zip | ||
| import org.gradle.work.DisableCachingByDefault | ||
| import org.jetbrains.intellij.pluginRepository.PluginRepositoryFactory | ||
| import org.jetbrains.intellij.pluginRepository.model.LicenseUrl | ||
| import org.jetbrains.intellij.pluginRepository.model.ProductFamily | ||
|
|
||
| /** | ||
| * Gradle plugin that packages and publishes a JetBrains Toolbox plugin to the | ||
| * [JetBrains Marketplace](https://plugins.jetbrains.com). | ||
| */ | ||
| class PublishToolboxPlugin : Plugin<Project> { | ||
| override fun apply(target: Project) { | ||
| val packageTask = target.tasks.register("packagePlugin", Zip::class.java) { | ||
| dependsOn(target.tasks.named("assemble")) | ||
| from(target.layout.buildDirectory.file("generated/extension.json")) | ||
| from(target.file("src/main/resources")) { | ||
| include("dependencies.json") | ||
| include("icon.svg") | ||
| into("${target.group}") | ||
|
azatsarynnyy marked this conversation as resolved.
|
||
| } | ||
| from(target.tasks.named("jar")) { | ||
| into("${target.group}/lib") | ||
|
azatsarynnyy marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
| target.tasks.register("publishPlugin", PublishTask::class.java) { | ||
| dependsOn(packageTask) | ||
| extensionId.set(target.group.toString()) | ||
| pluginZipFile.set(packageTask.flatMap { it.archiveFile }) | ||
| vendor.set(target.extensions.extraProperties["vendor"].toString()) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Task that uploads the packaged plugin ZIP to the JetBrains Marketplace. | ||
| * | ||
| * Requires the `JETBRAINS_MARKETPLACE_PUBLISH_TOKEN` environment variable to be set. | ||
| * The token can be generated from your JetBrains Marketplace account. | ||
| */ | ||
| @DisableCachingByDefault(because = "Publishes plugin to JetBrains Marketplace") | ||
| abstract class PublishTask : DefaultTask() { | ||
| @get:Input | ||
| abstract val extensionId: Property<String> | ||
|
|
||
| /** Path to the plugin ZIP archive produced by the `packagePlugin` task. */ | ||
| @get:InputFile | ||
| abstract val pluginZipFile: RegularFileProperty | ||
|
|
||
| @get:Input | ||
| abstract val vendor: Property<String> | ||
|
|
||
| @TaskAction | ||
| fun publish() { | ||
| val jbMarketplaceToken: String? = System.getenv("JETBRAINS_MARKETPLACE_PUBLISH_TOKEN") | ||
| if (jbMarketplaceToken.isNullOrBlank()) { | ||
| error( | ||
| "Environment variable `JETBRAINS_MARKETPLACE_PUBLISH_TOKEN` is not set. " + "Please obtain a token from https://plugins.jetbrains.com and set it." | ||
| ) | ||
| } | ||
|
|
||
| println("Publishing plugin ${extensionId.get()} to JetBrains Marketplace...") | ||
|
|
||
|
azatsarynnyy marked this conversation as resolved.
|
||
| val instance = PluginRepositoryFactory.create( | ||
| "https://plugins.jetbrains.com", jbMarketplaceToken | ||
| ) | ||
|
|
||
| val existingPlugin = instance.pluginManager.getPluginByXmlId( | ||
| extensionId.get(), ProductFamily.TOOLBOX | ||
| ) | ||
|
|
||
| if (existingPlugin != null) { | ||
| instance.uploader.uploadUpdateByXmlIdAndFamily( | ||
| extensionId.get(), | ||
| ProductFamily.TOOLBOX, | ||
| pluginZipFile.get().asFile, | ||
| null, // channel – not yet supported for Toolbox plugins. | ||
| "Bug fixes and improvements", | ||
| false | ||
| ) | ||
| } else { | ||
| println("Plugin not found on Marketplace. Uploading as new plugin...") | ||
| instance.uploader.uploadNewPlugin( | ||
| pluginZipFile.get().asFile, | ||
| listOf("toolbox", "gateway"), // do not change | ||
| LicenseUrl.ECLIPSE_PUBLIC, | ||
| ProductFamily.TOOLBOX, | ||
| vendor = vendor.get(), | ||
| isHidden = true, | ||
| ) | ||
| } | ||
| println("Plugin published successfully!") | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.