From a58ad2c34ee5750ff19560ff0276563579d183ef Mon Sep 17 00:00:00 2001 From: Jake Carter Date: Tue, 27 Feb 2024 14:36:02 -0700 Subject: [PATCH] Create update_version.yml --- .github/workflows/build-docs.yml | 2 +- .github/workflows/scripts/update_version.py | 2 ++ .github/workflows/update_version.yml | 31 +++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update_version.yml diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 6a9a8d8efa6..4629cc60c7a 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -15,7 +15,7 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v2.3.3 diff --git a/.github/workflows/scripts/update_version.py b/.github/workflows/scripts/update_version.py index abf7ad5a78f..ff60e2fb6a0 100644 --- a/.github/workflows/scripts/update_version.py +++ b/.github/workflows/scripts/update_version.py @@ -27,8 +27,10 @@ result = run(command, shell=True, capture_output=True) if result.returncode != 0: print(f"Failed to run {command} with error {result.returncode}:\n{result.stderr.decode(encoding='utf-8')}") + exit(result.returncode) version = result.stdout.decode(encoding="utf-8").strip() + print(version) # Our tagging convention is v{version_year}_{version_month} # git describe will sometimes return something like v2024_02-5-g5f0770a64e version_year = int(version.split("_")[0][1:]) # Split the year and month based on the '_', and strip off the leading 'v' diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml new file mode 100644 index 00000000000..ec3bcf18544 --- /dev/null +++ b/.github/workflows/update_version.yml @@ -0,0 +1,31 @@ +name: Update Version Info + +on: + push: + tags: [ "release" ] + + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Python + uses: actions/setup-python@v2.3.3 + + - name: Update Version Files + run: | + python3 .github/workflows/scripts/update_version.py + + - uses: EndBug/add-and-commit@v9 + + - name: Update Existing Tag + run: | + CURRENT_TAG=$(git describe --abbrev=0 --tags) + git tag -f $CURRENT_TAG + git push --tags --force