update php version #18
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.3' | |
| extensions: curl, json | |
| tools: box | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "MAJOR=$(echo $VERSION | cut -d. -f1)" >> $GITHUB_OUTPUT | |
| echo "MINOR=$(echo $VERSION | cut -d. -f1,2)" >> $GITHUB_OUTPUT | |
| - name: Inject version into source | |
| run: | | |
| sed -i "s/VERSION = 'dev'/VERSION = '${{ steps.version.outputs.VERSION }}'/" src/Version.php | |
| - name: Build PHAR (first pass) | |
| run: box compile | |
| - name: Calculate PHAR hash | |
| id: hash | |
| run: | | |
| HASH=$(sha512sum easyaudit.phar | cut -d' ' -f1) | |
| echo "HASH=$HASH" >> $GITHUB_OUTPUT | |
| - name: Inject hash into source | |
| run: | | |
| sed -i "s/HASH = 'dev'/HASH = '${{ steps.hash.outputs.HASH }}'/" src/Version.php | |
| - name: Build PHAR (final) | |
| run: box compile | |
| - name: Verify PHAR | |
| run: | | |
| php easyaudit.phar --version | |
| echo "PHAR size: $(du -h easyaudit.phar | cut -f1)" | |
| - name: Notify middleware webhook | |
| if: ${{ vars.MIDDLEWARE_WEBHOOK_URL != '' }} | |
| run: | | |
| PAYLOAD='{"version":"${{ steps.version.outputs.VERSION }}","hash":"${{ steps.hash.outputs.HASH }}","released_at":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' | |
| SIGNATURE=$(echo -n "$PAYLOAD" | openssl dgst -sha512 -hmac "${{ secrets.WEBHOOK_SECRET }}" | cut -d' ' -f2) | |
| curl -X POST "${{ vars.MIDDLEWARE_WEBHOOK_URL }}" \ | |
| -H "Content-Type: application/json" \ | |
| -H "X-Webhook-Signature: sha512=$SIGNATURE" \ | |
| -d "$PAYLOAD" \ | |
| --fail-with-body || echo "Warning: Failed to notify middleware webhook" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: easyaudit.phar | |
| generate_release_notes: true | |
| fail_on_unmatched_files: true | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| run: | | |
| IMAGE=ghcr.io/${{ github.repository_owner }}/easyaudit | |
| VERSION=${{ steps.version.outputs.VERSION }} | |
| MINOR=${{ steps.version.outputs.MINOR }} | |
| MAJOR=${{ steps.version.outputs.MAJOR }} | |
| docker build -t $IMAGE:$VERSION . | |
| # Mobile tags | |
| docker tag $IMAGE:$VERSION $IMAGE:$MINOR | |
| docker tag $IMAGE:$VERSION $IMAGE:$MAJOR | |
| docker tag $IMAGE:$VERSION $IMAGE:latest | |
| docker push $IMAGE:$VERSION | |
| docker push $IMAGE:$MINOR | |
| docker push $IMAGE:$MAJOR | |
| docker push $IMAGE:latest |