diff --git a/box.json b/box.json new file mode 100644 index 00000000..c7d0207b --- /dev/null +++ b/box.json @@ -0,0 +1,36 @@ +{ + "alias": "minfraud.phar", + "main": "phar-stub.php", + "output": "minfraud.phar", + "compactors": [ + "Herrera\\Box\\Compactor\\Composer", + "Herrera\\Box\\Compactor\\Json", + "Herrera\\Box\\Compactor\\Php" + ], + "files": [ + "LICENSE" + ], + "finder": [ + { + "name": [ + "LICENSE", + "LICENSE.*", + "*.php", + "*.pem", + "*.pem.md5" + ], + "exclude": [ + "phpunit", + "satooshi", + "Tests", + "tests", + "yaml" + ], + "in": "vendor" + } + ], + "directories": ["src/"], + "git-version": "git-version", + "shebang": false, + "stub": true +} diff --git a/composer.json b/composer.json index 9e47e3eb..45b1bfa8 100644 --- a/composer.json +++ b/composer.json @@ -19,8 +19,8 @@ "require": { "php": ">=5.3", "ext-json": "*", - "geoip2/geoip2": "2.2.0-alpha2", - "maxmind/web-service-common": "~0.0.1", + "geoip2/geoip2": "2.2.0-beta1", + "maxmind/web-service-common": "~0.0.2", "respect/validation": "~0.9.1" }, "require-dev": { diff --git a/dev-bin/phar-test.php b/dev-bin/phar-test.php new file mode 100755 index 00000000..8b70fc7e --- /dev/null +++ b/dev-bin/phar-test.php @@ -0,0 +1,10 @@ +#!/usr/bin/env php +now->ymd eq \$2; +say \$1; +EOF +) + +TAG="v$VERSION" + +if [ -f minfraud.phar ]; then + rm minfraud.phar +fi + +if [ -n "$(git status --porcelain)" ]; then + echo ". is not clean." >&2 + exit 1 +fi + +if [ -d vendor ]; then + rm -fr vendor +fi + +php composer.phar self-update +php composer.phar update --no-dev + +perl -pi -e "s/(?<=const VERSION = ').+?(?=';)/$TAG/g" src/MinFraud.php + +if [ ! -f box.phar ]; then + wget -O box.phar "https://github.com/box-project/box2/releases/download/2.5.0/box-2.5.0.phar" +fi + +php box.phar build + +PHAR_TEST=$(./dev-bin/phar-test.php) +if [[ -n $PHAR_TEST ]]; then + echo "Phar test outputed non-empty string: $PHAR_TEST" + exit 1 +fi + +# Download test deps +php composer.phar update + +./vendor/bin/phpunit + +if [ ! -d .gh-pages ]; then + echo "Checking out gh-pages in .gh-pages" + git clone -b gh-pages git@github.maxmind.com:maxmind/minfraud-api-php.git .gh-pages + pushd .gh-pages +else + echo "Updating .gh-pages" + pushd .gh-pages + git pull +fi + +if [ -n "$(git status --porcelain)" ]; then + echo ".gh-pages is not clean" >&2 + exit 1 +fi + +# We no longer have apigen as a dependency in Composer as releases are +# sporadically deleted upstream and compatibility is often broken on patch +# releases. +if [ ! -f apigen.phar ]; then + wget -O apigen.phar "https://github.com/apigen/apigen/releases/download/v4.0.0-RC3/apigen-4.0.0-RC3.phar" +fi + + +cat < apigen.neon +destination: doc/$TAG + +source: + - ../src + +title: "minFraud Score and Insights PHP API $TAG" +EOF + +php apigen.phar generate + + +PAGE=index.md +cat < $PAGE +--- +layout: default +title: minFraud Score and Insights PHP API +language: php +version: $TAG +--- + +EOF + +cat ../README.md >> $PAGE + +git add doc/ +git commit -m "Updated for $TAG" -a + +read -e -p "Push to origin? " SHOULD_PUSH + +if [ "$SHOULD_PUSH" != "y" ]; then + echo "Aborting" + exit 1 +fi + +git push + +popd + +git tag -a $TAG +git push +git push --tags diff --git a/phar-stub.php b/phar-stub.php new file mode 100644 index 00000000..36d4928a --- /dev/null +++ b/phar-stub.php @@ -0,0 +1,3 @@ +