在自动打包的时候添加提交hash #176 (#184)

* 删除不需要的re模块

* 添加编译过程中向源码添加提交hash的步骤

* 修正变量

* 整理代码
This commit is contained in:
scdhh
2021-08-10 03:38:59 +08:00
committed by GitHub
parent 57982d3c43
commit c1ce09ac52
3 changed files with 35 additions and 11 deletions

View File

@@ -9,14 +9,17 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: GetCommitID
- name: Get CommitID
run: |
$CommitID=git rev-parse --short "${{ GITHUB.SHA }}"
echo "CommitID=${CommitID}" >> $env:GITHUB_ENV
- name: GetVersion
- name: Get Version
run: |
$Version=python .github/workflows/getVersion.py
echo "Version=${Version}" >> $env:GITHUB_ENV
- name: Update Conf Version
run: |
python .github/workflows/updateConfVersion.py -H ${{ env.CommitID }}
- name: Download love
run: |
curl -OL https://github.com/love2d/love/releases/download/11.3/love-11.3-win64.zip
@@ -44,14 +47,17 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: GetCommitID
- name: Get CommitID
run: |
CommitID=$(git rev-parse --short "${{ GITHUB.SHA }}")
echo "CommitID=${CommitID}" >> $GITHUB_ENV
- name: GetVersion
- name: Get Version
run: |
Version=$(python3 .github/workflows/getVersion.py)
echo "Version=${Version}" >> $GITHUB_ENV
- name: Update Conf Version
run: |
python3 .github/workflows/updateConfVersion.py -H ${{ env.CommitID }}
- name: Download AppImageKit
run: curl -OL https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-x86_64.AppImage
- name: Unpack and Repack
@@ -75,14 +81,17 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: GetCommitID
- name: Get CommitID
run: |
CommitID=$(git rev-parse --short "${{ GITHUB.SHA }}")
echo "CommitID=${CommitID}" >> $GITHUB_ENV
- name: GetVersion
- name: Get Version
run: |
Version=$(python3 .github/workflows/getVersion.py)
echo "Version=${Version}" >> $GITHUB_ENV
- name: Update Conf Version
run: |
python3 .github/workflows/updateConfVersion.py -H ${{ env.CommitID }}
- name: Download Apktool
run: curl -OL https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.5.0.jar
- name: Unpack and Repack
@@ -95,8 +104,7 @@ jobs:
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
id: sign_app
name: Sign APK
with:
releaseDirectory: .
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
@@ -115,14 +123,17 @@ jobs:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v2
- name: GetCommitID
- name: Get CommitID
run: |
CommitID=$(git rev-parse --short "${{ GITHUB.SHA }}")
echo "CommitID=${CommitID}" >> $GITHUB_ENV
- name: GetVersion
- name: Get Version
run: |
Version=$(python3 .github/workflows/getVersion.py)
echo "Version=${Version}" >> $GITHUB_ENV
- name: Update Conf Version
run: |
python3 .github/workflows/updateConfVersion.py -H ${{ env.CommitID }}
- name: Pack love
run: |
zip -r Techmino.love document media parts Zframework conf.lua font.ttf main.lua

13
.github/workflows/updateConfVersion.py vendored Normal file
View File

@@ -0,0 +1,13 @@
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="用于更新conf.lua内编译版本号")
parser.add_argument("-H", "--Hash", type=str, help = "Github提交Hash")
args = parser.parse_args()
with open("conf.lua", "r+", encoding="utf-8") as file:
data = file.read()
data = data.replace('@DEV', f'@{args.Hash[0:4]}')
file.seek(0)
file.truncate()
file.flush()
file.write(data)

View File

@@ -1,4 +1,4 @@
import re, datetime
import datetime
import getVersion
info = r"""<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">