|
| 1 | +name: Build Custom EasyEngine |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "develop" ] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: Build Phar |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Check out source code |
| 14 | + uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Clean environment |
| 17 | + run: | |
| 18 | + rm -rf vendor composer.lock |
| 19 | + - name: Set up PHP |
| 20 | + uses: shivammathur/setup-php@v2 |
| 21 | + with: |
| 22 | + php-version: '8.3' |
| 23 | + coverage: none |
| 24 | + tools: composer |
| 25 | + extensions: pcntl, curl, sqlite3, zip, dom, mbstring, json, phar |
| 26 | + |
| 27 | + - name: Setup Composer authentication |
| 28 | + run: | |
| 29 | + composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} |
| 30 | + composer config --global --auth github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} |
| 31 | + composer config -g repo.packagist composer https://packagist.org |
| 32 | + - name: Install dependencies |
| 33 | + run: | |
| 34 | + composer install --prefer-dist --no-dev --no-progress --no-interaction --optimize-autoloader |
| 35 | + composer dump-autoload --optimize --classmap-authoritative |
| 36 | + - name: Prepare for PHAR build |
| 37 | + run: | |
| 38 | + # Copy required files to temporary directory |
| 39 | + mkdir -p phar-build |
| 40 | + cp -r php bin utils VERSION vendor phar-build/ |
| 41 | + - name: Build uncompressed PHAR |
| 42 | + run: | |
| 43 | + cd phar-build |
| 44 | + php -dphar.readonly=0 ../utils/make-phar.php easyengine.phar --no-compression |
| 45 | + chmod +x easyengine.phar |
| 46 | + mv easyengine.phar ../ |
| 47 | + cd .. |
| 48 | + - name: Test PHAR |
| 49 | + run: | |
| 50 | + php easyengine.phar cli info |
| 51 | + |
| 52 | + # Bước mới: Đọc nội dung file VERSION |
| 53 | + - name: Read VERSION file content |
| 54 | + id: get_version |
| 55 | + run: echo "VERSION_CONTENT=$(cat VERSION)" >> $GITHUB_OUTPUT |
| 56 | + |
| 57 | + - name: Create Git tag |
| 58 | + id: tag |
| 59 | + run: | |
| 60 | + # Sử dụng nội dung từ file VERSION và thêm "-custom" |
| 61 | + VERSION_FROM_FILE="${{ steps.get_version.outputs.VERSION_CONTENT }}" |
| 62 | + TAG_NAME="${VERSION_FROM_FILE}-custom" |
| 63 | + echo "TAG=${TAG_NAME}" >> $GITHUB_OUTPUT |
| 64 | + git tag "${TAG_NAME}" |
| 65 | + git push origin "${TAG_NAME}" |
| 66 | + |
| 67 | + - name: Create Release |
| 68 | + uses: softprops/action-gh-release@v1 |
| 69 | + with: |
| 70 | + tag_name: ${{ steps.tag.outputs.TAG }} |
| 71 | + files: easyengine.phar |
| 72 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments