-
Notifications
You must be signed in to change notification settings - Fork 32
161 lines (141 loc) · 6.29 KB
/
archiver.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# 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
#----------------------------------------------------------------------------------------------------------------------------------