Files
Techmino/.github/workflows/updateVersion.py
Particle_G e236be7a62 Ci ios (#395)
* merge get-cc-url into get-version

* add `get-cc`

* remove `apt update`

* rename `get-version` -> `get-info`

* rm unnecessary file

* - Add support for ios
- Fix missing top folder for macos

* - Fix directory names

* - Fix with binary r/w

* iOS的plist文件先转换为明文

* add IOS

* 整合新action

* Finishing touch

* Update action.yml

* Test chmod

* - Xcode build test

* - Build with default keychain

* - Test iOS only

* - Use macos-11

* - Change keychain operations' sequence

* - Allow provisioning updates

* - Set build directory

* - Specify build path

* - Pack bare app

* - Add quiet option

* 测试:输出touchrelease位置

* - Test with ad hoc cert

* - Fix wrong variable

* - Use Release instead of Distribution

* - Chmod CCloader to add execute permission

* 继续测试ios触屏问题

* 继续测试ios触屏问题

* - Use macos latest
- Re-enable other runs

* - Sign CCloader after build

* - Remove redundant inputs in build.yml

* - Install test

* - Export test

* - install test

* - Try fastlane

* - Use builtin ruby

* - CI Test

* - Update python script to fix ios versioning

* - Use static lib

* - Test static cc

* - Fix locations

* Update readme.md

Co-authored-by: Imple Lee <80144331+ImpleLee@users.noreply.github.com>
Co-authored-by: Trebor-Huang <2300936257@qq.com>
Co-authored-by: Trebor Huang <41145779+Trebor-Huang@users.noreply.github.com>
Co-authored-by: YunyushuLiu <kunluntree@qq.com>
Co-authored-by: MrZ626 <1046101471@qq.com>
Co-authored-by: 梦飞翔 <1149761294@qq.com>
2021-10-20 13:07:51 +08:00

109 lines
4.3 KiB
Python

import argparse
import re
def updateConf(): #更新存档位置
with open('conf.lua', 'r+', encoding='utf-8') as file:
data = file.read()
data = data.replace("t.identity='Techmino'--Saving folder", "t.identity='Techmino_Snapshot'--Saving folder")
file.seek(0)
file.truncate()
file.flush()
file.write(data)
def updateVersion(args): #更新版本号
with open('version.lua', 'r+', encoding='utf-8') as file:
data = file.read()
if args.Hash != False:
data = data.replace('@DEV', f'@{args.Hash[0:4]}')
else:
data = data.replace('@DEV', '')
file.seek(0)
file.truncate()
file.flush()
file.write(data)
def updateMacOS(args): #更新macOS打包信息
import datetime
thisYear = str(datetime.datetime.today().year)
with open('./.github/build/macOS/info.plist.template', 'r', encoding='utf-8') as file:
data = file.read()
data = data\
.replace('@versionName', args.Name)\
.replace('@thisYear', thisYear)
with open('./Techmino.app/Contents/info.plist', 'w+', encoding='utf-8') as file:
file.write(data)
def updateIOS(args): #更新iOS打包信息
with open('./Techmino-iOS/platform/xcode/Techmino.xcodeproj/project.pbxproj', 'r') as file:
data = file.read()
data = data.replace('__VERSION__', re.search(r'([0-9]+\.[0-9]+\.[0-9]+)', args.Name, re.I).group(1))
with open('./Techmino-iOS/platform/xcode/Techmino.xcodeproj/project.pbxproj', 'w') as file:
file.write(data)
def updateWindows(args): #更新Windows打包信息
Version = (args.Name).replace('V', '')
FileVersion = (f"{Version.replace('.', ',')},0")
with open('./.github/build/Windows/Techmino.rc.template', 'r', encoding='utf8') as file:
data = file.read()
data = data\
.replace('@FileVersion', FileVersion)\
.replace('@Version', Version)
with open('Techmino.rc', 'w+', encoding='utf8') as file:
file.write(data)
def updateAndroid(args, edition): #更新Android打包信息
if edition == 'Release':
appName = 'Techmino'
packageName = 'org.love2d.MrZ.Techmino'
edition = 'release'
elif edition == 'Snapshot':
appName = 'Techmino_Snapshot'
packageName = 'org.love2d.MrZ.Techmino.Snapshot'
edition = 'snapshot'
with open('./love-android/app/src/main/AndroidManifest.xml', "r+", encoding='utf-8') as file:
data = file.read()
data = data\
.replace('@appName', appName)\
.replace('@edition', edition)
file.seek(0)
file.truncate()
file.write(data)
with open("./love-android/app/build.gradle", "r+", encoding='utf-8') as file:
data = file.read()
data = data\
.replace('@packageName', packageName)\
.replace('@versionCode', args.Code)\
.replace('@versionName', args.Name)\
.replace('@storePassword', args.Store)\
.replace('@keyAlias', args.Alias)\
.replace('@keyPassword', args.Key)
file.seek(0)
file.truncate()
file.write(data)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='用于CI更新程序各类信息')
parser.add_argument('-T', '--Type', type=str, help = '更新的种类')
parser.add_argument('-H', '--Hash', type=str, default = False, help = 'Github提交Hash')
parser.add_argument('-C', '--Code', type=str, default = False, help = 'versionCode')
parser.add_argument('-N', '--Name', type=str, default = False, help = 'versionName')
parser.add_argument('-S', '--Store', type=str, default = False, help = 'storePassword')
parser.add_argument('-A', '--Alias', type=str, default = False, help = 'keyAlias')
parser.add_argument('-K', '--Key', type=str, default = False, help = 'keyPassword')
args = parser.parse_args()
if args.Type == 'Conf':
updateConf()
elif args.Type == 'Version':
updateVersion(args)
elif args.Type == 'Windows':
updateWindows(args)
elif args.Type == 'macOS':
updateMacOS(args)
elif args.Type == 'iOS':
updateIOS(args)
elif args.Type == 'AndroidRelease':
updateAndroid(args, 'Release')
elif args.Type == 'AndroidSnapshot':
updateAndroid(args, 'Snapshot')