[install] in archiver.yml ensure that the tag name is used as the nam… #82
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2020-2024 CERN and UCLouvain. | |
# Licensed under the GNU Lesser General Public License (version 3 or later). | |
# Created by: A. Valassi (Sep 2024) for the MG5aMC CUDACPP plugin. | |
# Further modified by: A. Valassi (2024) for the MG5aMC CUDACPP plugin. | |
#---------------------------------------------------------------------------------------------------------------------------------- | |
name: Archiver | |
#---------------------------------------------------------------------------------------------------------------------------------- | |
on: | |
push: | |
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*' | |
# Exclude running tags such as 'cudacpp_for3.6.0_latest' | |
# See https://github.com/orgs/community/discussions/25114 | |
- '!cudacpp_for*_latest' | |
#---------------------------------------------------------------------------------------------------------------------------------- | |
jobs: | |
archiver: | |
runs-on: ubuntu-latest | |
if: github.repository == 'valassi/madgraph4gpu' | |
steps: | |
- name: checkout_PR | |
uses: actions/checkout@v4 | |
with: | |
submodules: 'true' | |
path: branch_PR | |
- name: create_tarball_and_versiontxt | |
run: | | |
WORKDIR=$(pwd) | |
echo "WORKDIR=${WORKDIR}" >> $GITHUB_ENV | |
echo "HOME is ${HOME}" | |
echo "Current directory is $(pwd)" | |
echo "WORKDIR is ${WORKDIR}" | |
cd branch_PR | |
echo "Current directory is now $(pwd)" | |
echo "Current branch is $(git branch --show-current)" | |
.github/workflows/archiver.sh | |
mv cudacpp.tar.gz ${WORKDIR} | |
mv VERSION.txt ${WORKDIR} | |
- name: check_versiontag_and_create_runningtag_and_update_versiontxt | |
run: | | |
echo "HOME is ${HOME}" | |
echo "WORKDIR is ${WORKDIR}" | |
TAGPREFIX=cudacpp_for | |
echo "TAGPREFIX is ${TAGPREFIX}" | |
githubref=$${{ github.ref }} | |
echo "(From github.ref) githubref = ${githubref}" | |
tagname=${githubref#/tags/} | |
echo "(From github.ref) tagname = ${tagname}" | |
echo "TAGNAME=${tagname}" >> $GITHUB_ENV | |
cudacpp_version=$(cat ${WORKDIR}/VERSION.txt | awk '/^cudacpp_version/{print $3}') | |
mg5_version=$(cat ${WORKDIR}/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=${TAGPREFIX}${mg5_version}_latest | |
echo "TAGNAME_LATEST=${tagname_latest}" >> $GITHUB_ENV | |
echo "" >> ${WORKDIR}/VERSION.txt | |
echo "VERSION TAG: ${tagname}" >> ${WORKDIR}/VERSION.txt | |
echo "RUNNING TAG: ${tagname_latest}" >> ${WORKDIR}/VERSION.txt | |
- name: create_runningtag | |
run: | | |
echo "HOME is ${HOME}" | |
echo "Current directory is $(pwd)" | |
echo "WORKDIR is ${WORKDIR}" | |
cd branch_PR | |
echo "Current directory is now $(pwd)" | |
echo "Current branch is $(git branch --show-current)" | |
tagname=${TAGNAME} | |
echo "(From GITHUB_ENV) tagname = ${tagname}" | |
tagname_latest=${TAGNAME_LATEST} | |
echo "(From GITHUB_ENV) tagname_latest = ${tagname_latest}" | |
commit=$(cat ${WORKDIR}/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}" | |
echo "Running tag ${tagname_latest}" > msg.txt | |
echo "This is equivalent to version tag ${tagname}" >> msg.txt | |
echo "" >> msg.txt | |
python3 -c 'print("="*80)' >> msg.txt | |
cat ${WORKDIR}/VERSION.txt >> msg.txt | |
python3 -c 'print("="*80)' >> msg.txt | |
git tag -f ${tagname_latest} ${commit} -F msg.txt | |
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/') | |
with: | |
name: ${{ env.TAGNAME }} | |
# Previous attempt to upload files from ${HOME}/VERSION.txt and ${HOME}/cudacpp.tar.gz failed | |
# The current implementation uploads files from the default $WORKDIR (without giving the explicit full path) | |
files: | | |
cudacpp.tar.gz | |
VERSION.txt | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: release_runningtag | |
# See https://github.com/softprops/action-gh-release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: ${{ env.TAGNAME_LATEST }} | |
tag_name: refs/tags/${{ env.TAGNAME_LATEST }} | |
# Previous attempt to upload files from ${HOME}/VERSION.txt and ${HOME}/cudacpp.tar.gz failed | |
# The current implementation uploads files from the default $WORKDIR (without giving the explicit full path) | |
files: | | |
cudacpp.tar.gz | |
VERSION.txt | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: create_infodat | |
run: | | |
echo "HOME is ${HOME}" | |
echo "Current directory is $(pwd)" | |
echo "WORKDIR is ${WORKDIR}" | |
cd branch_PR | |
echo "Current directory is now $(pwd)" | |
echo "Current branch is $(git branch --show-current)" | |
python3 .github/workflows/archiver.py version_info.dat | |
mv version_info.dat ${HOME} | |
- name: checkout_INFO | |
uses: actions/checkout@v4 | |
with: | |
ref: INFO | |
path: branch_INFO | |
- name: commit_infodat | |
run: | | |
echo "HOME is ${HOME}" | |
echo "Current directory is $(pwd)" | |
echo "WORKDIR is ${WORKDIR}" | |
cd branch_INFO | |
echo "Current directory is now $(pwd)" | |
echo "Current branch is $(git branch --show-current)" | |
mv ${HOME}/version_info.dat . | |
git config user.name github-actions | |
git config user.email [email protected] | |
if [ -z "$(git status --porcelain version_info.dat)" ]; then | |
echo "Nothing to commit" | |
else | |
echo "Commit and push version_info.dat" | |
echo "Update version_info.dat" > msg.txt | |
echo "" >> msg.txt | |
git diff version_info.dat | tail --lines=+6 >> msg.txt | |
git commit -F msg.txt version_info.dat | |
git push | |
fi | |
#---------------------------------------------------------------------------------------------------------------------------------- |