From cc070615cc40d04c0e692e47615a3e487087fba4 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 14 Dec 2023 20:32:07 -0500 Subject: [PATCH 1/5] Set AUTOBUILD_VCS_BRANCH: secondlife/viewer-build-util/which-branch For a tag build used to release a package, github reports the tag name rather than the branch to which it corresponds. Look up the corresponding branch and pass it to autobuild as AUTOBUILD_VCS_BRANCH, which will set the vcs_branch field in the package's autobuild-package.xml's package_description. Otherwise, vcs_branch is reported for every build of every package as "HEAD". --- action.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/action.yaml b/action.yaml index 59c1b2a..f7fe2ab 100644 --- a/action.yaml +++ b/action.yaml @@ -162,6 +162,12 @@ runs: path: ${{ github.workspace }}/.autobuild-installables key: ${{ runner.os }}-${{ runner.arch }}-${{ inputs.configuration }}-${{ hashFiles('autobuild.xml') }} + - name: Determine branch + id: which-branch + uses: secondlife/viewer-build-util/which-branch@which-branch + with: + token: ${{ inputs.token }} + - name: Run autobuild shell: ${{ steps.shell.outputs.shell }} id: autobuild @@ -172,6 +178,7 @@ runs: AUTOBUILD_GITHUB_TOKEN: ${{ inputs.token }} AUTOBUILD_INSTALLABLE_CACHE: ${{ github.workspace }}/.autobuild-installables AUTOBUILD_VARIABLES_FILE: ${{ github.workspace }}/.build-variables/variables + AUTOBUILD_VCS_BRANCH: ${{ steps.which-branch.outputs.branch }} AUTOBUILD_VCS_INFO: "true" BUILD_ID: ${{ inputs.build-id }} CONFIGURATION: ${{ inputs.configuration }} From 6cc02463063558a02d2289fafbf744e3a1f87ace Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 14 Dec 2023 20:44:03 -0500 Subject: [PATCH 2/5] Only run which-branch if inputs.token is set. --- action.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index f7fe2ab..4a7f3c7 100644 --- a/action.yaml +++ b/action.yaml @@ -164,6 +164,7 @@ runs: - name: Determine branch id: which-branch + if: inputs.token uses: secondlife/viewer-build-util/which-branch@which-branch with: token: ${{ inputs.token }} @@ -178,7 +179,7 @@ runs: AUTOBUILD_GITHUB_TOKEN: ${{ inputs.token }} AUTOBUILD_INSTALLABLE_CACHE: ${{ github.workspace }}/.autobuild-installables AUTOBUILD_VARIABLES_FILE: ${{ github.workspace }}/.build-variables/variables - AUTOBUILD_VCS_BRANCH: ${{ steps.which-branch.outputs.branch }} + AUTOBUILD_VCS_BRANCH: ${{ steps.which-branch.outputs.branch || github.ref_name }} AUTOBUILD_VCS_INFO: "true" BUILD_ID: ${{ inputs.build-id }} CONFIGURATION: ${{ inputs.configuration }} From e07300f8396f0cf647cb65342d955a43a0297703 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 15 Dec 2023 15:55:49 -0500 Subject: [PATCH 3/5] Use git branch -r --contains ... instead of which-branch action. --- action.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yaml b/action.yaml index 4a7f3c7..52063a3 100644 --- a/action.yaml +++ b/action.yaml @@ -164,10 +164,10 @@ runs: - name: Determine branch id: which-branch - if: inputs.token - uses: secondlife/viewer-build-util/which-branch@which-branch - with: - token: ${{ inputs.token }} + shell: bash + run: | + branch="$(git branch -r --contains ${{ steps.sha.outputs.long }})" + echo "branch=${branch#*/}" >> "$GITHUB_OUTPUT" - name: Run autobuild shell: ${{ steps.shell.outputs.shell }} From 5db14919fc78c890803c174280d0d0fbd1a5ec00 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 18 Dec 2023 08:52:38 -0500 Subject: [PATCH 4/5] Try not quoting $GITHUB_OUTPUT --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 52063a3..0d587ac 100644 --- a/action.yaml +++ b/action.yaml @@ -167,7 +167,7 @@ runs: shell: bash run: | branch="$(git branch -r --contains ${{ steps.sha.outputs.long }})" - echo "branch=${branch#*/}" >> "$GITHUB_OUTPUT" + echo "branch=${branch#*/}" >> $GITHUB_OUTPUT - name: Run autobuild shell: ${{ steps.shell.outputs.shell }} From d68810c446bf45104ebea1990b515b3e14cee2c6 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 18 Dec 2023 09:03:21 -0500 Subject: [PATCH 5/5] Ensure that 'git branch -r --contains' produces just one line. --- action.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 0d587ac..f9b4cf4 100644 --- a/action.yaml +++ b/action.yaml @@ -166,7 +166,9 @@ runs: id: which-branch shell: bash run: | - branch="$(git branch -r --contains ${{ steps.sha.outputs.long }})" + # in real use, 'git branch -r --contains' should produce a single line, + # but our self-tests can emit more than one + branch="$(git branch -r --contains ${{ steps.sha.outputs.long }} | head -n 1)" echo "branch=${branch#*/}" >> $GITHUB_OUTPUT - name: Run autobuild