From 84c3a635d4cf972452560de1ab84a35e9d35be1d Mon Sep 17 00:00:00 2001 From: Stypox Date: Mon, 27 May 2024 15:09:27 +0200 Subject: [PATCH] Add GitHub action to build artifact --- .github/workflows/publish.yml | 30 ++++++++++++++++++++++++++++++ numbers/build.gradle.kts | 24 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..8fec2a3 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,30 @@ +name: CI + +on: + push: + branches: + - master + workflow_dispatch: + +permissions: + contents: read + +jobs: + build-and-test: + runs-on: ubuntu-latest + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Publish package + run: ./gradlew publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMMIT_SHA: ${{ vars.GITHUB_SHA }} diff --git a/numbers/build.gradle.kts b/numbers/build.gradle.kts index c662710..15b42d1 100644 --- a/numbers/build.gradle.kts +++ b/numbers/build.gradle.kts @@ -1,8 +1,14 @@ +import java.net.URI + plugins { alias(libs.plugins.org.jetbrains.kotlin.jvm) id("java-library") + id("maven-publish") } +group = "org.dicio" +version = System.getenv("COMMIT_SHA") + kotlin { jvmToolchain(17) } @@ -11,3 +17,21 @@ dependencies { implementation(libs.nanojson) testImplementation(libs.junit) } + +publishing { + repositories { + maven { + name = "GitHubPackages" + url = URI("https://maven.pkg.github.com/octocat/hello-world") + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + } + publications { + create("mavenJava") { + from(components["java"]) + } + } +}