Skip to content

Commit

Permalink
[install] in archiver.py, archiver.yml, gitTag.sh: add separate tag p…
Browse files Browse the repository at this point in the history
…refixes for forks (e.g. valassi_cudacpp_for... tags)
  • Loading branch information
valassi committed Oct 1, 2024
1 parent 8530ae3 commit 25b4e73
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 17 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
import subprocess
import sys

GITHUB_REPO = 'valassi/madgraph4gpu/'

PREFIX = 'cudacpp_for'
SUFFIX = '_latest'
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()
Expand All @@ -31,6 +30,14 @@ def create_infodat_file(path, versions):
if len(sys.argv) != 2:
print('Usage: python3 %s <infodat>'%sys.argv[0])
sys.exit(1)
repo_owner, repo_name = get_repo()
###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...
SUFFIX = '_latest'
tags = get_all_tags()
###print('Tags:', tags)
versions = get_supported_versions(tags)
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/archiver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ on:

tags:
# Include version tags such as 'cudacpp_for3.6.0_v1.0.0' or 'cudacpp_for3.6.0_v1.0.0_test001'
- 'cudacpp_for*_v*'
# Include version tags such as 'valassi_cudacpp_for3.6.0_v1.0.0' or 'valassi_cudacpp_for3.6.0_v1.0.0_test001'
- '*cudacpp_for*_v*'

# Exclude running tags such as 'cudacpp_for3.6.0_latest'
# Exclude running tags such as 'valassi_cudacpp_for3.6.0_latest'
# See https://github.com/orgs/community/discussions/25114
- '!cudacpp_for*_latest'
- '!*cudacpp_for*_latest'

#----------------------------------------------------------------------------------------------------------------------------------

Expand All @@ -27,7 +30,10 @@ jobs:

runs-on: ubuntu-latest

if: github.repository == 'valassi/madgraph4gpu'
# TEMPORARY! this will change eventually...
if: |
( github.repository == 'madgraph5/madgraph4gpu' && startsWith( github.ref, '/tags/cudacpp_for' ) )
|| ( github.repository == 'valassi/madgraph4gpu' && startsWith( github.ref, '/tags/valassi_cudacpp_for' ) )
steps:

Expand All @@ -54,7 +60,10 @@ jobs:
run: |
echo "Current directory is $(pwd)"
echo "WORKDIR is ${WORKDIR}"
OWNER = $${{ github.repository_owner }}
echo "WORKDIR is ${WORKDIR}"
TAGPREFIX=cudacpp_for
if [ "${OWNER}" != "madgraph5" ]; then TAGPREFIX="${OWNER}_${TAGPREFIX}"; fi # TEMPORARY! this will change eventually...
echo "TAGPREFIX is ${TAGPREFIX}"
githubref=$${{ github.ref }}
echo "(From github.ref) githubref = ${githubref}"
Expand Down Expand Up @@ -163,7 +172,6 @@ jobs:
- name: release_versiontag
# See https://github.com/softprops/action-gh-release
uses: softprops/action-gh-release@v2
###if: startsWith(github.ref, 'refs/tags/')
with:
name: ${{ env.TAGNAME }}
body_path: versiontag.txt
Expand Down
30 changes: 21 additions & 9 deletions epochX/cudacpp/gitTag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ scr=$(basename $(cd ..; pwd))/$(basename $(pwd))/$(basename $0) # the name of th
skipFetch=0
###skipFetch=1 # FOR DEBUGGING!

# The tag prefix used for all tags handled by this script
PREFIX=cudacpp_for

# Protect non-prerelease tags from deletion?
PROTECTTAGS=1
###PROTECTTAGS=0 # WARNING! USE WITH CARE...
Expand Down Expand Up @@ -54,28 +51,43 @@ fi

# Determine the local git branch
brn=`git branch | grep \* | cut -d ' ' -f2`
echo "INFO: git branch is '${brn}'"
echo "INFO: git branch is '${brn}'"
if [ "${brn}" != "install" ]; then # TEMPORARY! this should be branch 'master' eventually...
echo "ERROR! Invalid local branch ${brn}"
exit 1
fi

# Determine the remote git origin and the corresponding project name
# Determine the remote git origin and the corresponding repo name
# Stop if the remote git origin is not at github.com
url=`git config --get remote.origin.url`
echo "INFO: git remote is '${url}'"
echo "INFO: git remote is '${url}'"
url=${url%.git}
prj=${url##*github.com:}
if [ "${url}" == "${prj}" ]; then
echo "ERROR! git remote does not seem to be at github.com"
exit 1
fi
echo "INFO: git project is '${prj}'"
if [ "${prj}" != "valassi/madgraph4gpu" ]; then # TEMPORARY! this will change eventually...
echo "ERROR! Invalid project ${prj}"
echo "INFO: git repo is '${prj}'"
prjown=${prj%/*}
prjnam=${prj#*/}
echo "INFO: git repo owner is '${prjown}'"
echo "INFO: git repo name is '${prjnam}'"

# Check the repo name
if [ "${prjnam}" != "madgraph4gpu" ]; then # TEMPORARY! this will change eventually...
echo "ERROR! Invalid repo name '${prjnam}' (expect 'madgraph4gpu')"
exit 1
fi

# Check the repo owner
# Determine the tag prefix used for all tags handled by this script
if [ "${prjown}" == "madgraph5" ]; then # TEMPORARY! this will change eventually...
PREFIX=cudacpp_for
else
PREFIX=${prjown}_cudacpp_for
fi
echo "INFO! Tag prefix for repo owner '${prjown}' is '${PREFIX}'"

# Check that all changes are committed to git (except at most for this script only in the '-l' mode)
if [ "$(git status --porcelain | grep -v ^??)" != "" ]; then
if [ "$tagsuffix" != "" ] || [ "$(git status --porcelain | grep -v ^??)" != " M ${scr}" ]; then
Expand Down

0 comments on commit 25b4e73

Please sign in to comment.