|
1 | | -""" """ |
2 | | - |
3 | 1 | import sys |
4 | 2 | import os |
5 | 3 | import re |
|
10 | 8 | REPOSITORY_NAME = os.environ.get("REPOSITORY") |
11 | 9 | REF = os.environ.get("REF") |
12 | 10 |
|
13 | | -# determine the branch that triggered the workflow |
| 11 | +# Determine the branch that triggered the workflow |
14 | 12 | match = re.match(r"refs/heads/(.*)", REF) |
15 | 13 | if not match: |
16 | 14 | sys.exit(1) |
17 | 15 |
|
18 | 16 | branch_name = match.group(1) |
19 | | -print("Determined branch name: ", branch_name) |
| 17 | +print(f"Determined branch name: {branch_name}") |
20 | 18 |
|
21 | 19 | version = extract_version_from_cmakelists() |
22 | 20 |
|
|
25 | 23 | if is_dev_branch: |
26 | 24 | last_dev_release = determine_dev_release(version, REPOSITORY_NAME) |
27 | 25 | dev_release = str(last_dev_release + 1) |
28 | | - version += "-dev." + dev_release |
| 26 | + version += f"-dev.{dev_release}" |
| 27 | + |
| 28 | +# Ensure GITHUB_OUTPUT is set correctly |
| 29 | +github_output = os.getenv("GITHUB_OUTPUT") |
| 30 | +if not github_output: |
| 31 | + print("Error: GITHUB_OUTPUT is not set!", file=sys.stderr) |
| 32 | + sys.exit(1) |
29 | 33 |
|
30 | | -# Write the version and dev release to GitHub environment variable |
31 | | -with open(os.getenv("GITHUB_OUTPUT"), "a", encoding="utf-8") as env_file: |
32 | | - env_file.write(f"VERSION={version}\n") |
33 | | - print(f"VERSION={version}") |
| 34 | +# Write the outputs correctly |
| 35 | +with open(github_output, "a", encoding="utf-8") as env_file: |
| 36 | + env_file.write(f"version={version}\n") |
| 37 | + print( |
| 38 | + f"::set-output name=version::{version}" |
| 39 | + ) # Deprecated, but useful for debugging |
34 | 40 | if is_dev_branch and dev_release: |
35 | | - print(f"DEV_RELEASE={dev_release}") |
36 | | - env_file.write(f"DEV_RELEASE={dev_release}\n") |
| 41 | + env_file.write(f"dev_release={dev_release}\n") |
| 42 | + print(f"::set-output name=dev_release::{dev_release}") |
0 commit comments