diff --git a/.drone.yml b/.drone.yml
index e1cac50..82c5616 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -21,6 +21,14 @@ steps:
commands:
- rm -rf .git*
- 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 .
volumes:
- name: repo
@@ -46,12 +54,34 @@ steps:
event:
- push
+ - name: fetch
+ image: alpine/git
+ commands:
+ - git fetch --tags
+ when:
+ branch:
+ - master
+ event:
+ - tag
+
- name: deploy-stable
image: debian
commands:
+ - apt -qq update && apt -q -y install jq curl
- rm -rf .git*
- 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 .
+
volumes:
- name: repo
path: /tmp/botamusique/
diff --git a/configuration.default.ini b/configuration.default.ini
index 90a0611..cc58945 100644
--- a/configuration.default.ini
+++ b/configuration.default.ini
@@ -37,8 +37,8 @@ playback_mode = one-shot
autoplay_length = 5
clear_when_stop_in_oneshot = False
-# target version, stable or testing (testing need to bot installed with git)
-target_version = stable
+# target version, stable/testing/git (git need to bot installed with git)
+target_version = git
# Users allowed to kill the bot, or ban URLs.
admin = User1;User2;
diff --git a/mumbleBot.py b/mumbleBot.py
index be25154..65ba182 100644
--- a/mumbleBot.py
+++ b/mumbleBot.py
@@ -32,7 +32,7 @@ from media.cache import MusicCache
class MumbleBot:
- version = '6.5'
+ version = 'git'
def __init__(self, args):
self.log = logging.getLogger("bot")
diff --git a/update.sh b/update.sh
index b4aa1c8..f8f934a 100644
--- a/update.sh
+++ b/update.sh
@@ -9,8 +9,11 @@ case "$1" in
rm -r /tmp/botamusique.tar.gz
;;
testing)
- git fetch
- git pull --all
+ curl -Lo /tmp/botamusique.tar.gz https://packages.azlux.fr/botamusique/sources-testing.tar.gz
+ tar -xzf /tmp/botamusique.tar.gz -C /tmp/
+ cp -r /tmp/botamusique/* .
+ rm -r /tmp/botamusique
+ rm -r /tmp/botamusique.tar.gz
;;
*)
;;
diff --git a/util.py b/util.py
index 3b9359a..647ec4d 100644
--- a/util.py
+++ b/util.py
@@ -100,8 +100,11 @@ def get_user_ban():
return res
-def new_release_version():
- r = requests.get("https://packages.azlux.fr/botamusique/version")
+def new_release_version(target):
+ 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
return v.rstrip()
@@ -115,26 +118,28 @@ def fetch_changelog():
def update(current_version):
global log
- new_version = new_release_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...')
tp = sp.check_output(['/usr/bin/env', 'bash', 'update.sh', target]).decode()
log.debug(tp)
log.info('update: update pip libraries dependencies')
sp.check_output([var.config.get('bot', 'pip3_path'), 'install', '--upgrade', '-r', 'requirements.txt']).decode()
msg = "New version installed, please restart the bot."
- if target == "testing":
- msg += tp.replace('\n', '
')
+ 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:
- log.info('update: starting update youtube-dl via pip3')
- 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]
+ msg += "Update done: " + tp.split('Successfully installed')[1]
+
reload(youtube_dl)
msg += "
Youtube-dl reloaded"
return msg
@@ -374,8 +379,8 @@ def parse_time(human):
def parse_file_size(human):
- 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}
+ 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}
match = re.search("(\d+(?:\.\d*)?)\s*([A-Za-z]+)", human, flags=re.IGNORECASE)
if match:
num = float(match[1])
@@ -417,7 +422,7 @@ class LoggerIOWrapper(io.TextIOWrapper):
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_ducking_volume_set = 0
self.volume_set = 0