module-packer/pack.sh

41 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
if [ -f ".env" ]
then
source .env
fi
# TODO: implement .modignore processing from current dir and from src
rm -rf .git
md5=`find . -type f -exec md5sum {} + | awk '{print $1}' | sort | md5sum | awk '{ print $1 }'`
if [ -f "module.json" ]
then
mod_name=`cat module.json | jq ".name" -r`
mod_version=`cat module.json | jq ".version" -r`
mod_title=`cat module.json | jq ".title" -r`
else
echo "Moduleinfo read failed"
exit 9
fi
mod_build=${CI_COMMIT_BRANCH}-${CI_BUILD_NUMBER}-${DRONE_COMMIT_SHA:0:10}
echo "{
\"name\":\"${mod_name}\",
\"version\":\"${mod_version}\",
\"build\":\"${mod_build}\",
\"title\":\"${mod_title}\",
\"hash\":\"${md5}\"
}" > module.json
zip_name="mod_$mod_name-v$mod_version.zip"
rm -f mod_*.zip
zip -r /tmp/$zip_name .
curl --user ${REG_LOGIN}:${REG_PASSWORD} \
--upload-file /tmp/${zip_name} \
https://mxfox.ru/api/packages/${REG_REPOS}/generic/${mod_name}/${mod_version}-${CI_BUILD_NUMBER}-${DRONE_COMMIT_SHA:0:10}/${mod_name}-${mod_version}-${CI_BUILD_NUMBER}-${DRONE_COMMIT_SHA:0:10}.zip