From a71b5045894c085f2b92d077e2fd93305e01cdbf Mon Sep 17 00:00:00 2001 From: shoucandanghehe Date: Mon, 9 Aug 2021 07:10:40 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9actions=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=EF=BC=8C=E4=BF=AE=E6=94=B9=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E6=97=B6=E4=BE=9D=E8=B5=96=E7=9A=84python=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 69 ++++++++++++++----- .github/workflows/getVersion.bat | 2 + .github/workflows/getVersion.py | 11 +++ ...dateVersion.py => updateAndroidVersion.py} | 10 +-- .github/workflows/updateOSXVersion.py | 8 +-- 5 files changed, 75 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/getVersion.bat create mode 100644 .github/workflows/getVersion.py rename .github/workflows/{updateVersion.py => updateAndroidVersion.py} (57%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e3e39829..d185e613 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,21 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v2 + - name: GetCommitID + #这里找不到好办法用git获取CommitID,就直接截取了 + #如果有好办法的话欢迎pr( + #之前尝试用的: + #for /F %%i in ('git rev-parse --short "${{ GITHUB.SHA }}"') do (set CommitID=%%i) + #失败原因: + #直接powershell运行报错,使用bat运行会获取不到${{ GITHUB.SHA }} + run: | + $CommitID="${{ GITHUB.SHA }}".Substring(0,7) + echo $CommitID > test.txt + echo "CommitID=$CommitID" + echo "CommitID=$CommitID" >> $env:GITHUB_ENV + - name: GetVersion + run: | + .\.github\workflows\getVersion.bat - name: Download love run: | curl -OL https://github.com/love2d/love/releases/download/11.3/love-11.3-win64.zip @@ -26,16 +41,24 @@ jobs: copy /b love-11.3-win64\love.exe + game.love love-11.3-win64\Techmino.exe del love-11.3-win64\love.exe del love-11.3-win64\lovec.exe - - name: Artifact - uses: actions/upload-artifact@v1.0.0 + - name: Upload + uses: actions/upload-artifact@v2 with: - name: Windows + name: Techmino_${{ env.Version }}_${{ env.CommitID }}_Windows path: love-11.3-win64 build-linux: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 + - name: GetCommitID + run: | + CommitID=$(git rev-parse --short "${{ GITHUB.SHA }}") + echo "CommitID=${CommitID}" >> $GITHUB_ENV + - name: GetVersion + run: | + Version=$(python3 getVersion.py) + echo "Version=${Version}" >> $GITHUB_ENV - name: Download AppImageKit run: curl -OL https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-x86_64.AppImage - name: Unpack and Repack @@ -49,16 +72,24 @@ jobs: cd ../../../.. cp -r document media parts Zframework conf.lua font.ttf main.lua squashfs-root/usr/share/Techmino ./appimagetool-x86_64.AppImage squashfs-root Techmino.AppImage - - name: Artifact + - name: Upload uses: actions/upload-artifact@v2 with: - name: Linux + name: Techmino_${{ env.Version }}_${{ env.CommitID }}_Linux path: Techmino.AppImage build-android: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 + - name: GetCommitID + run: | + CommitID=$(git rev-parse --short "${{ GITHUB.SHA }}") + echo "CommitID=${CommitID}" >> $GITHUB_ENV + - name: GetVersion + run: | + Version=$(python3 getVersion.py) + echo "Version=${Version}" >> $GITHUB_ENV - name: Download Apktool run: curl -OL https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.5.0.jar - name: Unpack and Repack @@ -68,7 +99,7 @@ jobs: 7z x -o. apk/assets/game.love libAndroid rm apk/assets/game.love Techmino.apk 7z a -tzip apk/assets/game.love document libAndroid media parts Zframework conf.lua font.ttf main.lua - python3 .github/workflows/updateVersion.py + python3 .github/workflows/updateAndroidVersion.py java -jar apktool_2.5.0.jar b -o Techmino.apk apk - uses: 26F-Studio/sign-android-release@master name: Sign app APK @@ -81,18 +112,27 @@ jobs: keyPassword: ${{ secrets.KEY_PASSWORD }} env: BUILD_TOOLS_VERSION: "30.0.2" - - name: Artifact + - name: Upload uses: actions/upload-artifact@v2 with: - name: Android + name: Techmino_${{ env.Version }}_${{ env.CommitID }}_Android path: ${{steps.sign_app.outputs.signedReleaseFile}} build-macOS: runs-on: macos-10.15 steps: - uses: actions/checkout@v2 + - name: GetCommitID + run: | + CommitID=$(git rev-parse --short "${{ GITHUB.SHA }}") + echo "CommitID=${CommitID}" >> $GITHUB_ENV + - name: GetVersion + run: | + Version=$(python3 getVersion.py) + echo "Version=${Version}" >> $GITHUB_ENV - name: Pack love - run : zip -r Techmino.love document media parts Zframework conf.lua font.ttf main.lua + run: | + zip -r Techmino.love document media parts Zframework conf.lua font.ttf main.lua - name: Download template run: | curl -OL https://github.com/26F-Studio/Techmino/releases/download/v0.15.1/Techmino.app.zip @@ -116,11 +156,8 @@ jobs: security import certificate.p12 -k build.keychain -P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k Techminohaowan build.keychain /usr/bin/codesign --force --deep -s 79B81FC5EA155243C973B5417B0996501F00EF55 ./Techmino.app -v - - name: Pack Techmino - run: | - zip -r -y Techmino-Packed.app.zip Techmino.app - - name: Artifact - uses: actions/upload-artifact@v1.0.0 + - name: Upload + uses: actions/upload-artifact@v2 with: - name: macOS - path: Techmino-Packed.app.zip + name: Techmino_${{ env.Version }}_${{ env.CommitID }}_macOS + path: Techmino-Packed.app \ No newline at end of file diff --git a/.github/workflows/getVersion.bat b/.github/workflows/getVersion.bat new file mode 100644 index 00000000..6f052321 --- /dev/null +++ b/.github/workflows/getVersion.bat @@ -0,0 +1,2 @@ +for /F %%i in ('python .github/workflows/getVersion.py') do (set Version=%%i) +echo Version=%Version% \ No newline at end of file diff --git a/.github/workflows/getVersion.py b/.github/workflows/getVersion.py new file mode 100644 index 00000000..772c2b3a --- /dev/null +++ b/.github/workflows/getVersion.py @@ -0,0 +1,11 @@ +import re +def getVersion(): + with open("conf.lua", "r", encoding="utf-8") as file: + data = file.read() + versionCode = re.search("build=(\\d+)", data).group() + versionName = re.search('(?<=string=").*(?=@)', data).group() + return versionCode, versionName + +if __name__ == "__main__": + versionCode, versionName = getVersion() + print (versionName) \ No newline at end of file diff --git a/.github/workflows/updateVersion.py b/.github/workflows/updateAndroidVersion.py similarity index 57% rename from .github/workflows/updateVersion.py rename to .github/workflows/updateAndroidVersion.py index 6d34ddbe..e785d166 100644 --- a/.github/workflows/updateVersion.py +++ b/.github/workflows/updateAndroidVersion.py @@ -1,12 +1,12 @@ import re -with open("conf.lua", "r") as file: - data = file.read() -versionCode = re.search("build=(\\d+)", data).group(1) -versionName = re.search('short="([^"]+)', data).group(1) +import getVersion + +versionCode, versionName = getVersion.getVersion() + with open("apk/apktool.yml", "r+") as file: data = file.read() data = re.sub("versionCode:.+", f"versionCode: '{versionCode}'", data) data = re.sub("versionName:.+", f"versionName: {versionName}", data) file.seek(0) file.truncate() - file.write(data) + file.write(data) \ No newline at end of file diff --git a/.github/workflows/updateOSXVersion.py b/.github/workflows/updateOSXVersion.py index c550e324..f3281a5c 100644 --- a/.github/workflows/updateOSXVersion.py +++ b/.github/workflows/updateOSXVersion.py @@ -1,4 +1,5 @@ import re, datetime +import getVersion info = r""" @@ -57,9 +58,8 @@ info = r""" """ -with open("conf.lua", "r") as file: - data = file.read() -versionName = re.search('short="([^"]+)', data).group(1) +versionCode, versionName = getVersion.getVersion() + print("Updating to", versionName) with open("Techmino.app/Contents/info.plist", "w") as file: - file.write(info % (versionName, datetime.datetime.today().year)) + file.write(info % (versionName, datetime.datetime.today().year)) \ No newline at end of file From a37e164c0b1d9bb57a93d97e26b4cecc24a8b242 Mon Sep 17 00:00:00 2001 From: shoucandanghehe Date: Mon, 9 Aug 2021 07:12:43 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E6=AD=A3python=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d185e613..3be0413b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,7 +57,7 @@ jobs: echo "CommitID=${CommitID}" >> $GITHUB_ENV - name: GetVersion run: | - Version=$(python3 getVersion.py) + Version=$(python3 .github/workflows/getVersion.py) echo "Version=${Version}" >> $GITHUB_ENV - name: Download AppImageKit run: curl -OL https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-x86_64.AppImage @@ -88,7 +88,7 @@ jobs: echo "CommitID=${CommitID}" >> $GITHUB_ENV - name: GetVersion run: | - Version=$(python3 getVersion.py) + Version=$(python3 .github/workflows/getVersion.py) echo "Version=${Version}" >> $GITHUB_ENV - name: Download Apktool run: curl -OL https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.5.0.jar @@ -128,7 +128,7 @@ jobs: echo "CommitID=${CommitID}" >> $GITHUB_ENV - name: GetVersion run: | - Version=$(python3 getVersion.py) + Version=$(python3 .github/workflows/getVersion.py) echo "Version=${Version}" >> $GITHUB_ENV - name: Pack love run: | From 8d74a35f29a5f758849742d8a210d532ac408723 Mon Sep 17 00:00:00 2001 From: shoucandanghehe Date: Mon, 9 Aug 2021 07:17:19 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=B7=BB=E5=8A=A0version=E8=87=B3=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/getVersion.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/getVersion.bat b/.github/workflows/getVersion.bat index 6f052321..102a7731 100644 --- a/.github/workflows/getVersion.bat +++ b/.github/workflows/getVersion.bat @@ -1,2 +1,2 @@ for /F %%i in ('python .github/workflows/getVersion.py') do (set Version=%%i) -echo Version=%Version% \ No newline at end of file +echo Version=%Version% >> $env:GITHUB_ENV \ No newline at end of file From ebc4e08986c38978f00764383231301d5592d97b Mon Sep 17 00:00:00 2001 From: shoucandanghehe Date: Mon, 9 Aug 2021 07:39:26 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BD=BF=E7=94=A8python?= =?UTF-8?q?=E8=A7=A3=E5=86=B3bat=E6=97=A0=E6=B3=95=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 2 +- .github/workflows/windowsGetVersion.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/windowsGetVersion.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3be0413b..729fbcdb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: echo "CommitID=$CommitID" >> $env:GITHUB_ENV - name: GetVersion run: | - .\.github\workflows\getVersion.bat + python .github/workflows/windowsGetVersion.py - name: Download love run: | curl -OL https://github.com/love2d/love/releases/download/11.3/love-11.3-win64.zip diff --git a/.github/workflows/windowsGetVersion.py b/.github/workflows/windowsGetVersion.py new file mode 100644 index 00000000..13c447ce --- /dev/null +++ b/.github/workflows/windowsGetVersion.py @@ -0,0 +1,6 @@ +import os +import getVersion + +versionCode, versionName = getVersion.getVersion() + +os.system(f'echo Version={versionName} >> $env:GITHUB_ENV') \ No newline at end of file From b3ef90237fa0a468b2bd2b533338a1f79dbb0ff0 Mon Sep 17 00:00:00 2001 From: shoucandanghehe Date: Mon, 9 Aug 2021 07:52:42 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=8F=88=E6=8D=A2=E5=9B=9E=E4=BA=86bat?= =?UTF-8?q?=E5=B0=9D=E8=AF=95=E8=A7=A3=E5=86=B3=E6=97=A0=E6=B3=95=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8F=98=E9=87=8F=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 2 +- .github/workflows/getVersion.bat | 2 +- .github/workflows/windowsGetVersion.py | 6 ------ 3 files changed, 2 insertions(+), 8 deletions(-) delete mode 100644 .github/workflows/windowsGetVersion.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 729fbcdb..3be0413b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: echo "CommitID=$CommitID" >> $env:GITHUB_ENV - name: GetVersion run: | - python .github/workflows/windowsGetVersion.py + .\.github\workflows\getVersion.bat - name: Download love run: | curl -OL https://github.com/love2d/love/releases/download/11.3/love-11.3-win64.zip diff --git a/.github/workflows/getVersion.bat b/.github/workflows/getVersion.bat index 102a7731..26ae5276 100644 --- a/.github/workflows/getVersion.bat +++ b/.github/workflows/getVersion.bat @@ -1,2 +1,2 @@ for /F %%i in ('python .github/workflows/getVersion.py') do (set Version=%%i) -echo Version=%Version% >> $env:GITHUB_ENV \ No newline at end of file +powershell -Command echo "Version=%Version%" >> $env:GITHUB_ENV \ No newline at end of file diff --git a/.github/workflows/windowsGetVersion.py b/.github/workflows/windowsGetVersion.py deleted file mode 100644 index 13c447ce..00000000 --- a/.github/workflows/windowsGetVersion.py +++ /dev/null @@ -1,6 +0,0 @@ -import os -import getVersion - -versionCode, versionName = getVersion.getVersion() - -os.system(f'echo Version={versionName} >> $env:GITHUB_ENV') \ No newline at end of file From e28894549cb89199c35e32017827de8b4bf0a2db Mon Sep 17 00:00:00 2001 From: shoucandanghehe Date: Mon, 9 Aug 2021 08:16:11 +0800 Subject: [PATCH 6/7] =?UTF-8?q?C=20M=20D=20=E5=AE=B3=20=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 13 +++---------- .github/workflows/getVersion.bat | 2 -- 2 files changed, 3 insertions(+), 12 deletions(-) delete mode 100644 .github/workflows/getVersion.bat diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3be0413b..982ead21 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,20 +10,13 @@ jobs: steps: - uses: actions/checkout@v2 - name: GetCommitID - #这里找不到好办法用git获取CommitID,就直接截取了 - #如果有好办法的话欢迎pr( - #之前尝试用的: - #for /F %%i in ('git rev-parse --short "${{ GITHUB.SHA }}"') do (set CommitID=%%i) - #失败原因: - #直接powershell运行报错,使用bat运行会获取不到${{ GITHUB.SHA }} run: | - $CommitID="${{ GITHUB.SHA }}".Substring(0,7) - echo $CommitID > test.txt - echo "CommitID=$CommitID" + $CommitID=git rev-parse --short "${{ GITHUB.SHA }}" echo "CommitID=$CommitID" >> $env:GITHUB_ENV - name: GetVersion run: | - .\.github\workflows\getVersion.bat + $Version=python .github/workflows/getVersion.py + echo "Version=$Version" >> $env:GITHUB_ENV - name: Download love run: | curl -OL https://github.com/love2d/love/releases/download/11.3/love-11.3-win64.zip diff --git a/.github/workflows/getVersion.bat b/.github/workflows/getVersion.bat deleted file mode 100644 index 26ae5276..00000000 --- a/.github/workflows/getVersion.bat +++ /dev/null @@ -1,2 +0,0 @@ -for /F %%i in ('python .github/workflows/getVersion.py') do (set Version=%%i) -powershell -Command echo "Version=%Version%" >> $env:GITHUB_ENV \ No newline at end of file From d649a0caa1c0440e807756fbb435289ce98a615a Mon Sep 17 00:00:00 2001 From: shoucandanghehe Date: Mon, 9 Aug 2021 08:21:31 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 982ead21..40c2836e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,11 +12,11 @@ jobs: - name: GetCommitID run: | $CommitID=git rev-parse --short "${{ GITHUB.SHA }}" - echo "CommitID=$CommitID" >> $env:GITHUB_ENV + echo "CommitID=${CommitID}" >> $env:GITHUB_ENV - name: GetVersion run: | $Version=python .github/workflows/getVersion.py - echo "Version=$Version" >> $env:GITHUB_ENV + echo "Version=${Version}" >> $env:GITHUB_ENV - name: Download love run: | curl -OL https://github.com/love2d/love/releases/download/11.3/love-11.3-win64.zip