From 5aacaec63cc7db911675c1083997c5c6dab76cb3 Mon Sep 17 00:00:00 2001 From: Sergei Kharitontcev-Beglov Date: Thu, 23 May 2024 16:10:22 +0200 Subject: [PATCH] Added workflow for publishing --- .github/workflows/ci.yml | 20 ++++++++++++++++++++ .github/workflows/deploy.yml | 26 ++++++++++++++++++++++++++ build.gradle.kts | 11 ++++++++++- 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..aec28da --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,20 @@ +name: Continuous Integration +on: push +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + - name: Setup JDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + cache: 'gradle' + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + - name: Build the project + run: ./gradlew build \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..d29bfc4 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,26 @@ +name: Publish the library in Maven and make a release +on: + push: + tags: + - 'v**' +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + - name: Setup JDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + cache: 'gradle' + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + - name: Publish version to Maven + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_USERNAME: ${{ github.actor }} + run: ./gradlew publish diff --git a/build.gradle.kts b/build.gradle.kts index 61c8f77..72366f6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,11 +19,20 @@ publishing { create("runner") { groupId = "org.jetbrains.plan" artifactId = "experiment-runner" - version = "0.0.1" + version = project.version.toString() from(components["java"]) } } + repositories { + maven { + url = uri("https://maven.pkg.github.com/plan-research/kotlin-maven") + credentials { + username = project.findProperty("gpr.user")?.toString() ?: System.getenv("GITHUB_USERNAME") + password = project.findProperty("gpr.token")?.toString() ?: System.getenv("GITHUB_TOKEN") + } + } + } } tasks.test {