Skip to content

Get Exts

Get Exts #316

Workflow file for this run

#
# Copyright (C) 2022 Ing <https://github.com/wjz304>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
name: Get Exts
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
exts:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Initialization environment
run : |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Asia/Shanghai"
- name: Checkout rp-ext s
run: |
sudo rm -rf rp-ext_pocopico
git clone https://github.com/pocopico/rp-ext rp-ext_pocopico
# 容错
rm -f rp-ext_pocopico/asix/releases/ds3617xs_42218.json
rm -f rp-ext_pocopico/ax88179_178a/releases/ds3617xs_42218.json
rm -f rp-ext_pocopico/dm9601/releases/ds3617xs_42218.json
rm -f rp-ext_pocopico/nct6775/releases/dva3221_42218.json
rm -f rp-ext_pocopico/sfc/releases/ds918p_25556.json
rm -f rp-ext_pocopico/v9fs/releases/ds918p_42218.json
sudo rm -rf rp-ext_wjz304
git clone https://github.com/wjz304/rp-ext rp-ext_wjz304
# 容错
rm -f rp-ext_wjz304/asix/releases/ds3617xs_42218.json
rm -f rp-ext_wjz304/ax88179_178a/releases/ds3617xs_42218.json
rm -f rp-ext_wjz304/dm9601/releases/ds3617xs_42218.json
rm -f rp-ext_wjz304/nct6775/releases/dva3221_42218.json
rm -f rp-ext_wjz304/sfc/releases/ds918p_25556.json
rm -f rp-ext_wjz304/v9fs/releases/ds918p_42218.json
- name: Get exts lsit
uses: jannekem/run-python-script-action@v1.2
with:
script: |
# -*- coding: utf-8 -*-
import os, json, hashlib
root = '' # os.path.dirname(os.path.abspath(__file__))
def getjsonfile(file):
data = None
if os.path.isfile(file):
try:
with open(file, 'r') as f:
data = json.load(f)
except Exception as err:
print(err)
return data
def sha256sum(file):
sha256 = ''
if os.path.isfile(file):
with open(file, "rb") as f:
sha256=hashlib.sha256(f.read()).hexdigest()
return sha256
def pathstrsub(exp, reglist=[]):
ret = exp
try:
for re in reglist:
ret = ret.replace(re[0], re[1])
except Exception as err:
print(err)
return ret
def getextslist(work = 'rp-ext', reglist=[]):
exts = {}
try:
jext = 'rpext-index.json'
extdirs = os.listdir(os.path.join(root, work))
extdirs.sort()
print(extdirs)
for extdir in extdirs:
if extdir.startswith('.') or extdir.startswith('redpill'):
continue
if os.path.isdir(os.path.join(root, work, extdir)):
data_index = getjsonfile(os.path.join(root, work, extdir, jext))
if data_index != None:
try:
keys = data_index["releases"].keys()
for key in keys:
suffix = ''
data_releases = getjsonfile(os.path.join(root, work, pathstrsub(data_index["releases"][key], reglist)))
if data_releases != None:
if "files" in data_releases:
for file in data_releases["files"]:
sha256_online = file["sha256"]
sha256_local = sha256sum(os.path.join(root, work, pathstrsub( file["url"], reglist)))
if sha256_online != sha256_local:
suffix = '#'
print('file: {} -- key: {} -- error: {} -- really: {}'.format(pathstrsub(data_index["releases"][key], reglist), pathstrsub(file["url"], reglist), sha256_online, sha256_local))
else:
suffix = '*'
print('file: {} -- may not exists'.format(pathstrsub(data_index["releases"][key], reglist)))
if key in exts.keys():
exts[key][extdir + suffix] = data_index["info"]["description"]
else:
exts[key] = { extdir + suffix: data_index["info"]["description"]}
except Exception as err:
print(err)
except Exception as err:
print(err)
return exts
if __name__ == '__main__':
exts = {}
print('####################### pocopico #######################')
exts["pocopico"] = getextslist('rp-ext_pocopico', [['https://raw.githubusercontent.com/pocopico/rp-ext/master/',''], ['https://github.com/pocopico/rp-ext/raw/main/',''], ['https://github.com/pocopico/rp-ext/blob/main/','']])
print('####################### wjz304 #######################')
exts["wjz304"] = getextslist('rp-ext_wjz304', [['https://raw.githubusercontent.com/wjz304/rp-ext/master/','']])
if len(exts) > 0:
print('####################### exts #######################')
print(json.dumps(exts, indent=4))
with open(os.path.join(root, 'exts.json'), 'w', encoding='utf-8') as f:
f.write(json.dumps(exts, indent=4))
- name: Check and Push
run: |
if [ -n "$(git status -s | grep exts.json)" ]; then
git add exts.json
git commit -m "update $(date +%Y-%m-%d" "%H:%M:%S)"
git push -f
fi
- name: Checkout redpill-load s
run: |
sudo rm -rf redpill-load_pocopico_develop
git clone --branch develop https://github.com/pocopico/redpill-load.git redpill-load_pocopico_develop
# https://github.com/pocopico/rp-ext/blob/main/redpill/rpext-index.json 并不包含 DS3617xs/6.2.4-25556, 线上无法获取
rm -rf redpill-load_pocopico_develop/config/DS3617xs/6.2.4-25556
sudo rm -rf redpill-load_pocopico_jun
git clone --branch jun https://github.com/pocopico/redpill-load.git redpill-load_pocopico_jun
# https://github.com/pocopico/rp-ext/blob/main/redpill/rpext-index.json 并不包含 DS3617xs/6.2.4-25556, 线上无法获取
rm -rf redpill-load_pocopico_jun/config/DS3617xs/6.2.4-25556
sudo rm -rf redpill-load_jumkey_develop
git clone --branch develop https://github.com/jumkey/redpill-load.git redpill-load_jumkey_develop
- name: Get loads lsit
uses: jannekem/run-python-script-action@v1.2
with:
script: |
# -*- coding: utf-8 -*-
import os, json
root = '' # os.path.dirname(os.path.abspath(__file__))
def getloadlist(work = 'redpill-load'):
load = {}
try:
platforms = os.listdir(os.path.join(root, work, 'config'))
platforms.sort()
print(platforms)
for platform in platforms:
if platform.startswith('.') or platform.startswith('_'):
continue
load[platform] = []
if os.path.isdir(os.path.join(root, work, 'config', platform)):
versions = os.listdir(os.path.join(root, work, 'config', platform))
versions.sort()
print(versions)
for version in versions:
if os.path.exists(os.path.join(root, work, 'config', platform, version, 'config.json')):
load[platform].append(version)
except Exception as err:
print(err)
return load
if __name__ == '__main__':
loads = {}
print('################### pocopico develop ###################')
loads["pocopico_develop"] = getloadlist('redpill-load_pocopico_develop')
print('##################### pocopico jun #####################')
loads["pocopico_jun"] = getloadlist('redpill-load_pocopico_jun')
print('#################### jumkey develop ####################')
loads["jumkey_develop"] = getloadlist('redpill-load_jumkey_develop')
if len(loads) > 0:
print('####################### loads #######################')
print(json.dumps(loads, indent=4))
with open(os.path.join(root, 'loads.json'), 'w', encoding='utf-8') as f:
f.write(json.dumps(loads, indent=4))
- name: Check and Push
run: |
if [ -n "$(git status -s | grep loads.json)" ]; then
git add loads.json
git commit -m "update $(date +%Y-%m-%d" "%H:%M:%S)"
git push -f
fi