Improve update.yml

This commit is contained in:
windowsboy111
2022-10-16 19:11:19 +08:00
parent 7452874964
commit afaba869b3
6 changed files with 144 additions and 1 deletions
+36
View File
@@ -0,0 +1,36 @@
# for each folder in ultramarine/
# if there is chkupdate.py
# run it every 2 hours
name: Automatically check for updates
on:
schedule:
- cron: '0 */2 * * *'
workflow_dispatch:
jobs:
get-chkupdate-scripts:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- run: git fetch
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Run Update
run: ./update.sh
- name: Save
run: |
if [[ `git status --porcelain` ]]; then
git config user.name "Package Update Checker"
git config user.email "<>"
git commit -a -m "Automatic Update by chkupdate.py"
git push origin master
fi
+1 -1
View File
@@ -19,7 +19,7 @@ ver = data['channel-map'][0]['version']
f = open(SPEC, 'r')
content = f.read()
found = re.findall(REGEX, content)
found = re.findall(REGEX_VER, content)
try:
assert found
curver = found[0][1]
+6
View File
@@ -0,0 +1,6 @@
project "pkg" {
rpm {
spec = "discord-canary.spec"
sources = "."
}
}
+43
View File
@@ -0,0 +1,43 @@
import os
import re
from requests import get
def run_cmds(*cmds: str):
for cmd in cmds:
print(f"chkupdate: $ {cmd}")
if rc := os.system(cmd):
exit(f"chkupdate: Stopping because {rc=}")
SPEC = 'discord-canary.spec'
REGEX = r'Version:(\s+)([\.\d]+)\n'
LINK = 'https://discordapp.com/api/download/canary?platform=linux&format=tar.gz'
html = get(LINK, allow_redirects=False).text
newver = re.findall(r'https://dl-canary\.discordapp\.net/apps/linux/([\.\d]+)/', html)
if not any(newver):
exit("chkupdate: Failed to parse html!")
newver = newver[0]
f = open(SPEC, 'r')
content = f.read()
found = re.findall(REGEX, content)
try:
assert found
curver = found[0][1]
if newver == curver:
print("chkupdate: Up to date!")
exit()
else:
print(f"chkupdate: {curver} -> {newver}")
except IndexError or AssertionError:
exit("chkupdate: Failed to read spec!")
newspec = re.sub(REGEX, f'Version:{found[0][0]}{newver}\n', content, 1)
f.close()
f = open(SPEC, 'w')
f.write(newspec)
f.close()
run_cmds(f"wget https://discordapp.com/api/download/canary?platform=linux&format=tar.gz")
+40
View File
@@ -0,0 +1,40 @@
Name: discord-canary
Version: 0.0.139
Release: %autorelease
Summary: Free Voice and Text Chat for Gamers.
URL: discord.com
Source0: https://dl-canary.discordapp.net/apps/linux/%{version}/discord-canary-%{version}.tar.gz
License: https://discord.com/terms
Requires: libatomic, glibc, alsa-lib, GConf2, libnotify, nspr >= 4.13, nss >= 3.27, libstdc++, libX11 >= 1.6, libXtst >= 1.2, libappindicator, libcxx, libXScrnSaver
Group: Applications/Internet
ExclusiveArch: x86_64
%description
Imagine a place where you can belong to a school club, a gaming group, or a worldwide art community. Where just you and a handful of friends can spend time together. A place that makes it easy to talk every day and hang out more often.
%prep
%autosetup -n DiscordCanary
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p %{buildroot}%{_datadir}/discord-canary
cp -rv * %{buildroot}%{_datadir}/discord-canary
mkdir -p %{buildroot}%{_datadir}/applications/
mkdir -p %{buildroot}%{_datadir}/pixmaps
install discord-canary.desktop %{buildroot}%{_datadir}/applications/discord-canary.desktop
install discord.png %{buildroot}%{_datadir}/pixmaps/discord-canary.png
%files
%{_datadir}/discord-canary/
%{_datadir}/applications/discord-canary.desktop
%{_datadir}/pixmaps/discord-canary.png
%changelog
* Sun Oct 16 2022 windowsboy111 <wboy111@outlook.com> - 0.0.139
- Repackaged for Terra
* Tue Feb 22 2022 Ultramarine Release Tracking Service - 0.0.133-2
- Mass rebuild for release um36
* Sat Nov 20 2021 Cappy Ishihara <cappy@cappuchino.xyz>
- Initial release
Executable
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
search() {
for folder in $1/*; do
if [ -f "$folder/chkupdate.py" ]; then
echo :: $folder
(cd $folder && python chkupdate.py)
continue
fi
x=0
for thing in $folder/*; do
[[ -f $thing ]] && x=1 && break
done
[[ $x -eq 1 ]] && search $folder
done
}
search anda