New update method
manage testing deplyement
This commit is contained in:
parent
5768f20053
commit
ccbde28ef9
30
.drone.yml
30
.drone.yml
@ -21,6 +21,14 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- rm -rf .git*
|
- rm -rf .git*
|
||||||
- rm -rf web
|
- rm -rf web
|
||||||
|
- echo '#### REPLACE TARGET ####'
|
||||||
|
- sed -i 's/target_version = git/target_version = testing/' configuration.default.ini
|
||||||
|
- echo '#### REPLACE VERSION ####'
|
||||||
|
- version=$(git rev-parse HEAD)
|
||||||
|
- echo "current git commit is $version"
|
||||||
|
- echo $version > /tmp/botamusique/testing-version
|
||||||
|
- sed -i "s/version = 'git'/version = '$version'/" mumbleBot.py
|
||||||
|
- echo '#### DEPLOY SOURCES ####'
|
||||||
- tar -czf /tmp/botamusique/sources-testing.tar.gz .
|
- tar -czf /tmp/botamusique/sources-testing.tar.gz .
|
||||||
volumes:
|
volumes:
|
||||||
- name: repo
|
- name: repo
|
||||||
@ -46,12 +54,34 @@ steps:
|
|||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
|
|
||||||
|
- name: fetch
|
||||||
|
image: alpine/git
|
||||||
|
commands:
|
||||||
|
- git fetch --tags
|
||||||
|
when:
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
event:
|
||||||
|
- tag
|
||||||
|
|
||||||
- name: deploy-stable
|
- name: deploy-stable
|
||||||
image: debian
|
image: debian
|
||||||
commands:
|
commands:
|
||||||
|
- apt -qq update && apt -q -y install jq curl
|
||||||
- rm -rf .git*
|
- rm -rf .git*
|
||||||
- rm -rf web
|
- rm -rf web
|
||||||
|
- echo '#### REPLACE TARGET ####'
|
||||||
|
- sed -i 's/target_version = git/target_version = stable/' configuration.default.ini
|
||||||
|
- echo '#### REPLACE VERSION ####'
|
||||||
|
- version=$(git describe --abbrev=0 --tags)
|
||||||
|
- echo "version is $version"
|
||||||
|
- echo $version > /tmp/botamusique/version
|
||||||
|
- sed -i "s/version = 'git'/version = '$version'/" mumbleBot.py
|
||||||
|
- echo '#### REPLACE CHANGELOG ####'
|
||||||
|
- curl --silent "https://api.github.com/repos/azlux/botamusique/releases/latest") | jq -r '.body' > /tmp/botamusique/changelog
|
||||||
|
- echo '#### DEPLOY SOURCES ####'
|
||||||
- tar -czf /tmp/botamusique/sources-stable.tar.gz .
|
- tar -czf /tmp/botamusique/sources-stable.tar.gz .
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: repo
|
- name: repo
|
||||||
path: /tmp/botamusique/
|
path: /tmp/botamusique/
|
||||||
|
@ -37,8 +37,8 @@ playback_mode = one-shot
|
|||||||
autoplay_length = 5
|
autoplay_length = 5
|
||||||
clear_when_stop_in_oneshot = False
|
clear_when_stop_in_oneshot = False
|
||||||
|
|
||||||
# target version, stable or testing (testing need to bot installed with git)
|
# target version, stable/testing/git (git need to bot installed with git)
|
||||||
target_version = stable
|
target_version = git
|
||||||
|
|
||||||
# Users allowed to kill the bot, or ban URLs.
|
# Users allowed to kill the bot, or ban URLs.
|
||||||
admin = User1;User2;
|
admin = User1;User2;
|
||||||
|
@ -32,7 +32,7 @@ from media.cache import MusicCache
|
|||||||
|
|
||||||
|
|
||||||
class MumbleBot:
|
class MumbleBot:
|
||||||
version = '6.5'
|
version = 'git'
|
||||||
|
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
self.log = logging.getLogger("bot")
|
self.log = logging.getLogger("bot")
|
||||||
|
@ -9,8 +9,11 @@ case "$1" in
|
|||||||
rm -r /tmp/botamusique.tar.gz
|
rm -r /tmp/botamusique.tar.gz
|
||||||
;;
|
;;
|
||||||
testing)
|
testing)
|
||||||
git fetch
|
curl -Lo /tmp/botamusique.tar.gz https://packages.azlux.fr/botamusique/sources-testing.tar.gz
|
||||||
git pull --all
|
tar -xzf /tmp/botamusique.tar.gz -C /tmp/
|
||||||
|
cp -r /tmp/botamusique/* .
|
||||||
|
rm -r /tmp/botamusique
|
||||||
|
rm -r /tmp/botamusique.tar.gz
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
|
37
util.py
37
util.py
@ -100,8 +100,11 @@ def get_user_ban():
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
def new_release_version():
|
def new_release_version(target):
|
||||||
r = requests.get("https://packages.azlux.fr/botamusique/version")
|
if target == "testing":
|
||||||
|
r = requests.get("https://packages.azlux.fr/botamusique/testing-version")
|
||||||
|
else:
|
||||||
|
r = requests.get("https://packages.azlux.fr/botamusique/version")
|
||||||
v = r.text
|
v = r.text
|
||||||
return v.rstrip()
|
return v.rstrip()
|
||||||
|
|
||||||
@ -115,26 +118,28 @@ def fetch_changelog():
|
|||||||
def update(current_version):
|
def update(current_version):
|
||||||
global log
|
global log
|
||||||
|
|
||||||
new_version = new_release_version()
|
|
||||||
target = var.config.get('bot', 'target_version')
|
target = var.config.get('bot', 'target_version')
|
||||||
if version.parse(new_version) > version.parse(current_version) or target == "testing":
|
new_version = new_release_version(target)
|
||||||
|
msg = ""
|
||||||
|
if target == "git":
|
||||||
|
msg = "git install, I do nothing"
|
||||||
|
|
||||||
|
elif (target == "stable" and version.parse(new_version) > version.parse(current_version)) or \
|
||||||
|
(target == "testing" and version.parse(new_version) != version.parse(current_version)):
|
||||||
log.info('update: new version, start updating...')
|
log.info('update: new version, start updating...')
|
||||||
tp = sp.check_output(['/usr/bin/env', 'bash', 'update.sh', target]).decode()
|
tp = sp.check_output(['/usr/bin/env', 'bash', 'update.sh', target]).decode()
|
||||||
log.debug(tp)
|
log.debug(tp)
|
||||||
log.info('update: update pip libraries dependencies')
|
log.info('update: update pip libraries dependencies')
|
||||||
sp.check_output([var.config.get('bot', 'pip3_path'), 'install', '--upgrade', '-r', 'requirements.txt']).decode()
|
sp.check_output([var.config.get('bot', 'pip3_path'), 'install', '--upgrade', '-r', 'requirements.txt']).decode()
|
||||||
msg = "New version installed, please restart the bot."
|
msg = "New version installed, please restart the bot."
|
||||||
if target == "testing":
|
|
||||||
msg += tp.replace('\n', '<br/>')
|
|
||||||
|
|
||||||
|
log.info('update: starting update youtube-dl via pip3')
|
||||||
|
tp = sp.check_output([var.config.get('bot', 'pip3_path'), 'install', '--upgrade', 'youtube-dl']).decode()
|
||||||
|
if "Requirement already up-to-date" in tp:
|
||||||
|
msg += "Youtube-dl is up-to-date"
|
||||||
else:
|
else:
|
||||||
log.info('update: starting update youtube-dl via pip3')
|
msg += "Update done: " + tp.split('Successfully installed')[1]
|
||||||
tp = sp.check_output([var.config.get('bot', 'pip3_path'), 'install', '--upgrade', 'youtube-dl']).decode()
|
|
||||||
msg = ""
|
|
||||||
if "Requirement already up-to-date" in tp:
|
|
||||||
msg += "Youtube-dl is up-to-date"
|
|
||||||
else:
|
|
||||||
msg += "Update done: " + tp.split('Successfully installed')[1]
|
|
||||||
reload(youtube_dl)
|
reload(youtube_dl)
|
||||||
msg += "<br/> Youtube-dl reloaded"
|
msg += "<br/> Youtube-dl reloaded"
|
||||||
return msg
|
return msg
|
||||||
@ -374,8 +379,8 @@ def parse_time(human):
|
|||||||
|
|
||||||
|
|
||||||
def parse_file_size(human):
|
def parse_file_size(human):
|
||||||
units = {"B": 1, "KB": 1024, "MB": 1024*1024, "GB": 1024*1024*1024, "TB": 1024*1024*1024*1024,
|
units = {"B": 1, "KB": 1024, "MB": 1024 * 1024, "GB": 1024 * 1024 * 1024, "TB": 1024 * 1024 * 1024 * 1024,
|
||||||
"K": 1024, "M": 1024*1024, "G": 1024*1024*1024, "T": 1024*1024*1024*1024}
|
"K": 1024, "M": 1024 * 1024, "G": 1024 * 1024 * 1024, "T": 1024 * 1024 * 1024 * 1024}
|
||||||
match = re.search("(\d+(?:\.\d*)?)\s*([A-Za-z]+)", human, flags=re.IGNORECASE)
|
match = re.search("(\d+(?:\.\d*)?)\s*([A-Za-z]+)", human, flags=re.IGNORECASE)
|
||||||
if match:
|
if match:
|
||||||
num = float(match[1])
|
num = float(match[1])
|
||||||
@ -417,7 +422,7 @@ class LoggerIOWrapper(io.TextIOWrapper):
|
|||||||
|
|
||||||
|
|
||||||
class VolumeHelper:
|
class VolumeHelper:
|
||||||
def __init__(self, plain_volume = 0, ducking_plain_volume = 0):
|
def __init__(self, plain_volume=0, ducking_plain_volume=0):
|
||||||
self.plain_volume_set = 0
|
self.plain_volume_set = 0
|
||||||
self.plain_ducking_volume_set = 0
|
self.plain_ducking_volume_set = 0
|
||||||
self.volume_set = 0
|
self.volume_set = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user