diff --git a/.github/libs/version.py b/.github/libs/version.py index 2e94b7d81..1bbd4c150 100644 --- a/.github/libs/version.py +++ b/.github/libs/version.py @@ -198,7 +198,13 @@ def process_files(files,token = None, branch=None,force=False): parser = argparse.ArgumentParser(description="Retrieve details for the latest tag of a GitHub repository.") parser.add_argument("-t", "--token", help="gh token") parser.add_argument("-b","--branch" ,help="branch name") + parser.add_argument("-n","--newrelease" ,help="tag name") args = parser.parse_args() + if args.branch == 'main': - process_files(files, token=args.token, branch = args.branch) + if args.newrelease: + process_files(files, token=args.token, branch = args.branch, force = True, ) + else: + process_files(files, token=args.token, branch = args.branch) + diff --git a/.github/workflows/version_update.yml b/.github/workflows/version_update.yml index 13ff9af98..489090c4a 100644 --- a/.github/workflows/version_update.yml +++ b/.github/workflows/version_update.yml @@ -52,8 +52,18 @@ jobs: - name: Update Versioning id: run-python-script - run: python .github/libs/version.py -t ${GH_TOKEN} -b $(git rev-parse --abbrev-ref HEAD) - # working-directory: .github/libs # Adjusted the working directory + run: | + if [[ "${{ github.event_name }}" == "push" && "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then + echo "This is a tag release." + export TAG_NAME=$(echo "${{ github.ref }}" | sed 's|refs/tags/||') + python .github/libs/version.py -t ${GH_TOKEN} -b $(git rev-parse --abbrev-ref HEAD) -n ${TAG_NAME} + else + echo "This is not a tag release." + python .github/libs/version.py -t ${GH_TOKEN} -b $(git rev-parse --abbrev-ref HEAD) + # exit 1 + fi + + # working-directory: .github/libs # Adjusted the working directory shell: bash