Skip to content

Commit

Permalink
Merge pull request #20 from Heshdude/improving-automation
Browse files Browse the repository at this point in the history
Improving automation
  • Loading branch information
Heshdude committed Aug 8, 2020
2 parents 3dab7c6 + b46d93a commit 1894d86
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ jobs:
PREFIX_FILTER: |
installers
- name: Generate installers, update README.md & installers.toml
run: |
pip install toml
pip install pytablewriter
python generate.py ${{ env.GIT_DIFF }}
run: ./generate.sh ${{ env.GIT_DIFF }}
if: env.GIT_DIFF
- name: Minify generated installers
run: ./minify.sh ${{ env.GIT_DIFF }}
Expand Down
11 changes: 3 additions & 8 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def update_readme(summary):
curl = "Yes" if "curl" in installers else "No"
url = "https://installer.to/"+tool_shortname
value_matrix.append([name, apt, yum, pacman, apk, dnf, curl, url])
print(value_matrix)

writer.value_matrix = value_matrix
table_md = writer.dumps()
try:
Expand All @@ -46,32 +46,28 @@ def update_readme(summary):
readme_md.write(readme)
readme_md.close()
except Error as e:
print(e)
logging.error('Error occurred when trying to update README.md, error: '+ e)


def update_summary(name, shortname, description, installers):
try:
with open("./installers.toml", "r+") as installer_summary:
summaary = installer_summary.read()
print (summaary)
parsed_summary_toml = toml.loads(summaary)
print (parsed_summary_toml)
if shortname not in parsed_summary_toml:
parsed_summary_toml[shortname] = {}
parsed_summary_toml[shortname]['name'] = name
parsed_summary_toml[shortname]['name'] = name
parsed_summary_toml[shortname]['description'] = description
parsed_summary_toml[shortname]['installers'] = ",".join(installers)
print (parsed_summary_toml)
installer_summary.seek(0) # sets point at the beginning of the file
installer_summary.truncate() # Clear previous content
installer_summary.write(toml.dumps(parsed_summary_toml))
installer_summary.close()

update_readme(parsed_summary_toml)
except IOError as e:
print ("Error", e)
pass
logging.error('Error occurred when trying to update installers.toml, error: '+ e)

def get_method_case(method):
if method in methods:
Expand Down Expand Up @@ -167,7 +163,6 @@ def generate(path):

installer_sh.close()
update_summary(parsed_toml['name'], parsed_toml['shortname'], parsed_toml['description'], installer_methods)
print("installer_methods",installer_methods)

except IOError as x:
if x.errno == errno.EACCES:
Expand Down
14 changes: 14 additions & 0 deletions generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

X=()

for word in "$@"; do
X+=$(dirname "$word " | cut -d "/" -f "1 2")" "
done

CHANGED=$(echo $X | tr ' ' '\n' | sort | uniq | xargs)

echo "generating for $CHANGED"
pip install toml
pip install pytablewriter
python generate.py $CHANGED

0 comments on commit 1894d86

Please sign in to comment.