Skip to content

Commit 874474c

Browse files
committed
Shell file added to release files
1 parent 4ef4fd1 commit 874474c

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

.github/workflows/list-versions.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,41 @@
77
# containing each product name and associated last version.
88
# Used in CI when a new is release is creted to comment it.
99
def listVersions(source_path):
10+
print("Extracting products name and version from Spack recipes")
1011
recipes = glob.glob(source_path + '/**/package.py', recursive=True)
12+
products = {}
13+
for recipe in recipes:
14+
with open(recipe) as f:
15+
product_name = os.path.basename(os.path.dirname(recipe))
16+
line = ' '.join(f.readlines())
17+
version = re.search("version\([\'\"]([0-9]+(\.[0-9]+)*)[\'\"]", line)
18+
version_name = 'undefined' if version is None else version.group(1)
19+
recipes[product_name] = version_name
20+
print(products)
21+
1122
file_name = source_path + '/recipes.md'
23+
print("Creating markdown file:", file_name)
1224
with open(file_name, 'w') as md:
1325
md.write('**Below the last version of products contained in Spack recipes for this release.**\n')
1426
md.write('| Product | Version |\n')
1527
md.write('| ------- | ------- |\n')
16-
for recipe in recipes:
17-
with open(recipe) as f:
18-
product_name = os.path.basename(os.path.dirname(recipe))
19-
line = ' '.join(f.readlines())
20-
version = re.search("version\([\'\"]([0-9]+(\.[0-9]+)*)[\'\"]", line)
21-
version_name = 'undefined' if version is None else version.group(1)
22-
md.write('| ' + product_name + ' | ' + version_name + ' |\n')
28+
for product in products:
29+
product_name = product[0]
30+
version = product[1]
31+
md.write('| ' + product_name + ' | ' + version + ' |\n')
2332
print("File created:", file_name)
2433

34+
file_name = source_path + '/recipes.sh'
35+
print("Creating bash file:", file_name)
36+
with open(file_name, 'w') as md:
37+
md.write('#!/bin/bash\n\n')
38+
md.write('declare -A products\n')
39+
for product in products:
40+
product_name = product[0]
41+
version = product[1]
42+
md.write('products[' + product_name + ']=' + version + '\n')
43+
print("File created:", file_name)
44+
2545
if __name__ == "__main__":
2646
project_path = sys.argv[1]
2747
listVersions(project_path)

.github/workflows/make-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
uses: softprops/action-gh-release@v1
2828
with:
2929
body_path: ${{ github.workspace }}/recipes.md
30+
files: ${{ github.workspace }}/recipes.sh
3031
env:
3132
USERNAME: ${{ github.actor }}
3233
PASSWORD: ${{ github.token }}

0 commit comments

Comments
 (0)