Browse Source

Rake 'publish' task.

Yao Wei Tjong 姚伟忠 5 years ago
parent
commit
d518d45f60
5 changed files with 37 additions and 59 deletions
  1. 5 0
      .github/workflows/main.yml
  2. 10 0
      Rakefile
  3. 14 31
      android/urho3d-lib/build.gradle.kts
  4. 8 25
      build.gradle.kts
  5. 0 3
      settings.gradle.kts

+ 5 - 0
.github/workflows/main.yml

@@ -113,6 +113,11 @@ jobs:
             android/urho3d-lib/build/distributions/*.aar
             build/*.out
         if: github.event_name == 'push' || matrix.platform == 'linux-clang-tidy' == matrix.platform != 'linux-clang-format'
+      - name: Publish artifact
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: script/dockerized.sh ${PLATFORM/-*} rake ci publish
+        if: github.event_name == 'push' && matrix.platform == 'android'
   macOS:
     name: 🍏
     runs-on: macos-latest

+ 10 - 0
Rakefile

@@ -113,6 +113,16 @@ task :package do
   system %Q{#{wrapper} cmake --build "#{dir}" #{build_config} --target package} or abort
 end
 
+desc 'Publish build artifact'
+task :publish do
+  if ENV['PLATFORM'] == 'android'
+    Rake::Task['gradle'].invoke('publish')
+    next
+  end
+  init_default
+  abort "The 'publish' task is currently not supported on '#{ENV['PLATFORM']}' platform"
+end
+
 
 ### Internal tasks ###
 

+ 14 - 31
android/urho3d-lib/build.gradle.kts

@@ -25,7 +25,6 @@ import org.gradle.internal.os.OperatingSystem
 
 plugins {
     id("com.android.library")
-    id("com.jfrog.bintray")
     kotlin("android")
     kotlin("android.extensions")
     `maven-publish`
@@ -183,17 +182,16 @@ tasks {
 
 publishing {
     publications {
-        register<MavenPublication>("mavenAndroid") {
+        register<MavenPublication>("Urho") {
+            groupId = project.group.toString()
             artifactId = "${project.name}-${project.libraryType}"
             if (project.hasProperty("ANDROID_ABI")) {
                 artifactId = "$artifactId-${(project.property("ANDROID_ABI") as String).replace(',', '-')}"
             }
             afterEvaluate {
-                // Exclude publishing STATIC-debug AAR because its size exceeds 250MB limit allowed by Bintray
-                android.buildTypes
-                    .map { it.name }
-                    .filter { System.getenv("CI") == null || project.libraryType == "SHARED" || it == "release" }
-                    .forEach { artifact(tasks["zipBuildTree${it.capitalize()}"]) }
+                android.buildTypes.forEach {
+                    artifact(tasks["zipBuildTree${it.name.capitalize()}"])
+                }
             }
             artifact(tasks["sourcesJar"])
             artifact(tasks["documentationZip"])
@@ -226,32 +224,17 @@ publishing {
             }
         }
     }
-}
-
-bintray {
-    user = System.getenv("BINTRAY_USER")
-    key = System.getenv("BINTRAY_KEY")
-    publish = true
-    override = true
-    setPublications("mavenAndroid")
-    pkg.apply {
-        repo = "maven"
-        name = project.name
-        setLicenses("MIT")
-        vcsUrl = "https://github.com/urho3d/Urho3D.git"
-        userOrg = "urho3d"
-        setLabels("android", "game-development", "game-engine", "open-source", "urho3d")
-        websiteUrl = "https://urho3d.github.io/"
-        issueTrackerUrl = "https://github.com/urho3d/Urho3D/issues"
-        githubRepo = "urho3d/Urho3D"
-        publicDownloadNumbers = true
-        desc = project.description
-        version.apply {
-            name = project.version.toString()
-            desc = "Continuous delivery from GitHub Actions."
+    repositories {
+        maven {
+            name = "GitHubPackages"
+            url = uri("https://maven.pkg.github.com/urho3d/Urho3D")
+            credentials {
+                username = System.getenv("GITHUB_ACTOR")
+                password = System.getenv("GITHUB_TOKEN")
+            }
         }
     }
 }
 
 val Project.libraryType: String
-    get() = findProperty("URHO3D_LIB_TYPE") as String? ?: "STATIC"
+    get() = findProperty("URHO3D_LIB_TYPE") as String? ?: System.getenv("URHO3D_LIB_TYPE") ?: "static"

+ 8 - 25
build.gradle.kts

@@ -23,18 +23,13 @@
 import org.gradle.internal.io.NullOutputStream
 import java.io.ByteArrayOutputStream
 
-plugins {
-    base
-    // For some reasons the lint task requires bintray plugin to be declared here too in order to work as expected
-    id("com.jfrog.bintray") apply false
-}
-
 allprojects {
     group = "com.github.urho3d"
     version = determineVersion()
-    description = """Urho3D is a free lightweight,
-                    |cross-platform 2D and 3D game engine implemented in C++ and released under the MIT license.
-                    |Greatly inspired by OGRE and Horde3D.""".trimMargin().replace('\n', ' ')
+    description = """
+        Urho3D is a free lightweight, cross-platform 2D and 3D game engine implemented in C++ and
+        released under the MIT license. Greatly inspired by OGRE and Horde3D.
+    """.trimIndent().replace('\n', ' ')
     repositories {
         google()
         jcenter()
@@ -44,26 +39,14 @@ allprojects {
 /**
  * Find the most recent tag that is reachable from a commit and use that to set the Gradle's project version.
  *
- * e.g. commit described as "1.7-664-g34b1" will be mapped to "1.8-ROLLING" (rolling upgrades for the next version)
+ * e.g. commit described as "1.7-664-g34b1" will be mapped to "1.8-SNAPSHOT", (development snapshot for next version)
  *      tag "1.8" will be mapped to "1.8" as is (point release version), so does tag "1.8-RC" (release candidate)
  */
 fun determineVersion(): String {
-    // If it is explicitly specified then let return it instead
+    // If it is explicitly specified then use the specified version instead
     System.getenv("GRADLE_PROJECT_VERSION")?.let { return it }
-    // If it is on CI server then unshallow the clone's repo when necessary
-    if (System.getenv("CI") != null && System.getenv("RELEASE_TAG") == null) unshallowClone()
-    val desc = describeCommit(System.getenv("TRAVIS_COMMIT") ?: System.getenv("APPVEYOR_REPO_COMMIT"))
-    return Regex("^(.+?)-\\d").find(desc)?.destructured?.component1()?.let { "${bumpSemVer(it, 1)}-ROLLING" } ?: desc
-}
-
-/**
- * Unshallow the clone's repository and fetch all the tags.
- */
-fun unshallowClone() = exec {
-    commandLine = listOf("git", "fetch", "--tags", "--unshallow")
-    standardOutput = NullOutputStream.INSTANCE
-    errorOutput = NullOutputStream.INSTANCE
-    isIgnoreExitValue = true
+    val desc = describeCommit()
+    return Regex("^(.+?)-\\d").find(desc)?.destructured?.component1()?.let { "${bumpSemVer(it, 1)}-SNAPSHOT" } ?: desc
 }
 
 /**

+ 0 - 3
settings.gradle.kts

@@ -28,13 +28,10 @@ pluginManagement {
                     useModule("com.android.tools.build:gradle:4.0.1")
                 requested.id.id.startsWith("org.jetbrains.kotlin.") ->
                     useVersion(embeddedKotlinVersion)
-                requested.id.id == "com.jfrog.bintray" ->
-                    useVersion("1.8.5")
             }
         }
     }
     repositories {
-        @Suppress("UnstableApiUsage")
         gradlePluginPortal()
         google()
         jcenter()