summaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-01-18 13:34:40 -0500
committerNat Goodspeed <nat@lindenlab.com>2024-03-01 16:13:29 -0500
commit8f68199ccd4beeee827ff360e2f36871cedacdfe (patch)
treef6f8426ac6fceb9e1b063db6efe8dcc3cdfd36f7 /.github
parent9b3d4325d9f049bc7315e3772eee2fb5e4bfc83a (diff)
SL-20546: Use branch for autobuild package as well as release page.
which_branch.py has moved to viewer-build-util as a reusable action. (cherry picked from commit 09f66828ba573515c3766cce32f4746b8189efcf)
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/build.yaml8
-rw-r--r--.github/workflows/which_branch.py77
2 files changed, 1 insertions, 84 deletions
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index f172883ae6..b323290f6b 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -24,7 +24,7 @@ jobs:
outputs:
viewer_channel: ${{ steps.build.outputs.viewer_channel }}
viewer_version: ${{ steps.build.outputs.viewer_version }}
- viewer_branch: ${{ steps.build.outputs.viewer_branch }}
+ viewer_branch: ${{ steps.which-branch.outputs.branch }}
imagename: ${{ steps.build.outputs.imagename }}
env:
AUTOBUILD_ADDRSIZE: 64
@@ -187,15 +187,9 @@ jobs:
if [[ "$GITHUB_REF_TYPE" == "tag" && "${GITHUB_REF_NAME:0:12}" == "Second_Life_" ]]
then viewer_channel="${GITHUB_REF_NAME%#*}"
export viewer_channel="${viewer_channel//_/ }"
- # Since GITHUB_REF_NAME is a tag rather than a branch, we need
- # to discover to what branch this tag corresponds.
- viewer_branch="$(python3 .github/workflows/which_branch.py \
- --token "${{ github.token }}" ${{ github.workflow_sha }})"
else export viewer_channel="Second Life Test"
- viewer_branch="${GITHUB_REF_NAME}"
fi
echo "viewer_channel=$viewer_channel" >> "$GITHUB_OUTPUT"
- echo "viewer_branch=$viewer_branch" >> "$GITHUB_OUTPUT"
# On windows we need to point the build to the correct python
# as neither CMake's FindPython nor our custom Python.cmake module
diff --git a/.github/workflows/which_branch.py b/.github/workflows/which_branch.py
deleted file mode 100644
index 802ea44b5a..0000000000
--- a/.github/workflows/which_branch.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/env python3
-"""\
-@file which_branch.py
-@author Nat Goodspeed
-@date 2023-11-14
-@brief Discover which git branch(es) correspond to a given commit hash.
-
-$LicenseInfo:firstyear=2023&license=viewerlgpl$
-Copyright (c) 2023, Linden Research, Inc.
-$/LicenseInfo$
-"""
-
-import github
-import re
-import sys
-import subprocess
-
-class Error(Exception):
- pass
-
-def branches_for(token, commit, repo=None):
- """
- Use the GitHub REST API to discover which branch(es) correspond to the
- passed commit hash. The commit string can actually be any of the ways git
- permits to identify a commit:
-
- https://git-scm.com/docs/gitrevisions#_specifying_revisions
-
- branches_for() generates a (possibly empty) sequence of all the branches
- of the specified repo for which the specified commit is the tip.
-
- If repo is omitted or None, assume the current directory is a local clone
- whose 'origin' remote is the GitHub repository of interest.
- """
- if not repo:
- url = subprocess.check_output(['git', 'remote', 'get-url', 'origin'],
- text=True)
- parts = re.split(r'[:/]', url.rstrip())
- repo = '/'.join(parts[-2:]).removesuffix('.git')
-
- gh = github.MainClass.Github(token)
- grepo = gh.get_repo(repo)
- for branch in grepo.get_branches():
- try:
- delta = grepo.compare(base=commit, head=branch.name)
- except github.GithubException:
- continue
-
- if delta.ahead_by == 0 and delta.behind_by == 0:
- yield branch
-
-def main(*raw_args):
- from argparse import ArgumentParser
- parser = ArgumentParser(description=
-"%(prog)s reports the branch(es) for which the specified commit hash is the tip.",
- epilog="""\
-When GitHub Actions launches a tag build, it checks out the specific changeset
-identified by the tag, and so 'git branch' reports detached HEAD. But we use
-tag builds to build a GitHub 'release' of the tip of a particular branch, and
-it's useful to be able to identify which branch that is.
-""")
- parser.add_argument('-t', '--token', required=True,
- help="""GitHub REST API access token""")
- parser.add_argument('-r', '--repo',
- help="""GitHub repository name, in the form OWNER/REPOSITORY""")
- parser.add_argument('commit',
- help="""commit hash at the tip of the sought branch""")
-
- args = parser.parse_args(raw_args)
- for branch in branches_for(token=args.token, commit=args.commit, repo=args.repo):
- print(branch.name)
-
-if __name__ == "__main__":
- try:
- sys.exit(main(*sys.argv[1:]))
- except Error as err:
- sys.exit(str(err))