v1.0.0 release: tarball creation/installation, plugin symlink management, release management #15
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 | ||
steps: | ||
- name: checkout_PR | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: 'true' | ||
path: branch_PR | ||
- name: create_tarball_and_versiontxt | ||
run: | | ||
echo "HOME is ${HOME}" | ||
echo "Current directory is $(pwd)" | ||
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 ${HOME} | ||
mv VERSION.txt ${HOME} | ||
- name: check_versiontag_and_create_runningtag_and_update_versiontxt | ||
run: | | ||
echo "HOME is ${HOME}" | ||
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 ${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=${TAGPREFIX}${mg5_version}_latest | ||
echo "TAGNAME_LATEST=${tagname_latest}" >> $GITHUB_ENV | ||
echo "" >> ${HOME}/VERSION.txt | ||
echo "VERSION TAG: ${tagname} >> ${HOME}/VERSION.txt | ||
echo "RUNNING TAG: ${tagname_latest} >> ${HOME}/VERSION.txt | ||
- name: create_runningtag | ||
run: | | ||
echo "HOME is ${HOME}" | ||
echo "Current directory is $(pwd)" | ||
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 ${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 | ||
echo HOME=${HOME} | ||
ls ${HOME} | ||
cat ${HOME}/VERSION.txt | ||
- name: release_versiontag | ||
# See https://github.com/softprops/action-gh-release | ||
uses: softprops/action-gh-release@v2 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: | | ||
${HOME}/cudacpp.tar.gz | ||
${HOME}/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: | ||
# 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}" | ||
echo "Current directory is $(pwd)" | ||
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)" | ||
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 | ||
#---------------------------------------------------------------------------------------------------------------------------------- |