kitgit

tirbofish/dropbear · commit

1a056b4ac59b8e93a1a57d4cbe8f383e1610c052

fingers crossed this works: using github pages instead of github package repository (which required user auth) for publishing the package

Unverified

tk <4tkbytes@pm.me> · 2025-10-11 05:13

view full diff

diff --git a/.github/workflows/dokka_docs.yaml b/.github/workflows/dokka_docs.yaml
index ac1ccbe..b5dafac 100644
--- a/.github/workflows/dokka_docs.yaml
+++ b/.github/workflows/dokka_docs.yaml
@@ -1,10 +1,12 @@
-name: Deploy Dokka Documentation
+name: Publish Documentation and Maven Repository
 
 on:
   push:
     branches:
-      - main  # Change to your default branch if different
-  workflow_dispatch:  # Allows manual trigger
+      - main
+  release:
+    types: [created]
+  workflow_dispatch:
 
 permissions:
   contents: read
@@ -42,10 +44,37 @@ jobs:
       - name: Generate Dokka documentation
         run: ./gradlew dokkaGenerate
 
+      - name: Publish to Maven Local
+        run: ./gradlew publishAllPublicationsToGitHubPagesRepository
+
+      - name: Prepare GitHub Pages content
+        run: |
+          mkdir -p pages_content
+          # Copy Maven repo to root
+          cp -r build/repo/* pages_content/ || true
+          # Copy Dokka docs to /docs subdirectory
+          mkdir -p pages_content/docs
+          cp -r build/dokka/html/* pages_content/docs/ || true
+          # Create index.html that redirects to docs
+          cat > pages_content/index.html << 'EOF'
+          <!DOCTYPE html>
+          <html>
+          <head>
+            <meta charset="utf-8">
+            <title>Redirecting...</title>
+            <meta http-equiv="refresh" content="0; url=./docs/">
+            <link rel="canonical" href="./docs/">
+          </head>
+          <body>
+            <p>Redirecting to <a href="./docs/">documentation</a>...</p>
+          </body>
+          </html>
+          EOF
+
       - name: Upload artifact
         uses: actions/upload-pages-artifact@v4
         with:
-          path: ./build/dokka/html
+          path: ./pages_content
 
   deploy:
     environment:
diff --git a/build.gradle.kts b/build.gradle.kts
index 6965971..53e88f6 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -12,15 +12,6 @@ repositories {
     mavenCentral()
 }
 
-buildscript {
-    repositories {
-        mavenCentral()
-    }
-    dependencies {
-        classpath("io.github.cdimascio:dotenv-kotlin:6.4.1")
-    }
-}
-
 kotlin {
     jvm()
 
@@ -86,7 +77,7 @@ kotlin {
         binaries {
             sharedLib {
                 baseName = "dropbear"
-                
+
                 if (libDir != null && libNameForLinking != null) {
                     if (isMingwX64) {
                         linkerOpts("${libDir}/${libName}.lib")
@@ -113,7 +104,7 @@ kotlin {
         jvmMain {
             kotlin.srcDirs("src/jvmMain/kotlin", "src/jvmMain/java")
             dependencies {
-                
+
             }
         }
     }
@@ -146,34 +137,40 @@ tasks.register<JavaCompile>("generateJniHeaders") {
     dependsOn("compileKotlinJvm")
 }
 
-// switched to jitpack now :)
-//publishing {
-//    repositories {
-//        maven {
-//          name = "GitHubPackages"
-//            url = uri("https://maven.pkg.github.com/4tkbytes/dropbear")
-//
-//            val isPublishing = gradle.startParameter.taskNames.any {
-//                it.contains("publish", ignoreCase = true)
-//            }
-//
-//            if (isPublishing) {
-//                val dotenv = io.github.cdimascio.dotenv.dotenv()
-//                credentials {
-//                  username = dotenv["GITHUB_USERNAME"]
-//                  password = dotenv["GITHUB_TOKEN"]
-//              }
-//          }
-//        }
-//    }
-//
-//    publications {
-//        create<MavenPublication>("release") {
-//            groupId = group as String?
-//            artifactId = rootProject.name
-//            version = version
-//
-//            from(components["kotlin"])
-//        }
-//    }
-//}
+publishing {
+    repositories {
+        maven {
+            name = "GitHubPages"
+            url = uri(layout.buildDirectory.dir("repo"))
+        }
+    }
+
+    publications.withType<MavenPublication> {
+        pom {
+            name.set("dropbear")
+            description.set("The dropbear scripting part of the engine... uhh yeah!")
+            url.set("https://github.com/4tkbytes/dropbear")
+
+            licenses {
+                license {
+                    name.set("dropbear engine License, Version 1.2")
+                    url.set("https://raw.githubusercontent.com/4tkbytes/dropbear/refs/heads/main/LICENSE.md")
+                }
+            }
+
+            developers {
+                developer {
+                    id.set("4tkbytes")
+                    name.set("tk")
+                    email.set("4tkbytes@pm.me")
+                }
+            }
+
+            scm {
+                url.set("https://github.com/4tkbytes/dropbear")
+                connection.set("scm:git:git://github.com/4tkbytes/dropbear.git")
+                developerConnection.set("scm:git:ssh://git@github.com/4tkbytes/dropbear.git")
+            }
+        }
+    }
+}
\ No newline at end of file