diff --git a/.github/workflows/callable.test.yml b/.github/workflows/callable.test.yml new file mode 100644 index 0000000..d18a07e --- /dev/null +++ b/.github/workflows/callable.test.yml @@ -0,0 +1,41 @@ +name: Run tests + +on: + workflow_call: + +permissions: + contents: read + +jobs: + run_tests: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + - name: Run integration tests + run: ./gradlew test + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish Test Report + uses: mikepenz/action-junit-report@v4 + if: success() || failure() + with: + token: ${{ secrets.GITHUB_TOKEN }} + detailed_summary: true + follow_symlink: true + check_name: | + data + report_paths: | + **/data/build/test-results/test/TEST-*.xml + - name: Publish Test Report + uses: test-summary/action@v2 + if: success() || failure() + with: + paths: | + **/data/build/test-results/test/TEST-*.xml \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..2e8af94 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,23 @@ +name: Pull request CI + +on: + pull_request + +jobs: + unit_test: + uses: ./.github/workflows/callable.test.yml + + publish: + - needs: unit_test + - name: Checkout + uses: actions/checkout@v4 + - uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + - name: Run integration tests + run: ./gradlew publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..b375189 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,11 @@ +name: Push CI + +on: + push: + branches: + - 'main' + - '3-gitops' + +jobs: + unit_test: + uses: ./.github/workflows/callable.test.yml diff --git a/build.gradle.kts b/build.gradle.kts index f257ba0..8bf2868 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,13 +1,68 @@ plugins { `java-library` `maven-publish` + id("com.github.johnrengelman.shadow") version "8.1.1" } +val releaseWorkflow = "IdanKoblik/Gamma/.github/workflows/release.yml" +val snapshot: Boolean = System.getenv("GITHUB_WORKFLOW_REF") == null || !(System.getenv("GITHUB_WORKFLOW_REF").startsWith(releaseWorkflow)) +val isCi = System.getenv("GITHUB_ACTOR") != null + group = "com.github.idan.koblik" -version = "0.1-SNAPSHOT" +version = (if (System.getenv("VERSION") == null) "dev" else System.getenv("VERSION")) + (if (snapshot) "-SNAPSHOT" else "") allprojects { apply() + apply() + + publishing { + repositories { + if (isCi) { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/IdanKoblik/Gamma") + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + } + + if (isCi || project.findProperty("apartium.nexus.username") != null) { + if (snapshot) { + maven { + name = "ApartiumMaven" + url = uri("https://nexus.voigon.dev/repository/beta-snapshots") + credentials { + username = (System.getenv("APARTIUM_NEXUS_USERNAME") + ?: project.findProperty("apartium.nexus.username")).toString() + password = (System.getenv("APARTIUM_NEXUS_PASSWORD") + ?: project.findProperty("apartium.nexus.password")).toString() + } + } + } else { + maven { + name = "ApartiumMaven" + url = uri("https://nexus.voigon.dev/repository/beta-releases") + credentials { + username = (System.getenv("APARTIUM_NEXUS_USERNAME") + ?: project.findProperty("apartium.nexus.username")).toString() + password = (System.getenv("APARTIUM_NEXUS_PASSWORD") + ?: project.findProperty("apartium.nexus.password")).toString() + } + } + } + } + } + + publications { + create("maven") { + artifactId = "gamma" + + from(components["java"]) + } + } + } repositories { mavenCentral()