2019-12-26 22:02:36 +01:00
|
|
|
#!/bin/bash -e
|
2018-02-20 15:49:54 +01:00
|
|
|
|
2019-06-18 12:31:44 +02:00
|
|
|
# Configure
|
2019-06-18 14:31:38 +02:00
|
|
|
PHP_MAJOR_VERSION=$(php -r 'echo PHP_MAJOR_VERSION;')
|
|
|
|
PHP_MINOR_VERSION=$(php -r 'echo PHP_MINOR_VERSION;')
|
2019-09-21 20:43:01 +02:00
|
|
|
|
2021-09-04 18:07:22 +02:00
|
|
|
COMMIT="$(git log -1 --pretty=%H)"
|
2021-03-30 21:23:48 +02:00
|
|
|
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
2021-09-04 18:07:22 +02:00
|
|
|
TAG=$(git tag --points-at $COMMIT)
|
2021-03-30 21:23:48 +02:00
|
|
|
COMMIT_MESSAGE="$(git log -1 --pretty=%B HEAD)"
|
2021-03-30 21:18:38 +02:00
|
|
|
|
2021-09-04 17:22:45 +02:00
|
|
|
[[ "$TAG" == *.9999 ]] && exit 0
|
|
|
|
[[ "$TAG" == *.9998 ]] && exit 0
|
|
|
|
|
2021-09-04 18:07:22 +02:00
|
|
|
[ "$TAG" != "" ] && IS_RELEASE=y || IS_RELEASE=n
|
2019-12-27 14:47:20 +01:00
|
|
|
|
2021-09-04 18:07:22 +02:00
|
|
|
echo "Branch: $BRANCH"
|
|
|
|
echo "Commit: $COMMIT"
|
|
|
|
echo "Latest tag: $TAG"
|
2019-12-27 14:47:20 +01:00
|
|
|
echo "Is release: $IS_RELEASE"
|
2019-06-18 14:31:38 +02:00
|
|
|
|
2021-04-05 22:54:08 +02:00
|
|
|
skip=n
|
|
|
|
[ $PHP_MAJOR_VERSION -eq 8 ] && [ $PHP_MINOR_VERSION -ge 0 ] && {
|
2021-04-06 22:18:03 +02:00
|
|
|
echo
|
2021-04-06 22:05:33 +02:00
|
|
|
#composer update
|
|
|
|
#composer test || {
|
|
|
|
# cat tests/MadelineProto.log
|
|
|
|
# exit 1
|
|
|
|
#}
|
|
|
|
#cat tests/MadelineProto.log
|
2021-04-05 22:54:08 +02:00
|
|
|
} || {
|
|
|
|
skip=y
|
|
|
|
echo "Skip"
|
|
|
|
}
|
|
|
|
|
2019-06-18 12:31:44 +02:00
|
|
|
# Clean up
|
2019-05-11 01:02:15 +02:00
|
|
|
madelinePath=$PWD
|
2021-09-04 18:07:22 +02:00
|
|
|
[ "$IS_RELEASE" == "y" ] && ref="$TAG" || ref="$COMMIT"
|
2019-06-18 12:31:44 +02:00
|
|
|
|
2021-09-04 17:22:45 +02:00
|
|
|
php8.0 $(which composer) update
|
|
|
|
php8.0 vendor/bin/phabel publish -d "$ref"
|
2020-01-19 14:29:53 +01:00
|
|
|
|
2021-09-04 17:42:31 +02:00
|
|
|
git checkout "$ref.9998"
|
|
|
|
|
2021-09-04 17:22:45 +02:00
|
|
|
cd ..
|
|
|
|
rm -rf phar
|
|
|
|
mkdir phar
|
2021-03-30 16:10:37 +02:00
|
|
|
|
2021-09-04 17:22:45 +02:00
|
|
|
cd phar
|
2021-03-30 21:35:07 +02:00
|
|
|
|
2019-06-18 12:31:44 +02:00
|
|
|
# Install
|
2018-02-21 12:55:42 +01:00
|
|
|
echo '{
|
2021-09-04 17:22:45 +02:00
|
|
|
"name": "danog/madelineprotophar",
|
2018-02-20 15:49:54 +01:00
|
|
|
"require": {
|
2021-09-04 17:22:45 +02:00
|
|
|
"danog/madelineproto": "'$ref'.9998"
|
2018-02-20 15:49:54 +01:00
|
|
|
},
|
|
|
|
"authors": [
|
|
|
|
{
|
|
|
|
"name": "Daniil Gentili",
|
|
|
|
"email": "daniil@daniil.it"
|
|
|
|
}
|
2021-09-04 17:22:45 +02:00
|
|
|
],
|
|
|
|
"repositories": [
|
|
|
|
{
|
|
|
|
"type": "path",
|
2021-09-04 18:16:00 +02:00
|
|
|
"url": "'$madelinePath'",
|
|
|
|
"options":{"symlink": false}
|
2021-09-04 17:22:45 +02:00
|
|
|
}
|
2018-02-20 15:49:54 +01:00
|
|
|
]
|
|
|
|
}' > composer.json
|
2021-09-04 17:22:45 +02:00
|
|
|
composer update --no-cache
|
|
|
|
composer dumpautoload --optimize
|
2021-09-04 17:37:48 +02:00
|
|
|
rm -rf vendor/phabel/phabel/tests* vendor/danog/madelineproto/docs
|
2021-09-04 18:27:54 +02:00
|
|
|
find vendor/ -type f -exec sed 's/private function __sleep/public function __sleep/g' -i {} +
|
2021-03-30 23:02:58 +02:00
|
|
|
cd ..
|
|
|
|
|
2021-03-30 21:18:38 +02:00
|
|
|
branch="-$BRANCH"
|
2019-05-11 01:02:15 +02:00
|
|
|
cd $madelinePath
|
2019-09-21 17:11:37 +02:00
|
|
|
|
2019-06-16 21:20:29 +02:00
|
|
|
export TEST_SECRET_CHAT=test
|
|
|
|
export TEST_USERNAME=danogentili
|
2019-06-17 12:19:46 +02:00
|
|
|
export TEST_DESTINATION_GROUPS='["@danogentili"]'
|
2019-09-04 18:33:27 +02:00
|
|
|
export MTPROTO_SETTINGS='{"logger":{"logger_level":5}}'
|
2019-06-16 21:20:29 +02:00
|
|
|
|
2020-02-04 17:34:02 +01:00
|
|
|
runTestSimple()
|
|
|
|
{
|
2021-04-07 14:09:49 +02:00
|
|
|
tests/testing.php || {
|
|
|
|
cat MadelineProto.log
|
2021-04-07 16:41:13 +02:00
|
|
|
sleep 10
|
2021-04-07 14:09:49 +02:00
|
|
|
exit 1
|
|
|
|
}
|
2020-02-04 17:34:02 +01:00
|
|
|
}
|
|
|
|
runTest()
|
|
|
|
{
|
2021-04-05 17:58:35 +02:00
|
|
|
[ "$1" != "" ] && p="$1" || p=php
|
2021-04-07 15:15:49 +02:00
|
|
|
echo "m
|
2019-06-17 12:19:46 +02:00
|
|
|
$API_ID
|
|
|
|
$API_HASH
|
|
|
|
b
|
|
|
|
$BOT_TOKEN
|
|
|
|
n
|
|
|
|
n
|
|
|
|
n
|
2021-04-07 15:15:49 +02:00
|
|
|
" | $p tests/testing.php || {
|
|
|
|
cat MadelineProto.log
|
2021-04-07 16:41:13 +02:00
|
|
|
sleep 10
|
2021-04-07 15:15:49 +02:00
|
|
|
exit 1
|
|
|
|
}
|
2020-02-04 17:34:02 +01:00
|
|
|
}
|
|
|
|
|
2021-04-07 18:58:25 +02:00
|
|
|
k()
|
|
|
|
{
|
2021-09-04 23:57:01 +02:00
|
|
|
while :; do pkill -f 'MadelineProto worker .*' -P $$ || break && sleep 1; done
|
2021-04-07 18:58:25 +02:00
|
|
|
}
|
|
|
|
|
2021-06-11 20:38:39 +02:00
|
|
|
k
|
2021-04-06 17:21:03 +02:00
|
|
|
rm -f madeline.phar testing.madeline*
|
2021-04-06 00:11:32 +02:00
|
|
|
|
2020-02-04 17:34:02 +01:00
|
|
|
echo "Testing with previous version..."
|
2021-04-06 00:11:32 +02:00
|
|
|
export ACTIONS_FORCE_PREVIOUS=1
|
2020-02-04 17:34:02 +01:00
|
|
|
cp tests/testing.php tests/testingBackup.php
|
2021-04-06 00:11:32 +02:00
|
|
|
runTest
|
2021-04-07 18:58:25 +02:00
|
|
|
k
|
2020-02-04 17:34:02 +01:00
|
|
|
|
|
|
|
echo "Testing with new version (upgrade)..."
|
2021-09-04 18:07:22 +02:00
|
|
|
php tools/makephar.php $madelinePath/../phar "madeline$php$branch.phar" "$COMMIT-$php"
|
2021-03-30 21:18:38 +02:00
|
|
|
export ACTIONS_PHAR="madeline$php$branch.phar"
|
2020-02-04 17:34:02 +01:00
|
|
|
runTestSimple
|
2021-04-07 18:58:25 +02:00
|
|
|
k
|
2020-02-04 17:34:02 +01:00
|
|
|
|
|
|
|
echo "Testing with new version (restart)"
|
|
|
|
cp tests/testingBackup.php tests/testing.php
|
2021-04-06 22:44:40 +02:00
|
|
|
rm -f testing.madeline* || echo
|
2020-02-04 17:34:02 +01:00
|
|
|
runTest
|
|
|
|
|
|
|
|
echo "Testing with new version (reload)"
|
2019-12-29 14:44:03 +01:00
|
|
|
cp tests/testingBackup.php tests/testing.php
|
2020-02-04 17:34:02 +01:00
|
|
|
runTestSimple
|
2021-04-07 18:58:25 +02:00
|
|
|
k
|
2021-04-05 17:58:35 +02:00
|
|
|
|
|
|
|
echo "Testing with new version (kill+reload)"
|
|
|
|
cp tests/testingBackup.php tests/testing.php
|
|
|
|
runTestSimple
|
2020-02-04 17:34:02 +01:00
|
|
|
|
2021-03-30 20:57:10 +02:00
|
|
|
echo "Checking syntax of madeline.php"
|
|
|
|
php -l ./tools/phar.php
|
2019-06-16 21:20:29 +02:00
|
|
|
|
2021-04-06 22:18:03 +02:00
|
|
|
if [ "$SSH_KEY" != "" ]; then
|
|
|
|
eval "$(ssh-agent -s)"
|
|
|
|
echo -e "$SSH_KEY" > madeline_rsa
|
|
|
|
chmod 600 madeline_rsa
|
|
|
|
ssh-add madeline_rsa
|
2021-04-06 22:26:05 +02:00
|
|
|
fi
|
2021-04-06 22:18:03 +02:00
|
|
|
|
2021-04-06 22:51:40 +02:00
|
|
|
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
|
|
git config --global user.name "Github Actions"
|
2021-04-06 22:35:43 +02:00
|
|
|
|
2021-09-04 17:22:45 +02:00
|
|
|
rm -rf MadelineProtoPhar
|
2018-02-21 12:55:42 +01:00
|
|
|
git clone git@github.com:danog/MadelineProtoPhar
|
|
|
|
cd MadelineProtoPhar
|
2019-09-04 22:16:35 +02:00
|
|
|
|
2019-06-18 14:31:38 +02:00
|
|
|
cp "../madeline$php$branch.phar" .
|
2019-10-28 22:39:23 +01:00
|
|
|
cp ../tools/phar.php ../examples/mtproxyd .
|
2021-09-04 18:07:22 +02:00
|
|
|
echo -n "$COMMIT-$php" > release$php$branch
|
2019-06-21 21:20:44 +02:00
|
|
|
|
2019-09-21 20:43:01 +02:00
|
|
|
[ "$IS_RELEASE" == "y" ] && {
|
2019-06-21 21:20:44 +02:00
|
|
|
cp release$php$branch release$php
|
|
|
|
cp madeline$php$branch.phar madeline$php.phar
|
|
|
|
}
|
|
|
|
|
2019-06-21 21:28:15 +02:00
|
|
|
git add -A
|
2021-03-30 21:18:38 +02:00
|
|
|
git commit -am "Release $BRANCH - $COMMIT_MESSAGE"
|
2021-03-30 16:10:37 +02:00
|
|
|
while :; do
|
|
|
|
git push origin master && break || {
|
|
|
|
git fetch
|
|
|
|
git rebase origin/master
|
|
|
|
}
|
|
|
|
done
|
2019-09-04 19:17:16 +02:00
|
|
|
|
2018-02-21 12:55:42 +01:00
|
|
|
cd ..
|
2021-03-30 21:18:38 +02:00
|
|
|
echo "$COMMIT_MESSAGE" | grep "Apply fixes from StyleCI" && exit
|
2018-02-20 13:15:32 +01:00
|
|
|
|
|
|
|
[ -d JSON.sh ] || git clone https://github.com/dominictarr/JSON.sh
|
2021-03-30 23:24:05 +02:00
|
|
|
for chat_id in $DESTINATIONS;do
|
2021-03-30 21:18:38 +02:00
|
|
|
ID=$(curl -s https://api.telegram.org/bot$BOT_TOKEN/sendMessage -F disable_web_page_preview=1 -F text=" <b>Recent Commits to MadelineProto:$BRANCH</b>
|
2021-09-04 18:07:22 +02:00
|
|
|
<a href=\"https://github.com/danog/MadelineProto/commit/$COMMIT\">$COMMIT_MESSAGE (PHP $PHP_MAJOR_VERSION.$PHP_MINOR_VERSION)</a>
|
2019-12-25 19:38:44 +01:00
|
|
|
|
2021-04-06 23:23:17 +02:00
|
|
|
$COMMIT_MESSAGE" -F parse_mode="HTML" -F chat_id=$chat_id | JSON.sh/JSON.sh -s | egrep '\["result","message_id"\]' | cut -f 2 | cut -d '"' -f 2)
|
2019-12-25 19:38:44 +01:00
|
|
|
|
2018-02-20 13:15:32 +01:00
|
|
|
done
|