From 10ac257466c2ab803419436a9a51ca1e278682dd Mon Sep 17 00:00:00 2001 From: Michal Harakal Date: Mon, 24 Mar 2025 21:02:19 +0100 Subject: [PATCH 1/4] Add initial version of publish --- .github/workflows/deploy.yml | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..f29c74d2 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,40 @@ +name: Publish to GitHub Packages + +on: [ push, pull_request ] + +jobs: + build-job: + runs-on: ubuntu-latest # enables hardware acceleration in the virtual machine + timeout-minutes: 30 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 17 + + + - name: Print git commit variables + run: | + echo "TAG: $CURRENT_TAG" + + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties + + - name: Build + run: ./gradlew --stacktrace clean assemble + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 + + - name: Publish package + run: ./gradlew publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From b765a1cfbb18d0a0c0edcd7d6a4071954bf3d8cb Mon Sep 17 00:00:00 2001 From: Michal Harakal Date: Tue, 25 Mar 2025 16:02:09 +0100 Subject: [PATCH 2/4] Publish to github --- .../src/main/kotlin/module.publication.gradle.kts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/convention-plugins/src/main/kotlin/module.publication.gradle.kts b/convention-plugins/src/main/kotlin/module.publication.gradle.kts index 02e645af..dbdd2d2f 100644 --- a/convention-plugins/src/main/kotlin/module.publication.gradle.kts +++ b/convention-plugins/src/main/kotlin/module.publication.gradle.kts @@ -8,6 +8,17 @@ plugins { } publishing { + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/sk-ai-net/skainet") + credentials { + username = System.getenv("USERNAME") + password = System.getenv("TOKEN") + } + + } + } // Configure all publications publications.withType { // Stub javadoc.jar artifact @@ -19,7 +30,6 @@ publishing { // Provide artifacts information required by Maven Central pom { name.set("skainet - Kotlin Multiplatform library") - licenses { license { name.set("MIT") From 46c9d303d10273480792d65285536c33602cf216 Mon Sep 17 00:00:00 2001 From: Michal Harakal Date: Tue, 25 Mar 2025 16:35:54 +0100 Subject: [PATCH 3/4] Publish to github with proper env variables --- .../src/main/kotlin/module.publication.gradle.kts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/convention-plugins/src/main/kotlin/module.publication.gradle.kts b/convention-plugins/src/main/kotlin/module.publication.gradle.kts index dbdd2d2f..ae5b99eb 100644 --- a/convention-plugins/src/main/kotlin/module.publication.gradle.kts +++ b/convention-plugins/src/main/kotlin/module.publication.gradle.kts @@ -13,10 +13,9 @@ publishing { name = "GitHubPackages" url = uri("https://maven.pkg.github.com/sk-ai-net/skainet") credentials { - username = System.getenv("USERNAME") - password = System.getenv("TOKEN") + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") } - } } // Configure all publications From 41ce9b63b4cb2c9ece95a951136af1225adb4f42 Mon Sep 17 00:00:00 2001 From: Michal Harakal Date: Tue, 25 Mar 2025 17:33:09 +0100 Subject: [PATCH 4/4] Use write permissions --- .github/workflows/deploy.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f29c74d2..b38b6b70 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,6 +7,10 @@ jobs: runs-on: ubuntu-latest # enables hardware acceleration in the virtual machine timeout-minutes: 30 + permissions: + contents: write + packages: write + steps: - name: Checkout uses: actions/checkout@v4