diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 937387df..f09d6d9c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,8 +5,16 @@ before_script: test:app: #when: manual + before_script: + - wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig + - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" + - php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" + - php composer-setup.php + - php -r "unlink('composer-setup.php'); unlink('installer.sig');" + - php composer.phar install script: - cd api/Tests - phpunit - cd ../../ci - - php deploy_release_to_github.php \ No newline at end of file + - bash build_zip.sh + #- php deploy_release_to_github.php \ No newline at end of file diff --git a/ci/build_zip.sh b/ci/build_zip.sh new file mode 100644 index 00000000..936b9f50 --- /dev/null +++ b/ci/build_zip.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +cd ../ +mkdir release-temp +TARGETDIR='release-temp';for file in *;do test "$file" != "$TARGETDIR" && cp -r "$file" "$TARGETDIR/";done + +# Remove files that we don't want to bundle +cd release-temp +rm -rf ci +#rm .gitignore +#rm .gitlab-ci.yml +rm -rf .git +rm apidoc.json +rm CONTRIBUTING.md + +cd ../ +zip -r release.zip release-temp +rm -rf release-temp \ No newline at end of file diff --git a/ci/deploy_release_to_github.php b/ci/deploy_release_to_github.php index eeec0177..52723f5f 100644 --- a/ci/deploy_release_to_github.php +++ b/ci/deploy_release_to_github.php @@ -1,2 +1,49 @@ open($zip_name, ZipArchive::CREATE); +if ($res !== true) { + die("Failed to create zip!\n"); +} + +// Create recursive directory iterator +/** @var SplFileInfo[] $files */ +$files = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator("../"), + RecursiveIteratorIterator::LEAVES_ONLY +); + +foreach ($files as $name => $file) +{ + echo "\nWorking with file " . $file->getFilename() . "\n"; + + continue; + + if (substr($file->getFilename(), 0, strlen($file->getFilename())) === "." || + strtolower($file->getFilename()) === 'attachments' || + strtolower($file->getFilename()) === "contributing.md" || + strtolower($file->getFilename() === "ci") || + strtolower($file->getFilename() === "apidoc.json")) { + //-- Don"t compress . files + echo "Skipped file.\n"; + continue; + } + + // Skip directories (they would be added automatically) + if (!$file->isDir()) + { + // Get real and relative path for current file + $filePath = $file->getRealPath(); + $relativePath = substr($filePath, strlen("../") + 1); + + // Add current file to archive + $zip->addFile($filePath, $relativePath); + } else { + echo "Skipped directory " . $file->getFilename() . "\n"; + } +} \ No newline at end of file