-
Notifications
You must be signed in to change notification settings - Fork 1
Automate Windows builds #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4b1841f
Create Kiro spec for automating Windows releases
onethumb d0475df
Update Test Workflow to use immutable crc_fast library releases
onethumb 1cd3e83
Create Windows Release Workflow file structure
onethumb 9675e59
Implement extension matrix generation job
onethumb e43d7af
Set up build job matrix configuration
onethumb 968e3ba
Add crc_fast library download and extraction steps
onethumb 8871bbd
Configure extension build with php-windows-builder
onethumb 0edf93b
Create release job with artifact collection
onethumb c9c6496
Create draft release with DLL uploads
onethumb b8946d7
Enable workflow_dispatch
onethumb 59d410a
Remove example workflow
onethumb 5abecf1
WIP. Debug Windows Release workflow
onethumb c4ae5aa
Update .github/workflows/windows-release.yaml
onethumb 63da98e
Apply GitHub Copilot suggestions
onethumb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,264 @@ | ||
| name: Windows Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| # used when called manually. | ||
| workflow_run: | ||
| workflows: ["Tests"] | ||
| types: [completed] | ||
|
|
||
| permissions: | ||
| contents: write # For creating releases and uploading assets | ||
| actions: read # For downloading artifacts from build job | ||
|
|
||
| jobs: | ||
| # Check if this workflow should run (only on successful test runs triggered by version tags) | ||
| check-trigger: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' | ||
| outputs: | ||
| should_run: ${{ steps.check.outputs.should_run }} | ||
| tag_name: ${{ steps.check.outputs.tag_name }} | ||
| steps: | ||
| - name: Debug workflow_run event | ||
| run: | | ||
| echo "Event name: ${{ github.event.workflow_run.event }}" | ||
| echo "Head branch: ${{ github.event.workflow_run.head_branch }}" | ||
| echo "Head SHA: ${{ github.event.workflow_run.head_sha }}" | ||
| echo "Conclusion: ${{ github.event.workflow_run.conclusion }}" | ||
| echo "Full event context:" | ||
| echo '${{ toJson(github.event.workflow_run) }}' | ||
|
|
||
| - name: Check if triggered by version tag | ||
| id: check | ||
| run: | | ||
| # The head_branch contains the tag name directly (e.g., "0.0.1"), not "refs/tags/0.0.1" | ||
| # when the workflow is triggered by a tag push | ||
| HEAD_BRANCH="${{ github.event.workflow_run.head_branch }}" | ||
| EVENT_TYPE="${{ github.event.workflow_run.event }}" | ||
|
|
||
| echo "Event type: ${EVENT_TYPE}" | ||
| echo "Head branch: ${HEAD_BRANCH}" | ||
|
|
||
| # Check if this was triggered by a push event and the branch name looks like a version tag | ||
| if [[ "${EVENT_TYPE}" == "push" ]] && [[ "${HEAD_BRANCH}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "Valid version tag detected: ${HEAD_BRANCH}" | ||
| echo "should_run=true" >> $GITHUB_OUTPUT | ||
| echo "tag_name=${HEAD_BRANCH}" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "Not a valid version tag push. Event: ${EVENT_TYPE}, Branch: ${HEAD_BRANCH}" | ||
| echo "should_run=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| get-extension-matrix: | ||
| runs-on: ubuntu-latest | ||
| needs: check-trigger | ||
| if: needs.check-trigger.outputs.should_run == 'true' | ||
| outputs: | ||
| matrix: ${{ steps.extension-matrix.outputs.matrix }} | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ needs.check-trigger.outputs.tag_name }} | ||
|
|
||
| - name: Debug - Show composer.json | ||
| run: | | ||
| echo "=== composer.json contents ===" | ||
| cat composer.json | ||
| echo "" | ||
| echo "=== PHP version requirement ===" | ||
| grep -A 1 '"require"' composer.json | ||
|
|
||
| - name: Generate extension build matrix | ||
| id: extension-matrix | ||
| uses: php/php-windows-builder/extension-matrix@v1 | ||
| with: | ||
| arch-list: 'x64, arm64' | ||
| php-version-list: "8.1, 8.2, 8.3, 8.4" # reading from composer.json doesn't seem to work? | ||
onethumb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| build: | ||
| runs-on: windows-2022 | ||
| needs: [check-trigger, get-extension-matrix] | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: ${{ fromJson(needs.get-extension-matrix.outputs.matrix) }} | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ needs.check-trigger.outputs.tag_name }} | ||
|
|
||
| - name: Map PHP architecture to library architecture | ||
| id: map-arch | ||
| shell: pwsh | ||
| run: | | ||
| $phpArch = "${{ matrix.arch }}" | ||
|
|
||
| # Check if architecture is supported | ||
| if ($phpArch -eq "x86") { | ||
| echo "ERROR: 32-bit x86 builds are not supported" | ||
| echo "The crc_fast library does not provide 32-bit Windows releases" | ||
| echo "Supported architectures: x64, arm64" | ||
| exit 1 | ||
| } | ||
|
|
||
| $libArch = switch ($phpArch) { | ||
| "x64" { "x86_64" } | ||
| "arm64" { "aarch64" } | ||
| default { "x86_64" } | ||
| } | ||
| echo "lib_arch=$libArch" >> $env:GITHUB_OUTPUT | ||
| echo "Mapped PHP arch '$phpArch' to library arch '$libArch'" | ||
|
|
||
| - name: Download crc_fast Windows library release | ||
| shell: pwsh | ||
| run: | | ||
| $libArch = "${{ steps.map-arch.outputs.lib_arch }}" | ||
|
|
||
| # Get the latest release information from GitHub API | ||
| $releaseUrl = "https://api.github.com/repos/awesomized/crc-fast-rust/releases/latest" | ||
| $release = Invoke-RestMethod -Uri $releaseUrl -Headers @{ | ||
| "Accept" = "application/vnd.github+json" | ||
| "User-Agent" = "GitHub-Actions" | ||
| } | ||
|
|
||
| $version = $release.tag_name | ||
| echo "Latest crc_fast library version: $version" | ||
|
|
||
| # Find the Windows artifact for the target architecture | ||
| $artifactName = "crc-fast-$version-windows-$libArch.zip" | ||
| $asset = $release.assets | Where-Object { $_.name -eq $artifactName } | ||
|
|
||
| if (-not $asset) { | ||
| echo "ERROR: Could not find artifact '$artifactName' in release $version" | ||
| echo "Available assets:" | ||
| $release.assets | ForEach-Object { echo " - $($_.name)" } | ||
| exit 1 | ||
| } | ||
|
|
||
| $downloadUrl = $asset.browser_download_url | ||
| echo "Downloading from: $downloadUrl" | ||
|
|
||
| # Download the artifact | ||
| $outputPath = "crc_fast_lib.zip" | ||
| Invoke-WebRequest -Uri $downloadUrl -OutFile $outputPath -Headers @{ | ||
| "Accept" = "application/octet-stream" | ||
| "User-Agent" = "GitHub-Actions" | ||
| } | ||
|
|
||
| if (-not (Test-Path $outputPath)) { | ||
| echo "ERROR: Failed to download crc_fast library" | ||
| exit 1 | ||
| } | ||
|
|
||
| echo "Successfully downloaded crc_fast library ($([math]::Round((Get-Item $outputPath).Length / 1MB, 2)) MB)" | ||
|
|
||
| - name: Extract crc_fast library files | ||
| shell: pwsh | ||
| run: | | ||
| $extractPath = "C:\crc_fast" | ||
| $tempExtractPath = "C:\crc_fast_temp" | ||
|
|
||
| # Create temporary extraction directory | ||
| New-Item -ItemType Directory -Force -Path $tempExtractPath | Out-Null | ||
|
|
||
| # Extract the zip file to temp location | ||
| echo "Extracting crc_fast library to temporary location" | ||
| Expand-Archive -Path "crc_fast_lib.zip" -DestinationPath $tempExtractPath -Force | ||
|
|
||
| # Find the versioned subdirectory (e.g., crc-fast-1.7.0-windows-x86_64) | ||
| $dirs = Get-ChildItem -Path $tempExtractPath -Directory | ||
|
|
||
| if ($dirs.Count -eq 0) { | ||
| echo "ERROR: No subdirectory found after extraction" | ||
| exit 1 | ||
| } elseif ($dirs.Count -gt 1) { | ||
| echo "ERROR: Multiple subdirectories found after extraction. Expected only one." | ||
| $dirs | ForEach-Object { echo " $($_.FullName)" } | ||
| exit 1 | ||
| } | ||
|
|
||
| $versionedDir = $dirs[0] | ||
|
|
||
| echo "Found versioned directory: $($versionedDir.Name)" | ||
|
|
||
| # Move contents from versioned directory to final location | ||
| New-Item -ItemType Directory -Force -Path $extractPath | Out-Null | ||
| Move-Item -Path "$($versionedDir.FullName)\*" -Destination $extractPath -Force | ||
|
|
||
| # Clean up temp directory | ||
| Remove-Item -Recurse -Force $tempExtractPath | ||
|
|
||
| # List extracted contents for debugging | ||
| echo "Final directory structure:" | ||
| Get-ChildItem -Recurse $extractPath | ForEach-Object { echo " $($_.FullName)" } | ||
|
|
||
| - name: Verify required library files | ||
| shell: pwsh | ||
| run: | | ||
| $extractPath = "C:\crc_fast" | ||
| $requiredFiles = @( | ||
| "include\libcrc_fast.h", | ||
| "lib\crc_fast.lib" | ||
| ) | ||
|
|
||
| $missingFiles = @() | ||
| foreach ($file in $requiredFiles) { | ||
| $fullPath = Join-Path $extractPath $file | ||
| if (-not (Test-Path $fullPath)) { | ||
| $missingFiles += $file | ||
| echo "MISSING: $file" | ||
| } else { | ||
| echo "FOUND: $file" | ||
| } | ||
| } | ||
|
|
||
| if ($missingFiles.Count -gt 0) { | ||
| echo "" | ||
| echo "ERROR: Required library files not found after extraction:" | ||
| $missingFiles | ForEach-Object { echo " - $_" } | ||
| echo "" | ||
| echo "Directory structure:" | ||
| Get-ChildItem -Recurse $extractPath | ForEach-Object { echo " $($_.FullName)" } | ||
| exit 1 | ||
| } | ||
|
|
||
| echo "" | ||
| echo "All required library files verified successfully" | ||
|
|
||
| - name: Build extension with php-windows-builder | ||
| uses: php/php-windows-builder/extension@v1 | ||
| with: | ||
| php-version: ${{ matrix.php-version }} | ||
| arch: ${{ matrix.arch }} | ||
| ts: ${{ matrix.ts }} | ||
| args: --with-crc-fast=C:\crc_fast | ||
|
|
||
| - name: Upload DLL artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: php_crc_fast-${{ matrix.php-version }}-${{ matrix.arch }}-${{ matrix.ts }} | ||
| path: | | ||
| ${{ matrix.arch }}/${{ matrix.ts == 'ts' && 'Release_TS' || 'Release' }}/php_crc_fast.dll | ||
| if-no-files-found: error | ||
|
|
||
| release: | ||
| runs-on: ubuntu-latest | ||
| needs: [check-trigger, build] | ||
| if: needs.check-trigger.outputs.should_run == 'true' | ||
| steps: | ||
| - name: Download all DLL artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| path: artifacts | ||
| pattern: php_crc_fast-* | ||
| merge-multiple: false | ||
|
|
||
| - name: Create draft release with DLL uploads | ||
| uses: php/php-windows-builder/release@v1 | ||
| with: | ||
| release: ${{ needs.check-trigger.outputs.tag_name }} | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| draft: true | ||
| artifacts: artifacts/**/*.dll | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.