Add automated phar downloader

This commit is contained in:
Daniil Gentili 2018-02-21 12:55:42 +01:00
parent 0cd071cdb8
commit 925fa88de1
No known key found for this signature in database
GPG Key ID: 259900308520B573
7 changed files with 59 additions and 19 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
MadelineProtoPhar
JSON.sh
halloween
*.raw

View File

@ -1,8 +1,12 @@
language: php
php:
- '7.1'
before_install: echo "phar.readonly = 0" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- '7.1'
before_install:
- openssl aes-256-cbc -K $encrypted_5699a01b7a5f_key -iv $encrypted_5699a01b7a5f_iv
-in madeline_rsa.enc -out madeline_rsa -d
- echo "phar.readonly = 0" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- eval "$(ssh-agent -s)"
- ssh-add madeline_rsa
script:
- tests/makephar.sh

View File

@ -66,11 +66,13 @@ This library can also be used to create lua telegram bots (like bot API bots, on
* PFS in secret chats
## Requirements
## PHP Requirements
This project can only run on *PHP 7* and *HHVM*, both 32 bit and 64 bit systems are supported (x86, x86_64, armel, armhf, arm64, mipsel, mips64, powerpc and so on).
You can also run it on PHP 5 using [7to5](https://github.com/spatie/7to5).
To run it on *PHP 5*, use [MadelineProtoPhar](https://phar.madelineproto.xyz).
MadelineProto needs the curl, xml, mbstring extensions to function properly (most webhosts already have these extensions).
To install *all of the requirements* on `Ubuntu`, `Debian`, `Devuan`, or any other `Debian-based` distro, run the following command in your command line:
@ -109,6 +111,16 @@ Also note that MadelineProto will perform better if [php-primemodule](https://pr
### Installation
Download [phar.php](https://phar.madelineproto.xyz/phar.php), and include it in your script:
```
include 'phar.php';
```
It will automatically download the latest version of MadelineProto and import it.
OR
Run the following commands in a console:
```

View File

@ -70,11 +70,13 @@ This library can also be used to create lua telegram bots (like bot API bots, on
* PFS in secret chats
## Requirements
## PHP Requirements
This project can only run on *PHP 7* and *HHVM*, both 32 bit and 64 bit systems are supported (x86, x86_64, armel, armhf, arm64, mipsel, mips64, powerpc and so on).
You can also run it on PHP 5 using [7to5](https://github.com/spatie/7to5).
To run it on *PHP 5*, use [MadelineProtoPhar](https://phar.madelineproto.xyz).
MadelineProto needs the curl, xml, mbstring extensions to function properly (most webhosts already have these extensions).
To install *all of the requirements* on `Ubuntu`, `Debian`, `Devuan`, or any other `Debian-based` distro, run the following command in your command line:
@ -113,6 +115,16 @@ Also note that MadelineProto will perform better if [php-primemodule](https://pr
### Installation
Download [phar.php](https://phar.madelineproto.xyz/phar.php), and include it in your script:
```
include 'phar.php';
```
It will automatically download the latest version of MadelineProto and import it.
OR
Run the following commands in a console:
```

BIN
madeline_rsa.enc Normal file

Binary file not shown.

1
phar.php Normal file
View File

@ -0,0 +1 @@
<?php

View File

@ -1,13 +1,14 @@
#!/bin/sh -e
echo "$TRAVIS_COMMIT_MESSAGE" | grep -q phar && {
composer global require spatie/7to5
composer global require spatie/7to5
[ -f $HOME/.composer/vendor/bin/php7to5 ] && php7to5=$HOME/.composer/vendor/bin/php7to5
[ -f $HOME/.config/composer/vendor/bin/php7to5 ] && php7to5=$HOME/.config/composer/vendor/bin/php7to5
rm -rf phar7 phar5
rm -rf phar7 phar5 MadelineProtoPhar
mkdir phar7
cd phar7
echo '{
mkdir phar7
cd phar7
echo '{
"name": "danog/madelineprototests",
"minimum-stability":"dev",
"require": {
@ -26,13 +27,22 @@ echo "$TRAVIS_COMMIT_MESSAGE" | grep -q phar && {
}
]
}' > composer.json
composer update
cd ..
composer update
cd ..
$HOME/.composer/vendor/bin/php7to5 convert --copy-all phar7 phar5
$php7to5 convert --copy-all phar7 phar5
php makephar.php phar5 madeline.phar $TRAVIS_COMMIT
git clone git@github.com:danog/MadelineProtoPhar
cd MadelineProtoPhar
cp ../madeline.phar .
echo "$TRAVIS_COMMIT_MESSAGE" | grep -q release_phar && echo -n $TRAVIS_COMMIT > release
git add -A
git commit -am "Release $TRAVIS_COMMIT"
git push origin master
cd ..
php makephar.php phar5 madeline.phar $TRAVIS_COMMIT
}
[ -d JSON.sh ] || git clone https://github.com/dominictarr/JSON.sh
for chat_id in $destinations;do
@ -41,6 +51,6 @@ for chat_id in $destinations;do
$TRAVIS_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)
echo "$TRAVIS_COMMIT_MESSAGE" | grep -q phar && curl -s https://api.telegram.org/bot$token/sendDocument -F caption="md5: $(md5sum madeline.phar | sed 's/\s.*//g')
echo "$TRAVIS_COMMIT_MESSAGE" | grep -q release_phar && curl -s https://api.telegram.org/bot$token/sendDocument -F caption="md5: $(md5sum madeline.phar | sed 's/\s.*//g')
commit: $TRAVIS_COMMIT" -F chat_id=$chat_id -F document=@madeline.phar -F reply_to_message_id=$ID
done