feat: version config

This commit is contained in:
rankun 2020-04-18 02:04:48 +08:00
parent ff082f42b6
commit 5abcce9854
6 changed files with 38 additions and 9 deletions

View file

@ -42,7 +42,9 @@ jobs:
- name: Build MacOS
env:
ENV_QT_PATH: ${{ env.qt-install-path }}
run: ci/mac/build_for_mac.sh release
run: |
python ci\generate-version.py
ci/mac/build_for_mac.sh release
# 获取ref最后一个/后的内容
- name: Get the version
shell: bash

View file

@ -45,4 +45,6 @@ jobs:
- name: Build Ubuntu
env:
ENV_QT_PATH: ${{ env.qt-install-path }}
run: ci/linux/build_for_ubuntu.sh release
run: |
python ci\generate-version.py
ci/linux/build_for_ubuntu.sh release

View file

@ -71,6 +71,7 @@ jobs:
ENV_VCVARSALL: ${{ env.vcvarsall-path }}
ENV_QT_PATH: ${{ env.qt-install-path }}
run: |
call python ci\generate-version.py
call "ci\win\build_for_win.bat" release ${{ matrix.msvc-arch }}
# 获取ref最后一个/后的内容
- name: Get the version

View file

@ -56,14 +56,17 @@ INCLUDEPATH += \
$$PWD/devicemanage \
$$PWD/fontawesome
# 版本号会在打包脚本中定义并通过qmake传递进来
# 如果外部没有定义则内部定义debug模式
!defined(VERSION_MAJOR, var) {
VERSION_MAJOR = 0
VERSION_MINOR = 0
VERSION_PATCH = 0
}
# 如果变量没有定义
# !defined(TEST_VAR, var) {
# message("test")
# }
# 从文件读取版本号
CAT_VERSION = $$cat($$PWD/version)
# 拆分出版本号
VERSION_MAJOR = $$section(CAT_VERSION, ., 0, 0)
VERSION_MINOR = $$section(CAT_VERSION, ., 1, 1)
VERSION_PATCH = $$section(CAT_VERSION, ., 2, 2)
message("version:" $${VERSION_MAJOR}.$${VERSION_MINOR}.$${VERSION_PATCH})
# qmake变量的方式定义版本号

1
QtScrcpy/version Normal file
View file

@ -0,0 +1 @@
0.0.0

20
ci/generate-version.py Normal file
View file

@ -0,0 +1,20 @@
import sys
import os
if __name__ == '__main__':
p = os.popen('git rev-list --tags --max-count=1')
commit = p.read()
p.close()
p = os.popen('git describe --tags ' + commit)
tag = p.read()
p.close()
# print('get tag:', tag)
version = str(tag[1:])
version_file = os.path.abspath(os.path.join(os.path.dirname(__file__), "../QtScrcpy/version"))
file=open(version_file, 'w')
file.write(version)
file.close()
sys.exit(0)