forked from rakutentech/android-inappmessaging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post-to-discourse.sh
executable file
·63 lines (52 loc) · 1.46 KB
/
post-to-discourse.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -e
if [ -z $DISCOURSE_HOSTNAME ];
then
echo "DISCOURSE_HOSTNAME is not set.";
exit 1;
fi
if [ -z $DISCOURSE_API_KEY ];
then
echo "DISCOURSE_API_KEY is not set.";
exit 1;
fi
if [ -z $DISCOURSE_USERNAME ];
then
echo "DISCOURSE_USERNAME is not set.";
exit 1;
fi
if [ -z $DISCOURSE_CATEGORY_ID ];
then
echo "DISCOURSE_CATEGORY_ID is not set.";
exit 1;
fi
if [ -z "$DISCOURSE_SDK_NAME" ];
then
echo "DISCOURSE_SDK_NAME is not set.";
exit 1;
fi
if [ -n $1 ];
then
release_version_number=$1
release_version_number="${release_version_number:1}"
cd $DISCOURSE_DIR
awk "
/## $release_version_number/{flag=1;next}
/## [0-9]/{flag=0}
flag
" USERGUIDE.md > _releasenotes.md
RELEASE_NOTES=$(cat _releasenotes.md)
curl --location --request POST "https://$DISCOURSE_HOSTNAME/posts.json" \
--header "Content-Type: application/json; charset=utf-8" \
--header "Api-Key: $DISCOURSE_API_KEY" \
--header "Api-Username: $DISCOURSE_USERNAME" \
--data-raw "{
\"category\": $DISCOURSE_CATEGORY_ID,
\"title\": \"$DISCOURSE_SDK_NAME v${release_version_number} released 🚀\",
\"tags\": [\"android\", \"mobile\", \"mobilesdk\", \"release\", \"mag-sdk\"],
\"raw\": \"Hi,\n We are pleased to announce that we have released $DISCOURSE_SDK_NAME SDK v${release_version_number}!\n$RELEASE_NOTES\"
}"
else
echo "version input (format: vX.Y.Z) is missing.";
exit 1;
fi