Skip to content

Commit

Permalink
Add gradle publish script and gitops
Browse files Browse the repository at this point in the history
  • Loading branch information
IdanKoblik committed Sep 6, 2024
1 parent 2ca4952 commit b7508e3
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 1 deletion.
41 changes: 41 additions & 0 deletions .github/workflows/callable.test.yml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -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 }}
11 changes: 11 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Push CI

on:
push:
branches:
- 'main'
- '3-gitops'

jobs:
unit_test:
uses: ./.github/workflows/callable.test.yml
57 changes: 56 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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<JavaLibraryPlugin>()
apply<MavenPublishPlugin>()

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<MavenPublication>("maven") {
artifactId = "gamma"

from(components["java"])
}
}
}

repositories {
mavenCentral()
Expand Down

0 comments on commit b7508e3

Please sign in to comment.