mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 02:34:26 +08:00
通过持续集成自动生成openapi相关文件 (#3042)
This commit is contained in:
parent
34695ab1b8
commit
644a333ec3
20
.github/workflows/linux.yml
vendored
20
.github/workflows/linux.yml
vendored
@ -1,14 +1,15 @@
|
|||||||
name: Linux
|
name: Linux
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: 下载submodule源码
|
- name: 下载submodule源码
|
||||||
run: mv -f .gitmodules_github .gitmodules && git submodule sync && git submodule update --init
|
run: mv -f .gitmodules_github .gitmodules && git submodule sync && git submodule update --init
|
||||||
@ -33,4 +34,19 @@ jobs:
|
|||||||
- name: 运行MediaServer
|
- name: 运行MediaServer
|
||||||
run: pwd && cd release/linux/Debug && sudo ./MediaServer -d &
|
run: pwd && cd release/linux/Debug && sudo ./MediaServer -d &
|
||||||
|
|
||||||
|
- name: generate openapi
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
run: cd tools/openapi && python3 generates.py install-dependencies
|
||||||
|
|
||||||
|
- name: Commit and push if ./www/swagger/openapi.json changed
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
run: |
|
||||||
|
git diff --exit-code ./www/swagger/openapi.json || (
|
||||||
|
git config user.name alexliyu7352
|
||||||
|
git config user.email liyu7352@gmail.com
|
||||||
|
git add ./www/swagger/openapi.json
|
||||||
|
git commit -m "update openapi.json"
|
||||||
|
git push origin HEAD:master
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,18 +43,26 @@ def run_cmd(cmd: str, assert_success=False, capture_output=False, env=None) -> b
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def check_dependencies() -> None:
|
def check_dependencies(need_install:bool = False) -> None:
|
||||||
"""
|
"""
|
||||||
check dependencies
|
check dependencies
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if not check_installed("p2o"):
|
if not check_installed("p2o"):
|
||||||
print()
|
if not need_install:
|
||||||
print("p2o is not installed, please install it first!")
|
print()
|
||||||
print("If you use npm, you can install it by the following command:")
|
print("p2o is not installed, please install it first!")
|
||||||
print("npm install -g postman-to-openapi")
|
print("If you use npm, you can install it by the following command:")
|
||||||
print()
|
print("npm install -g postman-to-openapi")
|
||||||
sys.exit(1)
|
print()
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
# 先检查是否安装了npm, 没有就自动安装
|
||||||
|
if not check_installed("npm"):
|
||||||
|
print("npm is not installed, install it first")
|
||||||
|
run_cmd("sudo apt install npm -y")
|
||||||
|
print("p2o is not installed, install it")
|
||||||
|
run_cmd("sudo npm install -g postman-to-openapi")
|
||||||
else:
|
else:
|
||||||
print("p2o is installed")
|
print("p2o is installed")
|
||||||
|
|
||||||
@ -70,6 +78,12 @@ def get_version() -> str:
|
|||||||
elif os.path.isfile("../../cmake-build-release/version.h"):
|
elif os.path.isfile("../../cmake-build-release/version.h"):
|
||||||
print("Found version.h in cmake-build-release")
|
print("Found version.h in cmake-build-release")
|
||||||
version_h_path = "../../cmake-build-release/version.h"
|
version_h_path = "../../cmake-build-release/version.h"
|
||||||
|
elif os.path.isfile("../../build/version.h"):
|
||||||
|
print("Found version.h in build")
|
||||||
|
version_h_path = "../../build/version.h"
|
||||||
|
elif os.path.isfile("../../linux_build/version.h"):
|
||||||
|
print("Found version.h in linux_build")
|
||||||
|
version_h_path = "../../linux_build/version.h"
|
||||||
else:
|
else:
|
||||||
print("version.h not found")
|
print("version.h not found")
|
||||||
print("Please compile first")
|
print("Please compile first")
|
||||||
@ -138,7 +152,11 @@ def generate() -> None:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
check_dependencies()
|
# 如果有参数install-dependencies,则安装依赖
|
||||||
|
if len(sys.argv) > 1 and sys.argv[1] == "install-dependencies":
|
||||||
|
check_dependencies(True)
|
||||||
|
else:
|
||||||
|
check_dependencies()
|
||||||
version = get_version()
|
version = get_version()
|
||||||
secret = get_secret()
|
secret = get_secret()
|
||||||
update_options(version, secret)
|
update_options(version, secret)
|
||||||
|
Loading…
Reference in New Issue
Block a user