Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

feat: add PHAR generation on tag #30

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/phar.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bin/drift.phar
composer.lock
vendor
18 changes: 18 additions & 0 deletions box.json.dist
Original file line number Diff line number Diff line change
@@ -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"
]
}