Created
January 20, 2021 16:45
-
-
Save Ajetski/fa6b7ca71db0eaad6f29f6531ad08c75 to your computer and use it in GitHub Desktop.
A deploy script for https://github.com/Booshmagoosh/RecursiveDescentParser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "getting data..." | |
sed -r ' | |
s/"/\\"/g | |
s/\\n/\\\\n/g | |
s/^#include.*\.h.*$//g | |
s/^#include.*\.cpp.*$//g | |
s/\t/ /g | |
' src/RecursiveDescent.cpp > RecursiveDescentCPP.template | |
sed -ri ' | |
:a | |
N | |
$!ba | |
s/\n/\\n/g | |
' RecursiveDescentCPP.template | |
SRC=`cat RecursiveDescentCPP.template` | |
rm -f RecursiveDescentCPP.template | |
sed -r ' | |
s/"/\\"/g | |
s/\\n/\\\\n/g | |
s/^#include.*\.h.*$//g | |
s/^#include.*\.cpp.*$//g | |
s/\t/ /g | |
' src/Value.h > ValueH.template | |
cat ValueH.template | |
sed -ri ' | |
:a | |
N | |
$!ba | |
s/\n/\\n/g | |
' ValueH.template | |
VALUE=`cat ValueH.template` | |
rm -f ValueH.template | |
sed -r ' | |
s/"/\\"/g | |
s/\\n/\\\\n/g | |
s/^#include.*\.h.*$//g | |
s/^#include.*\.cpp.*$//g | |
s/\t/ /g | |
' src/Type.h > TypeH.template | |
sed -ri ' | |
:a | |
N | |
$!ba | |
s/\n/\\n/g | |
' TypeH.template | |
TYPE=`cat TypeH.template` | |
TYPE="$TYPE" | |
rm -f TypeH.template | |
STDIN=`sed -r ' | |
:a | |
N | |
$!ba | |
s/\n/\\\\n/g | |
' stdin.template` | |
echo "uploading data..." | |
RES=`curl --header "Content-Type: application/json" \ | |
--request POST \ | |
--data "{ | |
\"sessions\": [ | |
{ | |
\"id\": 1, | |
\"language\": \"c++\", | |
\"source\": \"$TYPE\\n\\n$VALUE\\n\\n$SRC\", | |
\"compilers\": [], | |
\"executors\": [ | |
{ | |
\"arguments\": \"\", | |
\"compiler\": { | |
\"id\": \"g102\", | |
\"libs\": [], | |
\"options\": \"-std=c++17 -Wall -Wextra\" | |
}, | |
\"stdin\": \"$STDIN\" | |
} | |
] | |
} | |
] | |
}" \ | |
https://godbolt.org/shortener` | |
URL=`echo $RES | sed -r ' | |
s/^.*(https:\/\/godbolt.org\/z\/.*)".*$/\1/ | |
'` | |
echo "response: $URL" | |
URL=`echo $URL | sed ' | |
s/\//\\\\\//g | |
'` | |
echo "writing response to README.md" | |
sed -r " | |
s/<!--LINK HERE-->/$URL/g | |
" README.template > README.md | |
echo "committing changes to readme" | |
git add README.md | |
git commit -m "update link in readme" | |
echo "pushing changes" | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment