module-packer/pack.sh

41 lines
1.0 KiB
Bash
Raw Normal View History

2022-04-30 13:21:08 +00:00
#!/bin/bash
2022-05-02 21:46:42 +00:00
if [ -f ".env" ]
2022-05-01 12:41:22 +00:00
then
2022-05-02 21:46:42 +00:00
source .env
2022-05-01 12:41:22 +00:00
fi
2022-04-30 13:21:08 +00:00
# TODO: implement .modignore processing from current dir and from src
2022-05-02 21:46:42 +00:00
rm -rf .git
2022-04-30 13:21:08 +00:00
2022-05-02 21:46:42 +00:00
md5=`find . -type f -exec md5sum {} + | awk '{print $1}' | sort | md5sum | awk '{ print $1 }'`
2022-04-30 13:21:08 +00:00
2022-05-02 21:46:42 +00:00
if [ -f "module.json" ]
2022-04-30 13:21:08 +00:00
then
2022-05-02 21:46:42 +00:00
mod_name=`cat module.json | jq ".name" -r`
mod_version=`cat module.json | jq ".version" -r`
mod_title=`cat module.json | jq ".title" -r`
2022-04-30 13:21:08 +00:00
else
echo "Moduleinfo read failed"
exit 9
fi
2022-08-02 17:35:29 +00:00
mod_build=${CI_COMMIT_BRANCH}-${CI_BUILD_NUMBER}-${DRONE_COMMIT_SHA:0:10}
2022-04-30 13:21:08 +00:00
echo "{
\"name\":\"${mod_name}\",
\"version\":\"${mod_version}\",
2022-08-02 17:35:29 +00:00
\"build\":\"${mod_build}\",
2022-05-01 11:56:01 +00:00
\"title\":\"${mod_title}\",
2022-05-02 21:25:03 +00:00
\"hash\":\"${md5}\"
2022-05-02 21:46:42 +00:00
}" > module.json
2022-04-30 13:21:08 +00:00
zip_name="mod_$mod_name-v$mod_version.zip"
rm -f mod_*.zip
2022-05-02 21:46:42 +00:00
zip -r /tmp/$zip_name .
2022-04-30 13:21:08 +00:00
2022-05-02 21:25:03 +00:00
curl --user ${REG_LOGIN}:${REG_PASSWORD} \
2022-05-02 21:46:42 +00:00
--upload-file /tmp/${zip_name} \
2022-05-19 12:23:47 +00:00
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
2022-04-30 13:21:08 +00:00