diff --git a/.github/workflows/phar.yaml b/.github/workflows/phar.yaml new file mode 100644 index 0000000..78e7536 --- /dev/null +++ b/.github/workflows/phar.yaml @@ -0,0 +1,93 @@ +name: PHAR + +on: + push: + tags: + - v[0-9]+.[0-9]+.[0-9]+ + +env: + DRIFT_PHAR_NAME: drift.phar + +jobs: + version: + name: Version + runs-on: ubuntu-latest + + outputs: + drift_version: ${{ steps.version.outputs.drift_version }} + + steps: + + - name: Get Drift version from tag + id: version + run: echo ::set-output name=drift_version::${GITHUB_REF/refs\/tags\//} + + phar-build: + name: Build + runs-on: ubuntu-latest + + needs: version + + steps: + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + tools: composer:v2 + + - name: Install Composer dependencies + # Make sure to ignore development dependencies + run: composer update --no-interaction --prefer-dist --no-progress --no-dev + + - name: Download Box + run: | + wget https://github.com/humbug/box/releases/latest/download/box.phar + chmod +x box.phar + + - name: Building PHAR for Drift ${{ needs.version.outputs.drift_version }} + run: php box.phar compile + + - name: Test compiled PHAR for Drift ${{ needs.version.outputs.drift_version }} + run: php bin/${{ env.DRIFT_PHAR_NAME }} --version + + - uses: actions/upload-artifact@v2 + with: + name: ${{ env.DRIFT_PHAR_NAME }} + path: bin/${{ env.DRIFT_PHAR_NAME }} + + phar-release: + name: Release + runs-on: ubuntu-latest + + needs: [version, phar-build] + + steps: + + - uses: actions/download-artifact@v2 + with: + name: ${{ env.DRIFT_PHAR_NAME }} + + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ needs.version.outputs.drift_version }} + draft: false + prerelease: false + + - name: Upload Drift PHAR + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./${{ env.DRIFT_PHAR_NAME }} + asset_name: ${{ env.DRIFT_PHAR_NAME }} + asset_content_type: application/octet-stream diff --git a/.gitignore b/.gitignore index 987e2a2..61668bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +bin/drift.phar composer.lock vendor diff --git a/box.json.dist b/box.json.dist new file mode 100644 index 0000000..2c6d6c1 --- /dev/null +++ b/box.json.dist @@ -0,0 +1,18 @@ +{ + "directories": [ + "config", + "src", + "vendor" + ], + "files": [ + "composer.json" + ], + "exclude-composer-files": false, + "force-autodiscovery": true, + "compression": "GZ", + "compactors": [ + "KevinGH\\Box\\Compactor\\Php", + "KevinGH\\Box\\Compactor\\PhpScoper", + "KevinGH\\Box\\Compactor\\Json" + ] +}