Horis 2 vuotta sitten
vanhempi
commit
d3a488e385

+ 35 - 1
.github/workflows/test.yml

@@ -175,9 +175,43 @@ jobs:
           done
 
       - name: Delete Pre-Release
-        run: gh release delete beta -y --cleanup-tag
+        run: gh release delete beta -y
         env:
           GH_TOKEN: ${{ github.token }}
+      
+      - name: Create or update beta tag
+        uses: actions/github-script@v7
+        with:
+          script: |
+            const createReleaseTag = async (client: github.GitHub, refInfo: Octokit.GitCreateRefParams) => {
+              core.startGroup('Generating release tag');
+              const friendlyTagName = refInfo.ref.substring(10); // 'refs/tags/latest' => 'latest'
+              core.info(`Attempting to create or update release tag "${friendlyTagName}"`);
+
+              try {
+                await client.git.createRef(refInfo);
+              } catch (err: any) {
+                const existingTag = refInfo.ref.substring(5); // 'refs/tags/latest' => 'tags/latest'
+                core.info(
+                  `Could not create new tag "${refInfo.ref}" (${err.message}) therefore updating existing tag "${existingTag}"`,
+                );
+                await client.git.updateRef({
+                  ...refInfo,
+                  ref: existingTag,
+                  force: true,
+                });
+              }
+
+              core.info(`Successfully created or updated the release tag "${friendlyTagName}"`);
+              core.endGroup();
+            };
+
+            await createReleaseTag(client, {
+              owner: context.repo.owner,
+              ref: 'refs/tags/beta',
+              repo: context.repo.repo,
+              sha: context.sha,
+            });
 
       - name: Publish Pre-Release
         uses: ncipollo/release-action@v1

+ 2 - 2
app/src/main/java/io/legado/app/help/AppUpdateGitHub.kt

@@ -1,7 +1,6 @@
 package io.legado.app.help
 
 import androidx.annotation.Keep
-import com.google.gson.Gson
 import io.legado.app.constant.AppConst
 import io.legado.app.exception.NoStackTraceException
 import io.legado.app.help.config.AppConfig
@@ -11,6 +10,7 @@ import io.legado.app.help.http.okHttpClient
 import io.legado.app.model.AppReleaseInfo
 import io.legado.app.model.AppVariant
 import io.legado.app.model.GithubRelease
+import io.legado.app.utils.GSON
 import io.legado.app.utils.fromJsonObject
 import kotlinx.coroutines.CoroutineScope
 
@@ -38,7 +38,7 @@ object AppUpdateGitHub : AppUpdate.AppUpdateInterface {
         if (body.isNullOrBlank()) {
             throw NoStackTraceException("获取新版本出错")
         }
-        return Gson().fromJsonObject<GithubRelease>(body)
+        return GSON.fromJsonObject<GithubRelease>(body)
             .getOrElse {
                 throw NoStackTraceException("获取新版本出错 " + it.localizedMessage)
             }