Skip to content

Commit

Permalink
update cicl
Browse files Browse the repository at this point in the history
  • Loading branch information
reymondzzzz committed Nov 14, 2023
1 parent 429f25e commit 6df3f75
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ on:
# Trigger the workflow on any pull request
pull_request:
workflow_dispatch:
inputs:
eap:
required: true
description: "EAP"
default: 0
type: number

jobs:

Expand All @@ -15,6 +21,8 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
PUBLISH_EAP: ${{ github.event.inputs.eap }}
outputs:
version: ${{ steps.properties.outputs.version }}
changelog: ${{ steps.properties.outputs.changelog }}
Expand Down
22 changes: 12 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Release
on:
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
push:
Expand All @@ -17,6 +17,15 @@ jobs:
version: ${{ steps.properties.outputs.version }}
changelog: ${{ steps.properties.outputs.changelog }}
steps:
- name: Set env CHANNEL
shell: bash
run: |
GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
if [[ ${GIT_BRANCH} == "main" ]]; then
echo "PUBLISH_CHANNEL=eap" >> "$GITHUB_ENV"
else
echo "PUBLISH_CHANNEL=default" >> "$GITHUB_ENV"
fi
# Free GitHub Actions Environment Disk Space
- name: Maximize Build Space
Expand Down Expand Up @@ -93,10 +102,6 @@ jobs:
name: pluginVerifier-result
path: ${{ github.workspace }}/build/reports/pluginVerifier

# # Run Qodana inspections
# - name: Qodana - Code Inspection
# uses: JetBrains/[email protected]

# Prepare plugin archive content for creating artifact
- name: Prepare Plugin Artifact
id: artifact
Expand All @@ -118,13 +123,10 @@ jobs:
- name: Publish Plugin
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
PUBLISH_CHANNEL: ${{ env.PUBLISH_CHANNEL }}
PUBLISH_EAP: 1
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
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 }} ./build/distributions/*
20 changes: 13 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ tasks {
}

publishPlugin {
channels.set(listOf(System.getenv("PUBLISH_CHANNEL")))
token.set(System.getenv("PUBLISH_TOKEN"))
}
}
Expand All @@ -85,15 +86,20 @@ fun String.runCommand(

fun getVersionString(baseVersion: String): String {
val tag = "git tag -l --points-at HEAD".runCommand(workingDir = rootDir)
if (tag.isNotEmpty() && tag.contains(baseVersion)) return baseVersion
if (System.getenv("PUBLISH_EAP") != "1" &&
tag.isNotEmpty() && tag.contains(baseVersion)) return baseVersion

val branch = "git rev-parse --abbrev-ref HEAD".runCommand(workingDir = rootDir)
val commitId = "git rev-parse --short=8 HEAD".runCommand(workingDir = rootDir)
val numberOfCommits = if (branch == "main") {
val lastTag = "git describe --tags --abbrev=0 @^".runCommand(workingDir = rootDir)
"git rev-list ${lastTag}..HEAD --count".runCommand(workingDir = rootDir)
return if (System.getenv("PUBLISH_EAP") == "1") {
"$baseVersion-eap-$commitId"
} else {
"git rev-list --count HEAD ^origin/main".runCommand(workingDir = rootDir)
val branch = "git rev-parse --abbrev-ref HEAD".runCommand(workingDir = rootDir)
val numberOfCommits = if (branch == "main") {
val lastTag = "git describe --tags --abbrev=0 @^".runCommand(workingDir = rootDir)
"git rev-list ${lastTag}..HEAD --count".runCommand(workingDir = rootDir)
} else {
"git rev-list --count HEAD ^origin/main".runCommand(workingDir = rootDir)
}
"$baseVersion-$branch-$numberOfCommits-$commitId"
}
return "$baseVersion-$branch-$numberOfCommits-$commitId"
}

0 comments on commit 6df3f75

Please sign in to comment.