2022-08-18 09:59:48 +00:00
# version format
version : '{build}'
deploy : on
# branches to build
branches :
# whitelist
only :
- master
# Do not build on tags (GitHub, Bitbucket, GitLab, Gitea)
skip_tags : true
# Maximum number of concurrent jobs for the project
max_jobs : 1
clone_depth : 1
# Build worker image (VM template)
build_cloud : Docker
environment :
docker_image : node:16-alpine
npm_config_cache : /appveyor/projects/cache
build_script :
- sh : |
chown -R node:node /appveyor/projects
chmod -R 777 /appveyor/projects
apk add curl jq
2022-08-18 11:24:32 +00:00
if [ $? -ne 0 ]; then
2022-08-18 09:59:48 +00:00
exit 1
fi
2022-08-18 11:24:32 +00:00
echo "Finished installling curl and jq"
2022-08-18 09:59:48 +00:00
2022-08-18 10:09:17 +00:00
SUCCESS=1
2022-10-17 14:16:57 +00:00
echo ""
echo "------------------------------------"
echo ""
2022-08-18 10:09:17 +00:00
2022-08-18 09:59:48 +00:00
for f in *; do
[ ! -d "$f" ] || [ -L "$f" ] || [ "$f" = "base" ] && continue;
echo "checking $f";
cd $f
CURR_VER="$(cat package.json | jq -r .name)_v$(cat package.json | jq -r .version)"
CURR_NAME="$(cat package.json | jq -r .name) v$(cat package.json | jq -r .version)"
2022-08-18 10:31:16 +00:00
MAN_PORT=$(cat package.json | jq -r .port)
MAN_NAME=$(cat package.json | jq -r .name)
2022-08-18 09:59:48 +00:00
echo "Checking https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases for name ${CURR_NAME}"
curl -s -X GET -H "Authorization: token $deploytoken" https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases | grep -o "\"name\"\:\"${CURR_NAME}\"" > /dev/null
if [ $? -eq 0 ] ; then
echo "Skipping $f since $CURR_NAME already exists";
2022-08-18 11:24:32 +00:00
continue;
2022-08-18 09:59:48 +00:00
fi
2022-08-18 11:24:32 +00:00
rm base
cp -Rf ../base ./base
mv package.json fuck-you-npm-package.json
mv build-package.json package.json
npm install && npm run build
CHECK=$?
if [ $CHECK -ne 0 ]; then
echo "Command failed with error code $CHECK"
SUCCESS=0;
continue;
fi;
mv package.json build-package.json
mv fuck-you-npm-package.json package.json
../7zas a -xr!*.xcf -mx9 "${CURR_VER}_build-sc.7z" package.json index.mjs api base public
echo "Creating release on gitea"
RELEASE_RESULT=$(curl \
-X POST \
-H "Authorization: token $deploytoken" \
-H "Content-Type: application/json" \
https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases \
-d "{\"tag_name\":\"${CURR_VER}\",\"name\":\"${CURR_NAME}\",\"body\":\"Automatic release from Appveyor from ${APPVEYOR_REPO_COMMIT} :\n\n${APPVEYOR_REPO_COMMIT_MESSAGE}\"}")
CHECK=$?
if [ $CHECK -ne 0 ]; then
echo "Command failed with error code $CHECK"
SUCCESS=0;
continue;
fi;
RELEASE_ID=$(echo $RELEASE_RESULT | jq -r .id)
echo "Adding ${CURR_VER}_build-sc.7z to release ${RELEASE_ID}"
curl \
-X POST \
-H "Authorization: token $deploytoken" \
-F "attachment=@${CURR_VER}_build-sc.7z" \
https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases/$RELEASE_ID/assets
CHECK=$?
if [ $CHECK -ne 0 ]; then
echo "Command failed with error code $CHECK"
SUCCESS=0;
continue;
fi;
echo "Deplying to production"
echo "curl -X POST http://192.168.93.50:$MAN_PORT/update/$MAN_NAME"
curl -X POST http://192.168.93.50:$MAN_PORT/update/$MAN_NAME
2022-10-17 14:16:57 +00:00
echo ""
echo "------------------------------------"
echo ""
2022-08-18 10:29:55 +00:00
cd ..
2022-08-18 09:59:48 +00:00
done
2022-08-18 10:10:14 +00:00
if [ $SUCCESS -eq 0 ]; then
2022-08-18 10:23:53 +00:00
echo "One or more jobs failed to build"
2022-08-18 10:09:17 +00:00
exit 1;
fi;
2022-08-18 09:59:48 +00:00
# on build failure
on_failure :
- sh : echo on_failure