mirror of
https://github.com/TeamPGM/PagerMaid_Plugins_Pyro.git
synced 2024-11-22 12:15:38 +00:00
CI: auto update version list
This commit is contained in:
parent
2746fedf49
commit
c11f43e98e
22
.github/workflows/python.yml
vendored
22
.github/workflows/python.yml
vendored
@ -4,6 +4,12 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- v2
|
- v2
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
- '.github/**'
|
||||||
|
- 'list.json'
|
||||||
|
- 'telegram_update.py'
|
||||||
|
- 'update_list.py'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -23,13 +29,23 @@ jobs:
|
|||||||
# 安装依赖
|
# 安装依赖
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
mkdir tmp && cd tmp
|
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install httpx
|
pip install httpx
|
||||||
|
|
||||||
# 发送通知
|
# 发送通知
|
||||||
- name: Send notice
|
- name: Send notice
|
||||||
run: |
|
run: |
|
||||||
cd tmp
|
|
||||||
cp ../telegram_update.py ./
|
|
||||||
python telegram_update.py ${{ secrets.TG_BOT_TOKEN }}
|
python telegram_update.py ${{ secrets.TG_BOT_TOKEN }}
|
||||||
|
|
||||||
|
# 更新 list
|
||||||
|
- name: Update list
|
||||||
|
run: |
|
||||||
|
python update_list.py
|
||||||
|
|
||||||
|
# Auto commit
|
||||||
|
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
|
with:
|
||||||
|
# Optional. Commit message for the created commit.
|
||||||
|
# Defaults to "Apply automatic changes"
|
||||||
|
commit_message: "CI: Update version json"
|
||||||
|
file_pattern: 'list.json'
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import json, time, sys
|
import time
|
||||||
|
import sys
|
||||||
|
import contextlib
|
||||||
from httpx import get, post
|
from httpx import get, post
|
||||||
|
|
||||||
token = str(sys.argv[1])
|
token = str(sys.argv[1])
|
||||||
main = json.loads(get("https://api.github.com/repos/TeamPGM/PagerMaid_Plugins_Pyro/commits/v2").content)
|
main = get("https://api.github.com/repos/TeamPGM/PagerMaid_Plugins_Pyro/commits/v2").json()
|
||||||
text = (
|
text = (
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
@ -19,17 +21,10 @@ text = (
|
|||||||
+ '): '
|
+ '): '
|
||||||
) + main['commit']['message']
|
) + main['commit']['message']
|
||||||
|
|
||||||
push_content = {'chat_id': '-1001441461877', 'disable_web_page_preview': 'True', 'parse_mode': 'markdown',
|
|
||||||
'text': text}
|
|
||||||
url = f'https://api.telegram.org/bot{token}/sendMessage'
|
url = f'https://api.telegram.org/bot{token}/sendMessage'
|
||||||
try:
|
for cid in ['-1001441461877', '-1001319957857']:
|
||||||
main_req = post(url, data=push_content)
|
push_content = {'chat_id': cid, 'disable_web_page_preview': 'True', 'parse_mode': 'markdown', 'text': text}
|
||||||
except:
|
with contextlib.suppress(Exception):
|
||||||
pass
|
main_req = post(url, data=push_content)
|
||||||
push_content['chat_id'] = '-1001319957857'
|
time.sleep(1)
|
||||||
time.sleep(1)
|
|
||||||
try:
|
|
||||||
main_req = post(url, data=push_content)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
print(main['sha'] + " ok!")
|
print(main['sha'] + " ok!")
|
||||||
|
29
update_list.py
Normal file
29
update_list.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
from httpx import get
|
||||||
|
|
||||||
|
main = get("https://api.github.com/repos/TeamPGM/PagerMaid_Plugins_Pyro/commits/v2").json()
|
||||||
|
plugins = [i["filename"].split("/")[0] for i in main["files"] if "/main.py" in i["filename"]]
|
||||||
|
with open("list.json", "r", encoding="utf8") as f:
|
||||||
|
list_json = json.load(f)
|
||||||
|
for plugin in plugins:
|
||||||
|
exist = False
|
||||||
|
for plug_dict in list_json["list"]:
|
||||||
|
if plug_dict["name"] == plugin:
|
||||||
|
exist = True
|
||||||
|
old_version = float(plug_dict["version"])
|
||||||
|
list_json["list"][list_json["list"].index(plug_dict)]["version"] = str(old_version + 0.01)
|
||||||
|
break
|
||||||
|
if not exist:
|
||||||
|
list_json["list"].append(
|
||||||
|
{"name": plugin,
|
||||||
|
"version": "1.0",
|
||||||
|
"section": "chat",
|
||||||
|
"maintainer": main['commit']['author']['name'],
|
||||||
|
"size": f"{os.path.getsize(f'{plugin}{os.sep}main.py') / 1000} kb",
|
||||||
|
"supported": True,
|
||||||
|
"des-short": "这个人很懒,什么都没留下",
|
||||||
|
"des": "这个人很懒,什么都没有留下。"})
|
||||||
|
with open("list.json", "w", encoding="utf8") as f:
|
||||||
|
json.dump(list_json, f, ensure_ascii=False, indent=4)
|
||||||
|
print(main['sha'] + " ok!")
|
Loading…
Reference in New Issue
Block a user