Skip to content

Commit 841e844

Browse files
authored
Fix check_latest_release shell script (#2118)
* Fix check_latest_release shell script * Correct env variable name. GITHUB auotmatically converts name to uppercase * Specify encoding when opening files * Add assert for better error if we tag format is wrong * Get the input fom the event file. We don't seem to be creating the INPUT_ variable
1 parent 89f0a20 commit 841e844

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

.github/workflows/check_latest_release.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,25 @@ jobs:
3131

3232
- name: Extract module name and version from release tag
3333
id: extract_tag
34+
shell: python
3435
run: |
36+
import os
37+
import json
38+
3539
# Extract module name and version from the release tag
3640
# Assuming the tag format is <module_name>-<version>, e.g., nidigital-1.4.0
37-
TAG="${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.event.release.tag_name }}"
38-
MODULE_NAME=$(echo "$TAG" | cut -d'-' -f1)
39-
MODULE_VERSION=$(echo "$TAG" | cut -d'-' -f2-)
40-
echo "module_name=$MODULE_NAME" >> "$GITHUB_OUTPUT"
41-
echo "module_version=$MODULE_VERSION" >> "$GITHUB_OUTPUT"
41+
with open(os.getenv("GITHUB_EVENT_PATH"), "r", encoding="utf-8") as event_file:
42+
event = json.load(event_file)
43+
if os.getenv("GITHUB_EVENT_NAME") == "workflow_dispatch":
44+
tag = event["inputs"]["release_tag"]
45+
else:
46+
tag = event["release"]["tag_name"]
47+
48+
assert tag.count("-") == 1, f"Invalid tag format: {tag}. Expected format: <module_name>-<version>"
49+
module_name, module_version = tag.split("-")
50+
with open(os.getenv("GITHUB_OUTPUT"), "a", encoding="utf-8") as output_file:
51+
output_file.write(f"module_name={module_name}\n")
52+
output_file.write(f"module_version={module_version}\n")
4253
# NOTE: we don't upload test coverage for this
4354
- name: run examples using PyPI uploads
4455
uses: ./.github/actions/run_examples_using_pypi_uploads

0 commit comments

Comments
 (0)