module-packer/pack.sh

44 lines
970 B
Bash
Raw Normal View History

2022-04-30 13:21:08 +00:00
#!/bin/bash
2022-05-01 12:41:22 +00:00
if [ ! -f .env ]
then
echo "Config not found"
exit
fi
2022-04-30 13:21:08 +00:00
2022-05-01 12:41:22 +00:00
source .env
2022-04-30 13:21:08 +00:00
rm -rf ./src
cp -r "${mod_path}" "./src"
# TODO: implement .modignore processing from current dir and from src
md5=`find ./src -type f -exec md5sum {} + | awk '{print $1}' | sort | md5sum | awk '{ print $1 }'`
if [ -f "src/module.json" ]
then
mod_name=`cat src/module.json | jq ".name" -r`
mod_version=`cat src/module.json | jq ".version" -r`
2022-05-01 11:56:01 +00:00
mod_title=`cat src/module.json | jq ".title" -r`
2022-04-30 13:21:08 +00:00
else
echo "Moduleinfo read failed"
exit 9
fi
echo "{
\"name\":\"${mod_name}\",
\"version\":\"${mod_version}\",
2022-05-01 11:56:01 +00:00
\"title\":\"${mod_title}\",
2022-05-02 21:25:03 +00:00
\"hash\":\"${md5}\"
}" > src/module.json
2022-04-30 13:21:08 +00:00
zip_name="mod_$mod_name-v$mod_version.zip"
rm -f mod_*.zip
cd src
zip -r ../$zip_name .
2022-05-02 21:25:03 +00:00
cd -
rm -rf src
2022-04-30 13:21:08 +00:00
2022-05-02 21:25:03 +00:00
curl --user ${REG_LOGIN}:${REG_PASSWORD} \
--upload-file ${zip_name} \
https://mxfox.ru/api/packages/${REG_REPOS}/generic/${mod_name}/${mod_version}/${mod_name}.zip
2022-04-30 13:21:08 +00:00