From 15d6cd5990a536db8c4b7f0cb25b0f55a0c41af9 Mon Sep 17 00:00:00 2001 From: Jay Fitzgerald <34140133+ni-jfitzger@users.noreply.github.com> Date: Tue, 8 Jul 2025 21:11:11 -0500 Subject: [PATCH 1/5] Fix check_latest_release shell script --- .github/workflows/check_latest_release.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check_latest_release.yml b/.github/workflows/check_latest_release.yml index b5b526190..e0a39e7d2 100644 --- a/.github/workflows/check_latest_release.yml +++ b/.github/workflows/check_latest_release.yml @@ -31,14 +31,24 @@ jobs: - name: Extract module name and version from release tag id: extract_tag + shell: python run: | + import os + import json + # Extract module name and version from the release tag # Assuming the tag format is -, e.g., nidigital-1.4.0 - TAG="${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.event.release.tag_name }}" - MODULE_NAME=$(echo "$TAG" | cut -d'-' -f1) - MODULE_VERSION=$(echo "$TAG" | cut -d'-' -f2-) - echo "module_name=$MODULE_NAME" >> "$GITHUB_OUTPUT" - echo "module_version=$MODULE_VERSION" >> "$GITHUB_OUTPUT" + if os.getenv("GITHUB_EVENT_NAME") == "workflow_dispatch": + tag = os.getenv("INPUT_release_tag") + else: + with open(os.getenv("GITHUB_EVENT_PATH"), "r") as event_file: + event = json.load(event_file) + tag = event["release"]["tag_name"] + + module_name, module_version = tag.split("-") + with open(os.getenv("GITHUB_OUTPUT"), "a") as output_file: + output_file.write(f"module_name={module_name}\n") + output_file.write(f"module_version={module_version}\n") # NOTE: we don't upload test coverage for this - name: run examples using PyPI uploads uses: ./.github/actions/run_examples_using_pypi_uploads From ccbc2c8d5e223f113bb49260bbedaa732ffe8115 Mon Sep 17 00:00:00 2001 From: Jay Fitzgerald <34140133+ni-jfitzger@users.noreply.github.com> Date: Tue, 8 Jul 2025 21:38:20 -0500 Subject: [PATCH 2/5] Correct env variable name. GITHUB auotmatically converts name to uppercase --- .github/workflows/check_latest_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_latest_release.yml b/.github/workflows/check_latest_release.yml index e0a39e7d2..2b73efadb 100644 --- a/.github/workflows/check_latest_release.yml +++ b/.github/workflows/check_latest_release.yml @@ -39,7 +39,7 @@ jobs: # Extract module name and version from the release tag # Assuming the tag format is -, e.g., nidigital-1.4.0 if os.getenv("GITHUB_EVENT_NAME") == "workflow_dispatch": - tag = os.getenv("INPUT_release_tag") + tag = os.getenv("INPUT_RELEASE_TAG") else: with open(os.getenv("GITHUB_EVENT_PATH"), "r") as event_file: event = json.load(event_file) From 531fef7246c2061bd2be52eb9d57a017df78e2c5 Mon Sep 17 00:00:00 2001 From: Jay Fitzgerald <34140133+ni-jfitzger@users.noreply.github.com> Date: Tue, 8 Jul 2025 21:41:57 -0500 Subject: [PATCH 3/5] Specify encoding when opening files --- .github/workflows/check_latest_release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_latest_release.yml b/.github/workflows/check_latest_release.yml index 2b73efadb..192f3b245 100644 --- a/.github/workflows/check_latest_release.yml +++ b/.github/workflows/check_latest_release.yml @@ -41,12 +41,12 @@ jobs: if os.getenv("GITHUB_EVENT_NAME") == "workflow_dispatch": tag = os.getenv("INPUT_RELEASE_TAG") else: - with open(os.getenv("GITHUB_EVENT_PATH"), "r") as event_file: + with open(os.getenv("GITHUB_EVENT_PATH"), "r", encoding="utf-8") as event_file: event = json.load(event_file) tag = event["release"]["tag_name"] module_name, module_version = tag.split("-") - with open(os.getenv("GITHUB_OUTPUT"), "a") as output_file: + with open(os.getenv("GITHUB_OUTPUT"), "a", encoding="utf-8") as output_file: output_file.write(f"module_name={module_name}\n") output_file.write(f"module_version={module_version}\n") # NOTE: we don't upload test coverage for this From c46081235cdc67939e418357d368523f3de37993 Mon Sep 17 00:00:00 2001 From: Jay Fitzgerald <34140133+ni-jfitzger@users.noreply.github.com> Date: Tue, 8 Jul 2025 21:43:40 -0500 Subject: [PATCH 4/5] Add assert for better error if we tag format is wrong --- .github/workflows/check_latest_release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check_latest_release.yml b/.github/workflows/check_latest_release.yml index 192f3b245..18412dfd9 100644 --- a/.github/workflows/check_latest_release.yml +++ b/.github/workflows/check_latest_release.yml @@ -45,6 +45,7 @@ jobs: event = json.load(event_file) tag = event["release"]["tag_name"] + assert tag.count("-") == 1, f"Invalid tag format: {tag}. Expected format: -" module_name, module_version = tag.split("-") with open(os.getenv("GITHUB_OUTPUT"), "a", encoding="utf-8") as output_file: output_file.write(f"module_name={module_name}\n") From 0fe45d00e5140a3d7a865f3001edf8654c47b686 Mon Sep 17 00:00:00 2001 From: Jay Fitzgerald <34140133+ni-jfitzger@users.noreply.github.com> Date: Tue, 8 Jul 2025 22:38:56 -0500 Subject: [PATCH 5/5] Get the input fom the event file. We don't seem to be creating the INPUT_ variable --- .github/workflows/check_latest_release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_latest_release.yml b/.github/workflows/check_latest_release.yml index 18412dfd9..ca0096429 100644 --- a/.github/workflows/check_latest_release.yml +++ b/.github/workflows/check_latest_release.yml @@ -38,11 +38,11 @@ jobs: # Extract module name and version from the release tag # Assuming the tag format is -, e.g., nidigital-1.4.0 + with open(os.getenv("GITHUB_EVENT_PATH"), "r", encoding="utf-8") as event_file: + event = json.load(event_file) if os.getenv("GITHUB_EVENT_NAME") == "workflow_dispatch": - tag = os.getenv("INPUT_RELEASE_TAG") + tag = event["inputs"]["release_tag"] else: - with open(os.getenv("GITHUB_EVENT_PATH"), "r", encoding="utf-8") as event_file: - event = json.load(event_file) tag = event["release"]["tag_name"] assert tag.count("-") == 1, f"Invalid tag format: {tag}. Expected format: -"