forked from madgraph5/madgraph4gpu
-
Notifications
You must be signed in to change notification settings - Fork 0
301 lines (277 loc) · 14.6 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# 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'
# 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'
#----------------------------------------------------------------------------------------------------------------------------------
jobs:
archiver:
runs-on: ubuntu-latest
# TEMPORARY! this will change eventually...
if: |
( github.repository == 'madgraph5/madgraph4gpu' && startsWith( github.ref, 'refs/tags/cudacpp_for' ) )
|| ( github.repository == 'valassi/madgraph4gpu' && startsWith( github.ref, 'refs/tags/valassi_cudacpp_for' ) )
steps:
- name: checkout_PR
uses: actions/checkout@v4
with:
submodules: 'true'
path: branch_PR
- name: create_tarball_and_versiontxt
run: |
echo "Current directory is $(pwd)"
WORKDIR=$(pwd)
echo "WORKDIR=${WORKDIR}" >> $GITHUB_ENV
echo "WORKDIR is ${WORKDIR}"
cd branch_PR
echo "Current directory is now $(pwd)"
echo "Current branch is \"$(git branch | \grep ^* | sed 's/^* //')\""
.github/workflows/archiver.sh
mv cudacpp.tar.gz ${WORKDIR}
mv VERSION.txt ${WORKDIR}
- name: check_versiontag_and_update_versiontxt
run: |
echo "Current directory is $(pwd)"
echo "WORKDIR is ${WORKDIR}"
githubref=$${{ github.ref }}
echo "(From github.ref) githubref = ${githubref}"
tagname=${githubref#/tags/}
echo "(From github.ref) tagname = ${tagname}"
echo "TAGNAME=${tagname}" >> $GITHUB_ENV
REPOSITORY=$${{ github.repository }}
echo "(From github.repository) REPOSITORY = ${REPOSITORY}"
###REPOOWNER=${REPOSITORY%/*} # owner is empty??
REPONAME=${REPOSITORY#*/} # owner is empty??
echo "(From github.repository) REPONAME = ${REPONAME}"
tmpsuffix=${tagname#*cudacpp_for}
TAGPREFIX=${tagname/${tmpsuffix}} # determine TAGPREFIX from triggering tag because github.repository_owner is empty(???)
echo "(From tagname) TAGPREFIX = ${TAGPREFIX}"
REPOOWNER=${TAGPREFIX%cudacpp_for}
if [ "${REPOOWNER}" == "${TAGPREFIX}" ]; then
echo "INTERNAL ERROR! Invalid TAGPREFIX '${TAGPREFIX}'" # does not end in 'cudacpp_for'?
exit 1 # this causes the job to fail without running the next steps
elif [ "${REPOOWNER}" == "" ]; then
REPOOWNER=madgraph5 # TEMPORARY! Will change eventually...
elif [ "${REPOOWNER%_}" != "${REPOOWNER}" ]; then
REPOOWNER=${REPOOWNER%_}
else
echo "INTERNAL ERROR! Invalid REPOOWNER '${REPOOWNER}'" # empty or does not end in '-'?
exit 1 # this causes the job to fail without running the next steps
fi
echo "(From tagname) REPOOWNER = ${REPOOWNER}"
REPOSITORY=${REPOOWNER}/${REPONAME}
echo "(From tagname) REPOSITORY = ${REPOSITORY}"
echo "REPOSITORY=${REPOSITORY}" >> $GITHUB_ENV
# Check version tag
cudacpp_version=$(cat ${WORKDIR}/VERSION.txt | awk '/^cudacpp_version/{print $3}')
mg5_version=$(cat ${WORKDIR}/VERSION.txt | awk '/^mg5_version_current/{print $3}')
mg5_commit=$(cat ${WORKDIR}/VERSION.txt | awk '/^mg5_commit_current/{print $3}')
echo "(From VERSION.txt) cudacpp_version = ${cudacpp_version}"
echo "(From VERSION.txt) mg5_version_current = ${mg5_version}"
echo "(From VERSION.txt) mg5_commit_current = ${mg5_commit}"
tagname_version=${TAGPREFIX}${mg5_version}_v${cudacpp_version}
echo "(From VERSION.txt) supported tagname = ${tagname_version}[_...]"
if [ "${tagname/${tagname_version}}" == "${tagname}" ]; then
echo "ERROR! Invalid tagname '${tagname}' does not start with '${tagname_version}'"
exit 1 # this causes 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]+)$','${tagname_suffix}') 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 causes the job to fail without running the next steps
fi
echo "OK! Tagname '${tagname}' respects the expected format"
tagname_latest=${TAGPREFIX}${mg5_version}_latest
echo "TAGNAME_LATEST=${tagname_latest}" >> $GITHUB_ENV
if [ "${tagname_suffix}" == "" ]; then
tagname_makelatest=true
echo "INFO: tagname ${tagname} is a release tag: will update running tag ${tagname_latest}"
else
tagname_makelatest=false
echo "INFO: tagname ${tagname} is a pre-release tag: will NOT update running tag ${tagname_latest}"
fi
echo "TAGNAME_MAKELATEST=${tagname_makelatest}" >> $GITHUB_ENV
# Update VERSION.txt
echo "" >> ${WORKDIR}/VERSION.txt
echo "VERSION TAG: ${tagname}" >> ${WORKDIR}/VERSION.txt
echo "RUNNING TAG: ${tagname_latest}" >> ${WORKDIR}/VERSION.txt
# Release notes for the version tag
echo "Version tag ${tagname} ([changelog](https://github.com/${REPOSITORY}/blob/${tagname}/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/CHANGELOG.md))" > ${WORKDIR}/versiontag.txt
echo "" >> ${WORKDIR}/versiontag.txt
echo "Validated for mg5amcnlo version ${mg5_version} (commit [${mg5_commit}](https://github.com/mg5amcnlo/mg5amcnlo/commit/${mg5_commit}))" >> ${WORKDIR}/versiontag.txt
echo "" >> ${WORKDIR}/versiontag.txt
echo "---" >> ${WORKDIR}/versiontag.txt
if [ "${tagname_makelatest}" != "true" ]; then
echo "" >> ${WORKDIR}/versiontag.txt
echo "This is a test or pre-release tag: to use it, install it directly as follows" >> ${WORKDIR}/versiontag.txt
echo "" >> ${WORKDIR}/versiontag.txt
echo "<sub>" >> ${WORKDIR}/versiontag.txt # hack to display smaller text in markdown
###echo "\`\`\`" >> ${WORKDIR}/versiontag.txt
echo "MG5_aMC>install cudacpp --cudacpp_tarball=https://github.com/${REPOSITORY}/releases/download/${tagname}/cudacpp.tar.gz" >> ${WORKDIR}/versiontag.txt
###echo "\`\`\`" >> ${WORKDIR}/versiontag.txt
echo "</sub>" >> ${WORKDIR}/versiontag.txt # hack to display smaller text in markdown
echo "" >> ${WORKDIR}/versiontag.txt
echo "---" >> ${WORKDIR}/versiontag.txt
fi
echo "" >> ${WORKDIR}/versiontag.txt
cat ${WORKDIR}/VERSION.txt | egrep '^(commit|TARBALL) ' >> ${WORKDIR}/versiontag.txt
- name: delete_versiontag_releaseonly
# See https://cli.github.com/manual/gh_release_delete
# See https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-github-cli-in-workflows
run: |
echo "Current directory is $(pwd)"
cd branch_PR
echo "Current directory is now $(pwd)"
echo "Current branch is \"$(git branch | \grep ^* | sed 's/^* //')\""
echo "Retrieve release ${{ env.TAGNAME }}"
python3 -c 'print("-"*132)'
if gh release view ${{ env.TAGNAME }}; then
python3 -c 'print("-"*132)'
echo "Delete release ${{ env.TAGNAME }}"
gh release delete ${{ env.TAGNAME }} -y
else
python3 -c 'print("-"*132)'
echo "Release ${{ env.TAGNAME }} does not exist"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: delete_runningtag_releaseandtag
if: ${{ env.TAGNAME_MAKELATEST == 'true' }}
# See https://cli.github.com/manual/gh_release_delete
# See https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-github-cli-in-workflows
run: |
echo "Current directory is $(pwd)"
cd branch_PR
echo "Current directory is now $(pwd)"
echo "Current branch is \"$(git branch | \grep ^* | sed 's/^* //')\""
echo "Retrieve release ${{ env.TAGNAME_LATEST }}"
python3 -c 'print("-"*132)'
if gh release view ${{ env.TAGNAME_LATEST }}; then
python3 -c 'print("-"*132)'
echo "Delete release ${{ env.TAGNAME_LATEST }} and the associated tag"
gh release delete ${{ env.TAGNAME_LATEST }} -y --cleanup-tag
else
python3 -c 'print("-"*132)'
echo "Release ${{ env.TAGNAME_LATEST }} does not exist"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: create_runningtag
if: ${{ env.TAGNAME_MAKELATEST == 'true' }}
run: |
echo "Current directory is $(pwd)"
echo "WORKDIR is ${WORKDIR}"
cd branch_PR
echo "Current directory is now $(pwd)"
echo "Current branch is \"$(git branch | \grep ^* | sed 's/^* //')\""
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}"
mg5_version=$(cat ${WORKDIR}/VERSION.txt | awk '/^mg5_version_current/{print $3}')
mg5_commit=$(cat ${WORKDIR}/VERSION.txt | awk '/^mg5_commit_current/{print $3}')
echo "(From VERSION.txt) mg5_version_current = ${mg5_version}"
echo "(From VERSION.txt) mg5_commit_current = ${mg5_commit}"
# Create running tag
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}"
git push -f --tags
# Release notes for the running tag
echo "Running tag ${tagname_latest} ([changelog](https://github.com/${REPOSITORY}/blob/${tagname_latest}/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/CHANGELOG.md))" > ${WORKDIR}/runningtag.txt
echo "This is equivalent to version tag ${tagname}" >> ${WORKDIR}/runningtag.txt
echo "" >> ${WORKDIR}/runningtag.txt
echo "Validated for mg5amcnlo version ${mg5_version} (commit [${mg5_commit}](https://github.com/mg5amcnlo/mg5amcnlo/commit/${mg5_commit}))" >> ${WORKDIR}/runningtag.txt
echo "" >> ${WORKDIR}/runningtag.txt
echo "---" >> ${WORKDIR}/runningtag.txt
echo "" >> ${WORKDIR}/runningtag.txt
cat ${WORKDIR}/VERSION.txt | egrep '^(commit|TARBALL) ' >> ${WORKDIR}/runningtag.txt
- name: release_versiontag
# See https://github.com/softprops/action-gh-release
uses: softprops/action-gh-release@v2
with:
name: ${{ env.TAGNAME }}
prerelease: ${{ env.TAGNAME_MAKELATEST != 'true' }}
make_latest: ${{ env.TAGNAME_MAKELATEST }}
body_path: versiontag.txt
# 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
if: ${{ env.TAGNAME_MAKELATEST == 'true' }}
# See https://github.com/softprops/action-gh-release
uses: softprops/action-gh-release@v2
with:
name: ${{ env.TAGNAME_LATEST }}
prerelease: ${{ env.TAGNAME_MAKELATEST != 'true' }}
make_latest: ${{ env.TAGNAME_MAKELATEST }}
tag_name: refs/tags/${{ env.TAGNAME_LATEST }}
body_path: runningtag.txt
# 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
if: ${{ env.TAGNAME_MAKELATEST == 'true' }}
run: |
echo "Current directory is $(pwd)"
echo "WORKDIR is ${WORKDIR}"
cd branch_PR
echo "Current directory is now $(pwd)"
echo "Current branch is \"$(git branch | \grep ^* | sed 's/^* //')\""
echo "(From GITHUB_ENV) REPOSITORY = ${REPOSITORY}"
python3 .github/workflows/archiver.py ${REPOSITORY} version_info.dat
mv version_info.dat ${WORKDIR}
echo "Created version_info.dat"
python3 -c 'print("-"*132)'
cat ${WORKDIR}/version_info.dat
- name: checkout_INFO
if: ${{ env.TAGNAME_MAKELATEST == 'true' }}
uses: actions/checkout@v4
with:
ref: INFO
path: branch_INFO
- name: commit_infodat
if: ${{ env.TAGNAME_MAKELATEST == 'true' }}
run: |
echo "Current directory is $(pwd)"
echo "WORKDIR is ${WORKDIR}"
cd branch_INFO
echo "Current directory is now $(pwd)"
echo "Current branch is \"$(git branch | \grep ^* | sed 's/^* //')\""
mv ${WORKDIR}/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 "No changes detected in version_info.dat: 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
#----------------------------------------------------------------------------------------------------------------------------------