From 223416440bc87aa8f37516ed54a3e43da927abc3 Mon Sep 17 00:00:00 2001 From: Nikhil Unni Date: Wed, 16 Oct 2024 13:34:02 -0400 Subject: [PATCH] Support for CI + Publishing --- .github/workflows/publish.yml | 35 ++++++++++++++++++++++++++++++++++ build.gradle.kts | 36 ++++++++++++++++++++++++++++------- 2 files changed, 64 insertions(+), 7 deletions(-) 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..a892851 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,35 @@ +name: Build and Publish + +on: [push] + +jobs: + test: + name: 'Build and Publish' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v1 + with: + java-version: '17' + - name: Run build + run: ./gradlew build + - name: Archive Tests Results + uses: actions/upload-artifact@v3 + if: failure() + with: + name: Tests Results + path: "**/build/reports/tests/" + retention-days: 2 + - name: Publish JVM + run: ./gradlew publish + if: github.ref == 'refs/heads/main' + env: + GITHUB_USERNAME: ${{secrets.GITHUB_ACTOR}} + GITHUB_PASSWORD: ${{secrets.GITHUB_TOKEN}} + - name: Publish NPM + run: ./gradlew publishJsPackageToGithubRegistry + if: github.ref == 'refs/heads/main' + env: + GITHUB_USERNAME: ${{secrets.GITHUB_ACTOR}} + GITHUB_PASSWORD: ${{secrets.GITHUB_TOKEN}} diff --git a/build.gradle.kts b/build.gradle.kts index 4082986..fe74ff4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,11 +1,11 @@ plugins { kotlin("multiplatform") version "2.0.20" id("maven-publish") - id("io.github.gciatto.kt-npm-publish") version "0.3.2" + id("dev.petuska.npm.publish") version "3.4.3" } group = "com.brainera" -version = "1.0-SNAPSHOT" +version = "0.0.1" repositories { mavenCentral() @@ -58,11 +58,33 @@ kotlin { } } -npmPublishing { - token.set(System.getenv("NPM_AUTH_TOKEN")) +npmPublish { + registries { + register("github") { + uri.set("https://npm.pkg.github.com") + authToken.set(System.getenv("GITHUB_PASSWORD")) + } + } - liftPackageJson { - license = "Apache-2.0" - name = "@cortexapps/pseudonymizer" + packages { + named("js") { + packageJson { + license = "Apache-2.0" + name = "@cortexapps/pseudonymizer" + } + } + } +} + +publishing { + repositories { + maven { + name = "GithubPackages" + url = uri("https://maven.pkg.github.com/cortexapps/pseudonymizer") + credentials { + username = project.findProperty("gpr.user") as? String ?: System.getenv("GITHUB_USERNAME") + password = project.findProperty("gpr.key") as? String ?: System.getenv("GITHUB_PASSWORD") + } + } } }