From 56f4de5b4d99f50ab3ac60dc60f67ff10ab50439 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 29 Feb 2024 16:36:58 +0000 Subject: [PATCH] Re-trigger version_metadata on tag release change. --- .github/libs/version.py | 8 +++++++- .github/workflows/version_update.yml | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/libs/version.py b/.github/libs/version.py index 2e94b7d8..1bbd4c15 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 13ff9af9..489090c4 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