diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d37acde..4312d95 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,6 +4,12 @@ on: push: tags: - "v*" + workflow_dispatch: + inputs: + version_name: + description: 'a version name' + required: false + default: '0.0.0' jobs: build: @@ -19,6 +25,8 @@ jobs: key: ${{ hashFiles('**/requirements.txt') }} - name: Build + env: + PROJECT_VERSION: ${{ github.event.inputs.version_name }} run: | tzutil /s "China Standard Time" python -m pip install wheel setuptools virtualenv diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 542868b..1a9b8c5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,11 @@ on: pull_request: branches: [ main ] workflow_dispatch: + inputs: + version_name: + description: 'a version name' + required: false + default: 'test-version' jobs: build: @@ -19,6 +24,8 @@ jobs: key: ${{ hashFiles('**/requirements.txt') }} - name: Build + env: + PROJECT_VERSION: ${{ github.event.inputs.version_name }} run: | tzutil /s "China Standard Time" python -m pip install wheel setuptools virtualenv diff --git a/build.spec b/build.spec index 667731d..e2a2722 100644 --- a/build.spec +++ b/build.spec @@ -16,11 +16,12 @@ def get_git_sha(): return os.getenv('GITHUB_SHA', '') # 生成版本号文件 +import os import json import time metadata_file = 'meta.json' -version_text = get_git_tag('0.0.0') +version_text = get_git_tag(os.getenv('PROJECT_VERSION', '0.0.0')) commit_sha = get_git_sha() compile_time = time.strftime("%Y-%m-%d %H:%M-%S %z")