Release binaries #8
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 binaries | |
| on: | |
| push: | |
| tags: | |
| - 'v[0-9]*.[0-9]*.[0-9]*' | |
| branches: | |
| - test-release | |
| permissions: | |
| contents: read | |
| jobs: | |
| check-version: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check version consistency | |
| run: | | |
| TAG_VERSION="${GITHUB_REF_NAME#v}" | |
| HEADER_VERSION=$(grep -oP '(?<=#define PHP_LIBARCHIVE_VERSION ")[^"]+' php_libarchive.h) | |
| echo "Tag version: $TAG_VERSION" | |
| echo "Header version: $HEADER_VERSION" | |
| if [ "$TAG_VERSION" != "$HEADER_VERSION" ]; then | |
| echo "ERROR: Tag version ($TAG_VERSION) does not match PHP_LIBARCHIVE_VERSION in php_libarchive.h ($HEADER_VERSION)" | |
| exit 1 | |
| fi | |
| echo "Versions match: $TAG_VERSION" | |
| create-draft-release: | |
| needs: [check-version] | |
| if: always() && (needs.check-version.result == 'success' || needs.check-version.result == 'skipped') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-tags: 'true' | |
| ref: ${{ github.ref }} | |
| - name: Create draft release from tag | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: gh release create "${{ github.ref_name }}" --title "${{ github.ref_name }}" --draft | |
| windows-extension-matrix: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.extension-matrix.outputs.matrix }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get the extension matrix | |
| id: extension-matrix | |
| uses: php/php-windows-builder/extension-matrix@v1 | |
| with: | |
| php-version-list: '8.0, 8.1, 8.2, 8.3, 8.4, 8.5' | |
| arch-list: x64 | |
| windows-build-deps: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Cache vcpkg packages | |
| id: vcpkg-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: C:\vcpkg\installed\x64-windows-static-md | |
| key: vcpkg-x64-windows-static-md-libarchive-v1 | |
| - name: Install libarchive via vcpkg | |
| if: steps.vcpkg-cache.outputs.cache-hit != 'true' | |
| shell: pwsh | |
| run: | | |
| $tripletDir = "$env:RUNNER_TEMP\vcpkg-triplets" | |
| New-Item -ItemType Directory -Force -Path $tripletDir | Out-Null | |
| Set-Content "$tripletDir\x64-windows-static-md.cmake" ` | |
| "set(VCPKG_TARGET_ARCHITECTURE x64)`nset(VCPKG_CRT_LINKAGE dynamic)`nset(VCPKG_LIBRARY_LINKAGE static)`nset(VCPKG_BUILD_TYPE release)" | |
| C:\vcpkg\vcpkg.exe install libarchive ` | |
| --triplet x64-windows-static-md ` | |
| --overlay-triplets="$tripletDir" ` | |
| --vcpkg-root C:\vcpkg | |
| - name: Upload libarchive artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: libarchive-x64-windows-static-md | |
| path: C:\vcpkg\installed\x64-windows-static-md | |
| if-no-files-found: error | |
| windows-build: | |
| needs: [windows-extension-matrix, windows-build-deps] | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.windows-extension-matrix.outputs.matrix) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download libarchive artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: libarchive-x64-windows-static-md | |
| path: C:\vcpkg\installed\x64-windows-static-md | |
| - name: Build the extension for Windows | |
| uses: php/php-windows-builder/extension@v1 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| arch: ${{ matrix.arch }} | |
| ts: ${{ matrix.ts }} | |
| args: --with-libarchive=C:\vcpkg\installed\x64-windows-static-md | |
| windows-release: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: [create-draft-release, windows-build] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Upload artifacts to the release | |
| uses: php/php-windows-builder/release@v1 | |
| with: | |
| release: ${{ github.ref_name }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| draft: 'true' |