Skip to content
This repository was archived by the owner on May 1, 2026. It is now read-only.

Commit 8c07b39

Browse files
committed
workflows: fix version propagation through workflow
1 parent c3e9ee5 commit 8c07b39

3 files changed

Lines changed: 24 additions & 17 deletions

File tree

.github/actions/version/action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ inputs:
88
description: "The Git reference (branch/tag) to check"
99
required: true
1010

11+
outputs:
12+
version:
13+
description: "The determined version"
14+
value: ${{ steps.version_handler.outputs.version }}
15+
1116
runs:
1217
using: "composite"
1318
steps:
@@ -34,11 +39,6 @@ runs:
3439
run: |
3540
python .github/workflows/version_handler.py
3641
37-
# Set the output VERSION from the result of the script
38-
- name: Set version output
39-
shell: bash
40-
run: echo "VERSION=${{ steps.version_handler.outputs.version }}" >> $GITHUB_ENV
41-
4242
- name: Fail if version is 0
4343
shell: bash
4444
run: |

.github/workflows/build-develop2.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
uses: actions/checkout@v3
1616

1717
- name: Get latest release version
18+
id: version_check
1819
uses: ./.github/actions/version
1920
with:
2021
repository: ${{ github.repository }}
@@ -37,6 +38,6 @@ jobs:
3738
uses: ./.github/actions/release
3839
with:
3940
build-config: ${{env.BUILD_CONFIGURATION}}
40-
version-name: ${{env.VERSION}}
41+
version-name: ${{steps.version_check.outputs.version}}
4142
prelease: true
4243
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
""" """
2-
31
import sys
42
import os
53
import re
@@ -10,13 +8,13 @@
108
REPOSITORY_NAME = os.environ.get("REPOSITORY")
119
REF = os.environ.get("REF")
1210

13-
# determine the branch that triggered the workflow
11+
# Determine the branch that triggered the workflow
1412
match = re.match(r"refs/heads/(.*)", REF)
1513
if not match:
1614
sys.exit(1)
1715

1816
branch_name = match.group(1)
19-
print("Determined branch name: ", branch_name)
17+
print(f"Determined branch name: {branch_name}")
2018

2119
version = extract_version_from_cmakelists()
2220

@@ -25,12 +23,20 @@
2523
if is_dev_branch:
2624
last_dev_release = determine_dev_release(version, REPOSITORY_NAME)
2725
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)
2933

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
3440
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

Comments
 (0)