mirror of
https://github.com/CopterExpress/clover.git
synced 2026-05-26 21:19:35 +00:00
image_builder: remove yadisk uploader
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
#
|
||||
# Script for upload the image to yadisk & change the release message on GitHub
|
||||
# Copyright (C) 2018 Copter Express Technologies
|
||||
#
|
||||
# Author: Artem Smirnov <urpylka@gmail.com>
|
||||
#
|
||||
# Distributed under MIT License (available at https://opensource.org/licenses/MIT).
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
|
||||
set -e # Exit immidiately on non-zero result
|
||||
|
||||
publish_image() {
|
||||
# TEMPLATE: publish_image_bash <IMAGE_PATH> <YA_SCRIPT> <CONFIG_FILE> <RELEASE_ID> <RELEASE_BODY>
|
||||
|
||||
# https://developer.github.com/v3/repos/releases/
|
||||
|
||||
IMAGE_NAME=$(basename $1)
|
||||
BUILD_DIR=$(dirname $1)
|
||||
|
||||
echo -e "Zip image"
|
||||
if [ ! -e "${BUILD_DIR}/${IMAGE_NAME}.zip" ]; then
|
||||
cd ${BUILD_DIR} && zip ${IMAGE_NAME}.zip ${IMAGE_NAME}
|
||||
echo -e "Zipping complete!" "SUCCESS"
|
||||
else
|
||||
echo -e "Zip-archive already created"
|
||||
cd ${BUILD_DIR} && rm ${IMAGE_NAME}.zip && zip ${IMAGE_NAME}.zip ${IMAGE_NAME} \
|
||||
&& echo -e "Old archive was deleted & create new" "SUCCESS"
|
||||
fi
|
||||
|
||||
echo -e "Upload image"
|
||||
local IMAGE_LINK=$($2 $3 ${BUILD_DIR}/${IMAGE_NAME}.zip) \
|
||||
&& echo -e "Upload copmlete!" "SUCCESS"
|
||||
|
||||
echo -e "Meashure size of zip-image"
|
||||
local IMAGE_SIZE=$(du -sh ${BUILD_DIR}/${IMAGE_NAME}.zip | awk '{ print $1 }') \
|
||||
&& echo -e "Meashuring copmlete!" "SUCCESS"
|
||||
|
||||
echo -e "Meashure hash-sum of zip-image"
|
||||
local IMAGE_HASH=$(sha256sum ${BUILD_DIR}/${IMAGE_NAME}.zip | awk '{ print $1 }') \
|
||||
&& echo -e "Meashuring copmlete!" "SUCCESS"
|
||||
|
||||
echo ""
|
||||
echo "\$5: $5"
|
||||
echo ""
|
||||
|
||||
echo -e "Post message to GH"
|
||||
local NEW_RELEASE_BODY="### Download\n* [${IMAGE_NAME}.zip](${IMAGE_LINK}) (${IMAGE_SIZE})\nsha256: ${IMAGE_HASH}\n\n$5"
|
||||
local DATA="{ \"body\":\"${NEW_RELEASE_BODY}\" }"
|
||||
|
||||
echo ""
|
||||
echo "\$DATA: $DATA"
|
||||
echo ""
|
||||
|
||||
local GH_LOGIN=$(cat $3 | jq '.github.login' -r)
|
||||
local GH_PASS=$(cat $3 | jq '.github.password' -r)
|
||||
local GH_URL=$(cat $3 | jq '.github.url' -r)
|
||||
curl -d "$DATA" -u "${GH_LOGIN}:${GH_PASS}" --request PATCH ${GH_URL}$4 \
|
||||
&& echo -e "Post message to GH copmlete!" "SUCCESS"
|
||||
}
|
||||
|
||||
publish_image $1 $2 $3 $4 "$5"
|
||||
@@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# The simple python uploader to YaDisk
|
||||
# Use: python yadisk.py login password file server_dir
|
||||
#
|
||||
# Copyright (C) 2018 Copter Express Technologies
|
||||
#
|
||||
# Author: Artem Smirnov <urpylka@gmail.com>
|
||||
#
|
||||
# Distributed under MIT License (available at https://opensource.org/licenses/MIT).
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
|
||||
from YaDiskClient.YaDiskClient import YaDisk
|
||||
import os.path, sys, json
|
||||
|
||||
def upload(_login, _password, _server_dir, _file):
|
||||
if os.path.isfile(_file):
|
||||
disk = YaDisk(_login, _password)
|
||||
disk.upload(_file, _server_dir + '/' + os.path.basename(_file))
|
||||
link = disk.publish_doc(_server_dir + '/' + os.path.basename(_file))
|
||||
print link
|
||||
else:
|
||||
print "Error: file-path is bad"
|
||||
return 1
|
||||
|
||||
def main():
|
||||
if (len(sys.argv) == 5):
|
||||
print "login: " + sys.argv[1]
|
||||
print "password: " + sys.argv[2]
|
||||
print "server_dir: " + sys.argv[3]
|
||||
print "file: " + sys.argv[4]
|
||||
|
||||
upload(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
|
||||
|
||||
elif (len(sys.argv) == 3):
|
||||
# print "config: " + sys.argv[1]
|
||||
# print "file: " + sys.argv[2]
|
||||
|
||||
if os.path.isfile(sys.argv[1]) and os.path.isfile(sys.argv[2]):
|
||||
|
||||
with open(sys.argv[1]) as json_data:
|
||||
d = json.load(json_data)
|
||||
upload(d['yadisk']['login'], d['yadisk']['password'], d['yadisk']['server_dir'], sys.argv[2])
|
||||
|
||||
else:
|
||||
print "Error: file-path or config-path is bad"
|
||||
return 1
|
||||
else:
|
||||
print "Error: amount of args is incorrect"
|
||||
return 1
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user