-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e77606d
commit c333423
Showing
1 changed file
with
40 additions
and
36 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,40 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2021-2022 José Manuel Barroso Galindo <[email protected]> | ||
|
||
set -euo pipefail | ||
|
||
git add dont_download.sh | ||
git commit -m "BOT: New dont_download.sh" > /dev/null 2>&1 || true | ||
git fetch origin main | ||
|
||
set +e | ||
CHANGES="$(git diff main:dont_download.sh origin/main:dont_download.sh | sed '/^[+-]export COMMIT/d' | sed '/^+++/d' | sed '/^---/d' | grep '^[+-]' | wc -l)" | ||
set -e | ||
|
||
if [ ${CHANGES} -ge 1 ] ; then | ||
echo "There are changes to push." | ||
echo | ||
git push origin main | ||
|
||
if ! gh release list | grep -q "latest" ; then | ||
gh release create "latest" || true | ||
sleep 15s | ||
fi | ||
|
||
md5sum "dont_download.zip" > "dont_download.zip.md5" | ||
|
||
gh release upload "latest" "dont_download.zip" --clobber | ||
gh release upload "latest" "dont_download.zip.md5" --clobber | ||
gh release upload "latest" "src/downloader.zip" --clobber | ||
|
||
echo | ||
echo "New dont_download.sh can be used." | ||
echo "::set-output name=NEW_RELEASE::yes" | ||
else | ||
echo "Nothing to be updated." | ||
echo "::set-output name=NEW_RELEASE::no" | ||
fi | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2021-2024 José Manuel Barroso Galindo <[email protected]> | ||
|
||
import subprocess | ||
import os | ||
|
||
subprocess.run(['git', 'add', 'dont_download.sh'], check=True) | ||
subprocess.run(['git', 'commit', '-m', 'BOT: New dont_download.sh'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) | ||
|
||
subprocess.run(['git', 'fetch', 'origin', 'main'], check=True) | ||
|
||
diff_cmd = "git diff main:dont_download.sh origin/main:dont_download.sh" | ||
filter_cmd = "grep '^[+-]' | grep -v 'export COMMIT' | grep -v '^\+\+\+' | grep -v '^---'" | ||
changes = subprocess.getoutput(f"{diff_cmd} | {filter_cmd} | wc -l") | ||
|
||
if int(changes) >= 1: | ||
print("There are changes to push:\n") | ||
print(changes) | ||
print() | ||
subprocess.run(['git', 'push', 'origin', 'main'], check=True) | ||
|
||
has_latest = subprocess.run(['gh', 'release', 'list'], capture_output=True, text=True) | ||
if "latest" not in has_latest.stdout: | ||
subprocess.run(['gh', 'release', 'create', 'latest'], stderr=subprocess.DEVNULL) | ||
|
||
time.sleep(15) | ||
|
||
subprocess.run(['md5sum', 'dont_download.zip', '>', 'dont_download.zip.md5'], shell=True) | ||
|
||
subprocess.run(['gh', 'release', 'upload', 'latest', 'dont_download.zip', '--clobber'], check=True) | ||
subprocess.run(['gh', 'release', 'upload', 'latest', 'dont_download.zip.md5', '--clobber'], check=True) | ||
subprocess.run(['gh', 'release', 'upload', 'latest', 'src/downloader.zip', '--clobber'], check=True) | ||
|
||
print("\nNew dont_download.sh can be used.") | ||
with open(os.environ['GITHUB_OUTPUT'], 'a') as f: | ||
f.write("NEW_RELEASE=yes\n") | ||
else: | ||
print("Nothing to be updated.") | ||
with open(os.environ['GITHUB_OUTPUT'], 'a') as f: | ||
f.write("NEW_RELEASE=no\n") |