|
| 1 | +name: Build application |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + tag: |
| 7 | + description: 'Tag version' |
| 8 | + required: true |
| 9 | + |
| 10 | +permissions: write-all |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Extract the tag version |
| 18 | + id: tag |
| 19 | + run: | |
| 20 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 21 | + GITHUB_REF=${{ github.event.inputs.tag }} |
| 22 | + fi |
| 23 | + echo "tag=${GITHUB_REF##*v}" >> "$GITHUB_OUTPUT" |
| 24 | +
|
| 25 | + - name: Checkout the code |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + submodules: true |
| 29 | + |
| 30 | + - name: Setup PHP |
| 31 | + uses: shivammathur/setup-php@v2 |
| 32 | + with: |
| 33 | + php-version: 8.2 |
| 34 | + extensions: curl, mbstring, zip, pcntl, pdo, pdo_sqlite, iconv, json, dom, curl, libxml, fileinfo, tokenizer, xml |
| 35 | + ini-values: error_reporting=E_ALL |
| 36 | + coverage: none |
| 37 | + |
| 38 | + - name: Install the dependencies |
| 39 | + run: composer install --prefer-dist --no-progress --no-interaction --no-suggest |
| 40 | + |
| 41 | + - name: Execute unit/feature tests |
| 42 | + run: php ./iconify --test |
| 43 | + |
| 44 | + - name: Create the PHAR file |
| 45 | + run: php ./iconify app:build iconify --build-version=${{ steps.tag.outputs.tag }} --ansi |
| 46 | + |
| 47 | + - name: Upload artifact |
| 48 | + uses: actions/upload-artifact@v4 |
| 49 | + with: |
| 50 | + name: iconify |
| 51 | + path: builds/iconify |
| 52 | + retention-days: 1 |
| 53 | + |
| 54 | + checks: |
| 55 | + runs-on: ubuntu-latest |
| 56 | + |
| 57 | + needs: build |
| 58 | + |
| 59 | + strategy: |
| 60 | + fail-fast: true |
| 61 | + matrix: |
| 62 | + os: [ "ubuntu-latest", "windows-latest" ] |
| 63 | + php: [ "8.2", "8.3", "8.4" ] |
| 64 | + |
| 65 | + name: check on ${{ matrix.os }} with PHP ${{ matrix.php }} |
| 66 | + |
| 67 | + steps: |
| 68 | + - name: Setup PHP |
| 69 | + uses: shivammathur/setup-php@v2 |
| 70 | + with: |
| 71 | + php-version: ${{ matrix.php }} |
| 72 | + extensions: curl, mbstring, zip, pcntl, pdo, pdo_sqlite, iconv, json, dom, curl, libxml, fileinfo, tokenizer, xml |
| 73 | + ini-values: error_reporting=E_ALL |
| 74 | + coverage: none |
| 75 | + |
| 76 | + - name: Remove old file |
| 77 | + run: rm -f builds/iconify |
| 78 | + |
| 79 | + - uses: actions/download-artifact@v4 |
| 80 | + with: |
| 81 | + name: iconify |
| 82 | + path: builds |
| 83 | + |
| 84 | + - name: Show version |
| 85 | + run: php builds/iconify --version |
| 86 | + |
| 87 | + - name: Run iconify-ide |
| 88 | + run: php builds/iconify --test |
| 89 | + |
| 90 | + push: |
| 91 | + runs-on: ubuntu-latest |
| 92 | + |
| 93 | + needs: checks |
| 94 | + |
| 95 | + steps: |
| 96 | + - name: Checkout the code |
| 97 | + uses: actions/checkout@v4 |
| 98 | + |
| 99 | + - name: Remove old file |
| 100 | + run: rm -f builds/iconify |
| 101 | + |
| 102 | + - uses: actions/download-artifact@v4 |
| 103 | + with: |
| 104 | + name: iconify |
| 105 | + path: builds |
| 106 | + |
| 107 | + - name: Git setup |
| 108 | + run: | |
| 109 | + git config --local user.email "[email protected]" |
| 110 | + git config --local user.name "GitHub Action" |
| 111 | + |
| 112 | + git config --global core.autocrlf false |
| 113 | + git config --global core.eol lf |
| 114 | +
|
| 115 | + - name: Commit the PHAR file |
| 116 | + id: build |
| 117 | + run: | |
| 118 | + IS_DIRTY=1 |
| 119 | + |
| 120 | + { git add ./builds/iconify && git commit -a -m "🏗️ Build application"; } || IS_DIRTY=0 |
| 121 | + |
| 122 | + echo "is_dirty=${IS_DIRTY}" >> "$GITHUB_OUTPUT" |
| 123 | +
|
| 124 | + - name: Push changes |
| 125 | + uses: ad-m/github-push-action@master |
| 126 | + if: steps.build.outputs.is_dirty == 1 |
| 127 | + with: |
| 128 | + github_token: ${{ secrets.COMPOSER_TOKEN }} |
0 commit comments