From 9c566651eb840705be90af19e911bda4a1914079 Mon Sep 17 00:00:00 2001 From: Konstantin Aksenov Date: Tue, 19 Mar 2024 12:04:33 +1000 Subject: [PATCH] feat(flows): release flow init --- .github/workflows/publish_release.yml | 61 +++++++++++++++++++++++++++ danger-kotlin/build.gradle.kts | 28 ++++++------ 2 files changed, 77 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/publish_release.yml diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml new file mode 100644 index 00000000..5cf6054b --- /dev/null +++ b/.github/workflows/publish_release.yml @@ -0,0 +1,61 @@ +name: Release distribution + +on: + workflow_dispatch: + +jobs: + dangerKotlinLibrary-shadowJar: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: 8 + - name: danger-kotlin-library:shadowJar + run: ./gradlew danger-kotlin-library:shadowJar + - name: Upload Artifact lib + uses: actions/upload-artifact@v4 + with: + name: lib + path: danger-kotlin-library/build/libs/danger-kotlin.jar + + dangerKotlin-build: + needs: [ dangerKotlinLibrary-shadowJar ] + strategy: + fail-fast: false + matrix: + targetOS: [ linuxX64, macosX64, macosArm64, mingwX64 ] + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Download Artifact lib + uses: actions/download-artifact@v4 + with: + name: lib + + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: 8 + - name: danger-kotlin:build -PtargetOS="${{ matrix.targetOS }}" + run: ./gradlew danger-kotlin:build -PtargetOS="${{ matrix.targetOS }}" + - name: Prepare distribution package + run: | + mkdir -p dist + mkdir -p dist/lib/danger + mkdir -p dist/bin + ls -R + mv "danger-kotlin.jar" "dist/lib/danger" + mv "danger-kotlin/build/bin/runner/releaseExecutable/danger-kotlin.kexe" "dist/bin/danger-kotlin" + chmod +x dist/bin/danger-kotlin + - name: Zip target release + uses: actions/upload-artifact@v4 + with: + name: danger-kotlin-${{ matrix.targetOS }} + path: dist/* diff --git a/danger-kotlin/build.gradle.kts b/danger-kotlin/build.gradle.kts index 9959e77c..67c42d07 100644 --- a/danger-kotlin/build.gradle.kts +++ b/danger-kotlin/build.gradle.kts @@ -8,18 +8,22 @@ kotlin { * https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#setting-up-targets */ val targetOS: String by project - val osName = if (project.hasProperty("targetOS")) { - targetOS + val buildTarget = if (project.hasProperty("targetOS")) { + when (val osName = targetOS) { + "macosX64" -> macosX64("runner") + "linuxX64" -> linuxX64("runner") + "macosArm64" -> macosArm64("runner") + "mingwX64" -> mingwX64("runner") + else -> throw GradleException("OS '$osName' is not supported.") as Throwable + } } else { - System.getProperty("os.name") - } - - val buildTarget = when (osName) { - "Mac OS X" -> macosX64("runner") - "Linux" -> linuxX64("runner") - "Mac OS X Apple silicon" -> macosArm64("runner") - "Windows 11" -> mingwX64("runner") - else -> throw GradleException("OS '$osName' is not supported.") as Throwable + when (val osName = System.getProperty("os.name")) { + "Mac OS X" -> macosX64("runner") + "Linux" -> linuxX64("runner") + "Mac OS X Apple silicon" -> macosArm64("runner") + "Windows 11" -> mingwX64("runner") + else -> throw GradleException("OS '$osName' is not supported.") as Throwable + } } buildTarget.apply { @@ -41,4 +45,4 @@ kotlin { } } } -} \ No newline at end of file +}