diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 741f15cf..cdb1a8f6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: @@ -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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ffc3650c..5f375b07 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: @@ -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 @@ -93,10 +102,6 @@ jobs: name: pluginVerifier-result path: ${{ github.workspace }}/build/reports/pluginVerifier -# # Run Qodana inspections -# - name: Qodana - Code Inspection -# uses: JetBrains/qodana-action@v2022.3.4 - # Prepare plugin archive content for creating artifact - name: Prepare Plugin Artifact id: artifact @@ -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/* diff --git a/build.gradle.kts b/build.gradle.kts index ba33973a..ac1941e8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -61,6 +61,7 @@ tasks { } publishPlugin { + channels.set(listOf(System.getenv("PUBLISH_CHANNEL"))) token.set(System.getenv("PUBLISH_TOKEN")) } } @@ -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" }