Skip to content

Commit

Permalink
try publishing EAPs with CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mkurnikov committed Apr 30, 2024
1 parent 96a58c2 commit 56fb59b
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 5 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: check
name: Check

on:
push:
Expand All @@ -10,10 +10,9 @@ jobs:
tests:
strategy:
matrix:
os: [ ubuntu-latest ]
gradle-properties-version: [ 232, 233 ]
gradle-properties-version: [ 232, 233, 241 ]

runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
env:
ORG_GRADLE_PROJECT_shortPlatformVersion: ${{ matrix.gradle-properties-version }}

Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/publish-eap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Publish EAP

on:
# only works on 'master' branch as it is a default branch
workflow_run:
workflows: [ Check ]
types:
- completed
branches:
- master

jobs:
check-for-tests-success:
runs-on: ubuntu-latest
permissions:
actions: write

steps:
- name: Early exit if tests wasn't successful
if: ${{ github.event.workflow_run.conclusion != 'success' }}
run: |
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


publish-eap-channel:
needs: [ check-for-tests-success ]
strategy:
matrix:
gradle-properties-version: [ 232, 233, 241 ]

runs-on: ubuntu-latest
env:
ORG_GRADLE_PROJECT_shortPlatformVersion: ${{ matrix.gradle-properties-version }}
JB_PUB_TOKEN: ${{ secrets.JB_PUB_TOKEN }}
JB_PUB_CHANNEL: eap

steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: 17

- name: Setup Gradle and dependencies
uses: gradle/actions/[email protected]
with:
gradle-version: wrapper
cache-read-only: false
arguments: ":resolveDependencies -Pkotlin.incremental=false --no-daemon"
gradle-home-cache-excludes: |
caches/modules-2/files-2.1/com.jetbrains.intellij.pycharm
caches/modules-2/files-2.1/com.jetbrains.intellij.idea
caches/modules-2/files-2.1/com.jetbrains.intellij.clion
- name: Build
uses: gradle/[email protected]
with:
gradle-version: wrapper
arguments: "assemble testClasses -Pkotlin.incremental=false --no-daemon --stacktrace"
gradle-home-cache-excludes: |
caches/modules-2/files-2.1/com.jetbrains.intellij.pycharm
caches/modules-2/files-2.1/com.jetbrains.intellij.idea
caches/modules-2/files-2.1/com.jetbrains.intellij.clion
- name: Publish to EAP channel
uses: gradle/[email protected]
with:
gradle-version: wrapper
arguments: ":plugin:publishPlugin -Pkotlin.incremental=false --no-daemon --stacktrace"
gradle-home-cache-excludes: |
caches/modules-2/files-2.1/com.jetbrains.intellij.pycharm
caches/modules-2/files-2.1/com.jetbrains.intellij.idea
caches/modules-2/files-2.1/com.jetbrains.intellij.clion
40 changes: 39 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,56 @@
import org.jetbrains.intellij.tasks.PrepareSandboxTask
import org.jetbrains.intellij.tasks.RunPluginVerifierTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.ByteArrayOutputStream
import java.util.*

val publishingToken = System.getenv("JB_PUB_TOKEN") ?: null
val publishingChannel = System.getenv("JB_PUB_CHANNEL") ?: "default"
// set by default in Github Actions
val isCI = System.getenv("CI") != null

fun prop(name: String): String =
extra.properties[name] as? String
?: error("Property `$name` is not defined in gradle.properties for environment `$shortPlatformVersion`")

fun gitHash(): String {
val byteOut = ByteArrayOutputStream()
project.exec {
commandLine = "git rev-parse --short HEAD".split(" ")
// commandLine = "git rev-parse --abbrev-ref HEAD".split(" ")
standardOutput = byteOut
}
return String(byteOut.toByteArray()).trim().also {
if (it == "HEAD")
logger.warn("Unable to determine current branch: Project is checked out with detached head!")
}
}

fun gitTimestamp(): String {
val byteOut = ByteArrayOutputStream()
project.exec {
commandLine = "git show --no-patch --format=%at HEAD".split(" ")
// commandLine = "git rev-parse --abbrev-ref HEAD".split(" ")
standardOutput = byteOut
}
return String(byteOut.toByteArray()).trim().also {
if (it == "HEAD")
logger.warn("Unable to determine current branch: Project is checked out with detached head!")
}
}

val shortPlatformVersion = prop("shortPlatformVersion")
val codeVersion = "1.36.0"
val pluginVersion = "$codeVersion.$shortPlatformVersion"

var pluginVersion = "$codeVersion.$shortPlatformVersion"
if (publishingChannel != "default") {
// timestamp of the commit with this eaps addition
val start = 1714498465
val commitTimestamp = gitTimestamp().toInt() - start
val commitHash = gitHash()
pluginVersion = "$pluginVersion-$publishingChannel.$commitTimestamp-$commitHash"
}

val pluginGroup = "org.move"
val javaVersion = JavaVersion.VERSION_17
val pluginJarName = "intellij-move-$pluginVersion"
Expand Down Expand Up @@ -225,6 +262,7 @@ project(":plugin") {

publishPlugin {
token.set(publishingToken)
channels.set(listOf(publishingChannel))
}

runIde { enabled = true }
Expand Down

0 comments on commit 56fb59b

Please sign in to comment.