Przeglądaj źródła

Deploy master branch commits as snapshot (#1983)

* Deploy main branch commits as snapshot

* Snapshot builds don't have a Release artifact

* restrict snapshot to actual commits on master branch

* Deploy steps don't actually use test-run maven artifacts

* Partial Revert. We need that artifact
Sailsman63 2 lat temu
rodzic
commit
1641070465
2 zmienionych plików z 54 dodań i 2 usunięć
  1. 46 2
      .github/workflows/main.yml
  2. 8 0
      common.gradle

+ 46 - 2
.github/workflows/main.yml

@@ -206,9 +206,9 @@ jobs:
   # The snapshot is downloaded when people build the engine without setting buildNativeProject
   # The snapshot is downloaded when people build the engine without setting buildNativeProject
   # this is useful for people that want to build only the java part and don't have
   # this is useful for people that want to build only the java part and don't have
   # all the stuff needed to compile natives.
   # all the stuff needed to compile natives.
-  DeploySnapshot:
+  DeployNativeSnapshot:
     needs: [BuildJMonkey]
     needs: [BuildJMonkey]
-    name: "Deploy snapshot"
+    name: "Deploy native snapshot"
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
     if: github.event_name == 'push'
     if: github.event_name == 'push'
     steps:
     steps:
@@ -291,6 +291,50 @@ jobs:
             fi
             fi
           fi
           fi
 
 
+  # This job deploys snapshots on the master branch
+  DeployJavaSnapshot:
+    needs: [BuildJMonkey]
+    name: Deploy Java Snapshot
+    runs-on: ubuntu-latest
+    if: github.event_name == 'push' && github.ref_name == 'master'
+    steps:
+
+      # We need to clone everything again for uploadToMaven.sh ...
+      - name: Clone the repo
+        uses: actions/checkout@v3
+        with:
+          fetch-depth: 1
+
+      # Setup jdk 17 used for building Maven-style artifacts
+      - name: Setup the java environment
+        uses: actions/setup-java@v3
+        with:
+          distribution: 'temurin'
+          java-version: '17'
+
+      - name: Download natives for android
+        uses: actions/download-artifact@master
+        with:
+          name: android-natives
+          path: build/native
+
+      - name: Rebuild the maven artifacts and deploy them to the Sonatype repository
+        run: |
+          if [ "${{ secrets.OSSRH_PASSWORD }}" = "" ];
+          then
+            echo "Configure the following secrets to enable deployment to Sonatype:"
+            echo "OSSRH_PASSWORD, OSSRH_USERNAME, SIGNING_KEY, SIGNING_PASSWORD"
+          else
+            ./gradlew publishMavenPublicationToSNAPSHOTRepository \
+            -PossrhPassword=${{ secrets.OSSRH_PASSWORD }} \
+            -PossrhUsername=${{ secrets.OSSRH_USERNAME }} \
+            -PsigningKey='${{ secrets.SIGNING_KEY }}' \
+            -PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
+            -PuseCommitHashAsVersionName=true \
+            --console=plain --stacktrace
+          fi
+
+
   # This job deploys the release
   # This job deploys the release
   DeployRelease:
   DeployRelease:
     needs: [BuildJMonkey]
     needs: [BuildJMonkey]

+ 8 - 0
common.gradle

@@ -171,6 +171,14 @@ publishing {
             name = 'OSSRH'
             name = 'OSSRH'
             url = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2'
             url = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2'
         }
         }
+	maven {
+	    credentials {
+                username = gradle.rootProject.hasProperty('ossrhUsername') ? ossrhUsername : 'Unknown user'
+                password = gradle.rootProject.hasProperty('ossrhPassword') ? ossrhPassword : 'Unknown password'
+	    }
+	    name = 'SNAPSHOT'
+	    url = 'https://oss.sonatype.org/content/repositories/snapshots/'
+	}
     }
     }
 }
 }