Skip to content

Commit 0bd2a37

Browse files
committed
add branch and PR number to uploaded build filenames
1 parent b2c32cf commit 0bd2a37

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ jobs:
8484
run: python3 -u ci_set_matrix.py
8585
working-directory: tools
8686
env:
87+
PULL: ${{ github.event.number }}
8788
LAST_FAILED_JOBS: ${{ steps.get-last-commit-with-checks.outputs.check_runs }}
8889

8990
tests:
@@ -294,3 +295,5 @@ jobs:
294295
with:
295296
boards: ${{ toJSON(fromJSON(needs.scheduler.outputs.ports)[matrix.port]) }}
296297
cp-version: ${{ needs.scheduler.outputs.cp-version }}
298+
env:
299+
PULL: ${{ github.event.number }}

tools/build_board_info.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,20 @@ def get_version_info():
7575
sha = os.environ["GITHUB_SHA"]
7676

7777
if not version:
78-
version = "{}-{}".format(date.today().strftime("%Y%m%d"), sha[:7])
78+
# Get branch we are PR'ing into, if any.
79+
branch = os.environ.get("GITHUB_BASE_REF", "").strip().replace("/", "_")
80+
if not branch:
81+
branch = "no-branch"
82+
83+
# Get PR number, if any
84+
pull_request_maybe = os.environ.get("PULL", "")
85+
if pull_request_maybe:
86+
pull_request_maybe = f"-PR{pull_request_maybe}"
87+
88+
date_stamp = date.today().strftime("%Y%m%d")
89+
short_sha = sha[:7]
90+
# Example: 20231121-8.2.x-PR9876-123abcd
91+
version = f"{date_stamp}-{branch}{pull_request_maybe}-{short_sha}"
7992

8093
return sha, version
8194

0 commit comments

Comments
 (0)