Skip to content

Commit

Permalink
[install] in archiver.py/yml get the repo owner/name from the github ci
Browse files Browse the repository at this point in the history
  • Loading branch information
valassi committed Oct 1, 2024
1 parent 3736647 commit 0c86da2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
import subprocess
import sys

def get_repo():
out = subprocess.check_output(['git', 'config', '--get', 'remote.origin.url']).decode()
return out.split(':')[1].split('.')[0].split('/') # returns (repo_owner, repo_name)

def get_all_tags():
out = subprocess.check_output(['git', 'tag']).decode()
return out.split('\n')
Expand All @@ -27,16 +23,19 @@ def create_infodat_file(path, versions):
fsock.write(line%{'repo':GITHUB_REPO, 'prefix':PREFIX, 'version':v, 'suffix':SUFFIX})

if "__main__" == __name__:
if len(sys.argv) != 2:
print('Usage: python3 %s <infodat>'%sys.argv[0])
if len(sys.argv) != 3:
print('Usage: python3 %s <repoowner/reponame> <infodat>'%sys.argv[0])
sys.exit(1)
repo_owner, repo_name = get_repo()
print('Executing: python3 %s "%s" "%s"'%( sys.argv[0],sys.argv[1],sys.argv[2]))
repo = sys.argv[1]
infodat = sys.argv[2]
repo_owner, repo_name = repo.split('/')
###print('Repo owner:', repo_owner)
###print('Repo name:', repo_name)
GITHUB_REPO = '%s/%s/'%(repo_owner, repo_name)
PREFIX = 'cudacpp_for'
if repo_owner != 'madgraph5' : PREFIX = repo_owner + "_" + PREFIX # TEMPORARY! this will change eventually...
if repo_name != 'madgraph4gpu' : raise Exception('Invalid repo_name (expect "madgraph4gpu")') # TEMPORARY! this will change eventually...
if repo_name != 'madgraph4gpu' : raise Exception('Invalid repo_name "%s" (expect "madgraph4gpu")'%repo_name) # TEMPORARY! this will change eventually...
SUFFIX = '_latest'
tags = get_all_tags()
###print('Tags:', tags)
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/archiver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
echo "Current directory is $(pwd)"
echo "WORKDIR is ${WORKDIR}"
OWNER=$${{ github.repository_owner }}
echo "WORKDIR is ${WORKDIR}"
echo "OWNER is ${OWNER}"
TAGPREFIX=cudacpp_for
if [ "${OWNER}" != "madgraph5" ]; then TAGPREFIX="${OWNER}_${TAGPREFIX}"; fi # TEMPORARY! this will change eventually...
echo "TAGPREFIX is ${TAGPREFIX}"
Expand All @@ -88,6 +88,7 @@ jobs:
fi
echo "OK! Tagname '${tagname}' respects the expected format"
tagname_latest=${TAGPREFIX}${mg5_version}_latest
echo "(From TAGPREFIX) tagname_latest = ${tagname_latest}"
echo "TAGNAME_LATEST=${tagname_latest}" >> $GITHUB_ENV
# Update VERSION.txt
echo "" >> ${WORKDIR}/VERSION.txt
Expand Down Expand Up @@ -205,7 +206,9 @@ jobs:
cd branch_PR
echo "Current directory is now $(pwd)"
echo "Current branch is \"$(git branch | \grep ^* | sed 's/^* //')\""
python3 .github/workflows/archiver.py version_info.dat
REPO=$${{ github.repository }}
echo "REPO is ${REPO}"
python3 .github/workflows/archiver.py ${REPO} version_info.dat
mv version_info.dat ${WORKDIR}
echo "Created version_info.dat"
python3 -c 'print("-"*132)'
Expand Down

0 comments on commit 0c86da2

Please sign in to comment.