From 09276284cadcb7cea1fdd616d5bea9375634ae19 Mon Sep 17 00:00:00 2001 From: insolita Date: Thu, 15 Apr 2021 19:16:37 +0800 Subject: [PATCH] prepare action for build phar, fix #33 --- .github/builder.sh | 10 ++++++ .github/workflows/release.yml | 58 +++++++++++++++++++++++++++++++++++ box.json | 8 +++++ composer.json | 2 +- 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 .github/builder.sh create mode 100644 .github/workflows/release.yml create mode 100644 box.json diff --git a/.github/builder.sh b/.github/builder.sh new file mode 100644 index 0000000..3cfadd2 --- /dev/null +++ b/.github/builder.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -eu + +box validate || exit 1 +box compile || exit 1 + +if [ ! -f "./unused_scanner.phar" ] || [ ! -x "./unused_scanner.phar" ]; then + (>&2 echo "Phar build failed :-(") + exit 1 +fi \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f20e794 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: release +# on: +# push: +# tags: +# - '*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.1' + extensions: intl, zip, zlib, mbstring + coverage: none + ini-values: memory_limit=1G, phar.readonly=0 + + - name: Get composer cache directory + id: composer_release_cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache Composer packages + id: composer-release-cache + uses: actions/cache@v2 + with: + path: ${{ steps.composer_release_cache.outputs.dir }} + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.json') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install + run: composer install --prefer-dist --no-interaction --no-ansi --no-progress --no-suggest + + - name: Install Box + run: composer global require humbug/box + + - name: Phar building + run: .github/builder.sh + + - name: Getting Tag Name + id: get-version + run: echo ::set-output name=version::${GITHUB_REF#refs/tags/} + + - name: Self-Test + run: ./unused_scanner.phar --version + + - name: Release + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + name: ${{ steps.get-version.outputs.version }} + tag: ${{ steps.get-version.outputs.version }} + body: 'Next stable release.' + allowUpdates: true + artifacts: unused_scanner.phar + artifactContentType: application/x-php \ No newline at end of file diff --git a/box.json b/box.json new file mode 100644 index 0000000..f4ff459 --- /dev/null +++ b/box.json @@ -0,0 +1,8 @@ +{ + "chmod": "0755" , + "directories": [ "Lib" , "Exceptions" , "vendor" ] , + "files": [ "README.md" ] , + "main": "unused_scanner" , + "output": "unused_scanner.phar" , + "stub": true +} \ No newline at end of file diff --git a/composer.json b/composer.json index a46689e..23afe80 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "psr-4": { "insolita\\Scanner\\Lib\\": "Lib" , "insolita\\Scanner\\Exceptions\\": "Exceptions", - "tests": "tests" + "tests\\": "tests" } } , "extra": {