From 221dda18d981c1dd591e2012f6fbf3d4f8cacb66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Sat, 27 Apr 2024 19:56:54 +0800 Subject: [PATCH] auto load version --- .github/workflows/build.yml | 1 - .github/workflows/release.yml | 13 +++++-------- build.py | 8 +++++++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7e2726da..a1480460 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,6 @@ jobs: build: runs-on: windows-latest strategy: - # 矩阵配置 matrix: include: - architecture: x86 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f25ef660..35f537ff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,18 +1,12 @@ name: Release on: - workflow_dispatch: # allows manual triggering - inputs: - create_release: - description: 'Create new release' - required: true - type: string + workflow_dispatch: jobs: build: runs-on: windows-latest strategy: - # 矩阵配置 matrix: include: - architecture: x86 @@ -46,10 +40,13 @@ jobs: name: ${{ matrix.fname }} path: build/${{ matrix.fname }}.zip + - name: loaddversion + id: loaddversion + run: python build.py loaddversion - name: Release LunaTranslator uses: softprops/action-gh-release@v2 with: - tag_name: ${{ github.event.inputs.create_release }} + tag_name: ${{ steps.loaddversion.outputs.version }} files: build/${{ matrix.fname }}.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.py b/build.py index 0bf2191d..1eb360d4 100644 --- a/build.py +++ b/build.py @@ -1,5 +1,5 @@ import os, sys -import shutil +import shutil, json import subprocess import requests @@ -209,6 +209,12 @@ def buildPlugins(): if __name__ == "__main__": + if sys.argv[1]=='loaddversion': + os.chdir(rootDir) + with open('LunaTranslator/files/defaultconfig/static_data.json','r',encoding='utf8') as ff: + version=json.loads(ff.read())['version'] + print('::set-output name=version::'+version) + exit() arch = sys.argv[1] isdebug=len(sys.argv)>2 and int(sys.argv[2]) os.chdir(rootDir)