All checks were successful
continuous-integration/drone/push Build is passing
64 lines
2.2 KiB
Bash
64 lines
2.2 KiB
Bash
#!/bin/sh
|
|
|
|
set -euo pipefail
|
|
git fetch --tags
|
|
|
|
CURRENTTAG=$(git tag --sort=-taggerdate | head -n 1)
|
|
PREVIOUSTAG=$(git tag --sort=-taggerdate | head -n 2 | tail -n 1)
|
|
ALLCHANGES=$(npx -y @philippdormann/changelogen@latest --from $PREVIOUSTAG --to $CURRENTTAG --no-output | sed 's/"/\\"/g' | tail -n +6)
|
|
FORMATTED_CHANGES=$(echo "# $CURRENTTAG \n $ALLCHANGES" | pandoc -f markdown -t html | sed 's/"/'"'"'/g' | xargs echo -n)
|
|
|
|
|
|
if [ "${PLUGIN_GITEA_DOMAIN:+set}" = set ]; then
|
|
if [ "${PLUGIN_GITEA_APIKEY:-null}" = null ]; then
|
|
echo "No api key provided";
|
|
exit 1;
|
|
fi
|
|
if [ "${PLUGIN_REPO:-null}" = null ]; then
|
|
PLUGIN_REPO=$CI_REPO_NAME
|
|
fi
|
|
|
|
curl --request POST \
|
|
--url "https://$PLUGIN_GITEA_DOMAIN/api/v1/repos/$PLUGIN_REPO/releases" \
|
|
--header "Content-Type: application/json" \
|
|
--header "Authorization: token $PLUGIN_GITEA_APIKEY" \
|
|
--data "{
|
|
\"name\": \"$CURRENTTAG\",
|
|
\"body\": \"$ALLCHANGES\",
|
|
\"draft\": false,
|
|
\"tag_name\": \"$CURRENTTAG\"
|
|
}"
|
|
fi
|
|
if [ "${PLUGIN_MATRIX_SERVER:+set}" = set ]; then
|
|
if [ "${PLUGIN_MATRIX_USER:-null}" = null ]; then
|
|
echo "No matrix username provided";
|
|
exit 3;
|
|
fi
|
|
if [ "${PLUGIN_REPO:-null}" = null ]; then
|
|
echo "No matrix password provided";
|
|
exit 4;
|
|
fi
|
|
if [ "${PLUGIN_MATRIX_ROOM:-null}" = null ]; then
|
|
echo "No matrix room id provided";
|
|
exit 4;
|
|
fi
|
|
|
|
MATRIX_LOGIN=$(curl --request POST \
|
|
--url "https://$PLUGIN_MATRIX_SERVER/_matrix/client/r0/login" \
|
|
--header "Content-Type: application/json" \
|
|
--data "{
|
|
\"type\": \"m.login.password\",
|
|
\"user\": \"$PLUGIN_MATRIX_USER\",
|
|
\"password\": \"$PLUGIN_MATRIX_PASSWORD\"
|
|
}")
|
|
MATRIX_TOKEN=$(echo $MATRIX_LOGIN | jq .access_token | sed 's/"//g' )
|
|
curl --request POST \
|
|
--url "https://$PLUGIN_MATRIX_SERVER/_matrix/client/r0/rooms/$PLUGIN_MATRIX_ROOM/send/m.room.message?access_token=$MATRIX_TOKEN" \
|
|
--header "Content-Type: application/json" \
|
|
--data "{
|
|
\"msgtype\": \"m.text\",
|
|
\"body\": \"$(echo "# $CURRENTTAG \n $ALLCHANGES" | xargs echo -n)\",
|
|
\"format\": \"org.matrix.custom.html\",
|
|
\"formatted_body\": \"$FORMATTED_CHANGES\"
|
|
}"
|
|
fi |