Просмотр исходного кода

Add script to publish to play store

世界 4 лет назад
Родитель
Сommit
100cff294b
5 измененных файлов с 87 добавлено и 4 удалено
  1. 56 1
      .github/workflows/release.yml
  2. 2 1
      .gitignore
  3. 27 2
      app/build.gradle
  4. 1 0
      app/src/main/play/release-notes/en-US/default.txt
  5. 1 0
      build.gradle

+ 56 - 1
.github/workflows/release.yml

@@ -197,4 +197,59 @@ jobs:
               wait $job || exit 1
             done
           }
-          upload apks/*.apk
+          upload apks/*.apk
+  play:
+    name: Publish to Play Store
+    if: github.event.inputs.upload != 'y'
+    runs-on: ubuntu-latest
+    needs:
+      - v2ray
+      - shadowsocks
+      - shadowsocksr
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+      - name: Setup Android SDK Tools
+        uses: android-actions/setup-android@v2
+      - name: Fetch Status
+        run: |
+          git submodule status 'shadowsocks/*' > shadowsocks_status
+          git submodule status 'shadowsocksr/*' > shadowsocksr_status
+          git submodule status v2ray > v2ray_status
+      - name: V2Ray Cache
+        uses: actions/cache@v2
+        with:
+          path: |
+            app/libs/libv2ray.aar
+          key: ${{ hashFiles('bin/libs/v2ray/*', 'v2ray_status') }}
+      - name: Shadowsocks Cache
+        uses: actions/cache@v2
+        with:
+          path: |
+            app/libs/shadowsocks-release.aar
+          key: ${{ hashFiles('shadowsocks_status') }}
+      - name: ShadowsocksR Cache
+        uses: actions/cache@v2
+        with:
+          path: |
+            app/libs/shadowsocksr-release.aar
+          key: ${{ hashFiles('shadowsocksr_status') }}
+      - name: Gradle cache
+        uses: actions/cache@v2
+        with:
+          path: ~/.gradle
+          key: gradle-${{ hashFiles('**/*.gradle') }}
+      - name: Checkout Library
+        run: |
+          git submodule update --init 'app/*'
+      - name: Debug Build
+        run: |
+          echo "sdk.dir=${ANDROID_HOME}" > local.properties
+          echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
+          export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}"
+          ./run update_assets
+          cat > service_account_credentials.json << EOF
+          ${{ secrets.ANDROID_PUBLISHER_CREDENTIALS }}"
+          EOF
+          ./gradlew app:publishRelease
+          echo "APK=$APK" >> $GITHUB_ENV

+ 2 - 1
.gitignore

@@ -14,4 +14,5 @@ build/
 .cxx
 local.properties
 /app/libs/
-/app/src/main/assets/v2ray
+/app/src/main/assets/v2ray
+/service_account_credentials.json

+ 27 - 2
app/build.gradle

@@ -6,6 +6,9 @@ plugins {
     id "com.mikepenz.aboutlibraries.plugin"
 }
 
+def verCode = 10
+def verName = "0.1-beta10"
+
 def keystorePwd = null
 def alias = null
 def pwd = null
@@ -30,6 +33,28 @@ keystorePwd = keystorePwd ?: System.getenv("KEYSTORE_PASS")
 alias = alias ?: System.getenv("ALIAS_NAME")
 pwd = pwd ?: System.getenv("ALIAS_PASS")
 
+def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")
+def beta = verName.contains("beta")
+if (serviceAccountCredentialsFile.isFile()) {
+    setupPlay(beta)
+    play.serviceAccountCredentials = serviceAccountCredentialsFile
+} else if (System.getenv().containsKey("ANDROID_PUBLISHER_CREDENTIALS")) {
+    setupPlay(beta)
+}
+
+void setupPlay(boolean beta) {
+    apply plugin: "com.github.triplet.play"
+    play {
+        track = "beta"
+    //    track = beta ? "beta" : "production"
+        defaultToAppBundles = true
+    }
+}
+
+configurations {
+    compile.exclude module: "support-v4"
+}
+
 android {
     compileSdkVersion 30
     buildToolsVersion "30.0.3"
@@ -38,8 +63,8 @@ android {
         applicationId "io.nekohasekai.sagernet"
         minSdkVersion 21
         targetSdkVersion 30
-        versionCode 9
-        versionName "0.1-beta9"
+        versionCode verCode
+        versionName verName
 
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
 

+ 1 - 0
app/src/main/play/release-notes/en-US/default.txt

@@ -0,0 +1 @@
+For changelog, please check messages in the telegram update channel @SagerNet.

+ 1 - 0
build.gradle

@@ -13,6 +13,7 @@ buildscript {
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
         classpath "gradle.plugin.org.mozilla.rust-android-gradle:plugin:0.8.3"
         classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:8.8.5"
+        classpath "com.github.triplet.gradle:play-publisher:3.0.0"
     }
 }