Skip to content

Commit

Permalink
[install] move "_latest" tag creation from gitTag.sh to archiver.yml …
Browse files Browse the repository at this point in the history
…(and move from 'TEST_cudacpp' to 'cudacpp' tags)
  • Loading branch information
valassi committed Sep 30, 2024
1 parent c5f5a41 commit e3c27e5
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 15 deletions.
77 changes: 74 additions & 3 deletions .github/workflows/archiver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,31 @@ name: Archiver

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

env:

TAGPREFIX: cudacpp_for

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

on:
push:
tags: [ '*' ]

tags:
# Include version tags such as 'cudacpp_for3.6.0_v1.0.0' or 'cudacpp_for3.6.0_v1.0.0_test001'
- '${{ env.TAGPREFIX }*_v*'

tags-ignore:
# Exclude running tags such as 'cudacpp_for3.6.0_latest'
- '${{ env.TAGPREFIX }*_latest'

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

jobs:

archiver:

runs-on: ubuntu-latest

steps:

- name: checkout_master
Expand All @@ -26,7 +42,7 @@ jobs:
submodules: 'true'
path: branch_PR

- name: create_tarball
- name: create_tarball_and_versiontxt
run: |
echo "HOME is ${HOME}"
echo "Current directory is $(pwd)"
Expand All @@ -37,7 +53,51 @@ jobs:
mv cudacpp.tar.gz ${HOME}
mv VERSION.txt ${HOME}
- name: release
- name:
run: |
echo "HOME is ${HOME}"
echo "" >> ${HOME}/VERSION.txt
echo "VERSION TAG: "${{ github.ref_name }} >> ${HOME}/VERSION.txt
echo "TAG NAME: "${{ github.ref_name }} >> ${HOME}/VERSION.txt
- name: check_versiontag_and_create_runningtag
run: |
echo "HOME is ${HOME}"
tagname=$${{ github.ref_name }}
echo "(From github.ref) tagname = ${tagname}"
cudacpp_version=$(cat ${HOME}/VERSION.txt | awk '/^cudacpp_version/{print $3}')
mg5_version=$(cat ${HOME}/VERSION.txt | awk '/^mg5_version_current/{print $3}')
echo "(From VERSION.txt) cudacpp_version = ${cudacpp_version}"
echo "(From VERSION.txt) mg5_version_current = ${mg5_version}"
tagname_version=${TAGPREFIX}${mg5_version}_v${cudacpp_version}
echo "(From VERSION.txt) _expected_ tagname = ${tagname_version}[_...]"
if [ "${tagname/${tagname_version}}" == "${tagname}" ]; then
echo "ERROR! Invalid tagname '${tagname}' does not start with '${tagname_version}'"
exit 1 # this will cause the job to fail without running the next steps
fi
tagname_suffix="${tagname/${tagname_version}}"
if [ `python3 -c "import re; print(re.match('(|_[0-9a-z]+)$','${tagsuffix}') is not None)"` == "False" ]; then
echo "ERROR! Invalid tagname '${tagname}' (valid format is '${tagname_version}[_txt]' where txt only contains letters or digits)"
exit 1 # this will cause the job to fail without running the next steps
fi
tagname_latest=cudacpp_for${mg5_version}_latest
echo "TAGNAME_LATEST=${tagname_latest}" >> $GITHUB_ENV

- name: create_runningtag
run: |
tagname=$${{ github.ref_name }}
echo "(From github.ref) tagname = ${tagname}"
tagname_latest=${TAGNAME_LATEST}
echo "(From GITHUB_ENV) tagname_latest = ${tagname_latest}"
commit=$(cat ${HOME}/VERSION.txt | awk '/^commit/{print $2}')
echo "(From VERSION.txt) commit = ${commit}"
git config user.name github-actions
git config user.email [email protected]
echo "INFO: create running tag ${tagname_latest}"
git tag -f ${tagname_latest} ${commit} -m "Running tag ${tagname_latest}" -m "Tag created on $(date)" -m "This is equivalent to version tag ${tagname}"
git push -f --tags
- name: release_versiontag
# See https://github.com/softprops/action-gh-release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -48,6 +108,17 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: release_runningtag
# See https://github.com/softprops/action-gh-release
uses: softprops/action-gh-release@v2
with:
tag_name: 'refs/tags/${TAGNAME_LATEST}'
files: |
${HOME}/cudacpp.tar.gz
${HOME}/VERSION.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: create_infodat
run: |
echo "HOME is ${HOME}"
Expand Down
20 changes: 8 additions & 12 deletions epochX/cudacpp/gitTag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ skipFetch=0
###skipFetch=1 # FOR DEBUGGING!

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

# Usage
function usage()
{
echo "Usage (1): $0 [-f] <tagsuffix>"
echo "Creates a new version tag and a new running tag and pushes them to the remote repository"
echo "Creates a new version tag and pushes it to the remote repository"
echo "The github CI will then create also a running tag with '_latest' suffix"
echo "Valid formats for <tagsuffix> are 'n1.n2.n3' or 'n1.n2.n3_txt' where txt only contains letters or digits"
echo "Version number 'n1.n2.n3' must match that in the CUDACPP_OUTPUT/__init__.py file"
echo "Use the -f option to delete and recreate a version tag that already exists"
Expand Down Expand Up @@ -159,13 +160,13 @@ else
done
echo ""

# Build the version and running tag names
# Build the version tag and running tag names
versTAG=${PREFIX}_for${mg5_version}_v${tagsuffix}
runnTAG=${PREFIX}_for${mg5_version}_latest
echo "INFO: will create version tag ${versTAG}"
echo "INFO: will create running tag ${runnTAG}"
echo "(the CI will create running tag ${runnTAG})"

# Check if the version tag and/or running tag already exist
# Check if the version tag already exists
for tag in ${existing_tags}; do
if [ "${versTAG}" == "${tag}" ] && [ "${force}" != "-f" ]; then
echo "ERROR! Tag ${tag} already exists: use the -f option to recreate it"
Expand All @@ -179,14 +180,9 @@ else
echo "INFO: create version tag ${versTAG}"
git tag ${force} ${versTAG} -m "Version tag ${versTAG}" -m "Tag created on $(date)"

# Create the running tag
# (always use '-f' to replace any previously existing tag with the same name)
echo "INFO: create running tag ${runnTAG}"
git tag -f ${runnTAG} -m "Running tag ${runnTAG}" -m "Tag created on $(date)" -m "This is equivalent to version tag ${versTAG}"

# Push the tags to the remote repository
# Push the tag to the remote repository
# (use '-f' to replace any previously existing tag with the same name)
echo "INFO: push tags to the remote repository"
echo "INFO: push tag to the remote repository"
git push -f --tags

fi

0 comments on commit e3c27e5

Please sign in to comment.