mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-19 19:15:07 +00:00
feat: version config
This commit is contained in:
parent
ff082f42b6
commit
5abcce9854
6 changed files with 38 additions and 9 deletions
4
.github/workflows/macos.yml
vendored
4
.github/workflows/macos.yml
vendored
|
@ -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
|
||||
|
|
4
.github/workflows/ubuntu.yml
vendored
4
.github/workflows/ubuntu.yml
vendored
|
@ -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
|
||||
|
|
1
.github/workflows/windows.yml
vendored
1
.github/workflows/windows.yml
vendored
|
@ -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
|
||||
|
|
|
@ -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
1
QtScrcpy/version
Normal file
|
@ -0,0 +1 @@
|
|||
0.0.0
|
20
ci/generate-version.py
Normal file
20
ci/generate-version.py
Normal 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)
|
Loading…
Add table
Reference in a new issue