1212permissions : {}
1313
1414jobs :
15+ build-native-cli-archives :
16+ # Build native CLI archives before the release is created so they can
17+ # be uploaded as GitHub release assets.
18+ if : >
19+ github.repository == 'WordPress/wordpress-playground' &&
20+ (
21+ github.event_name == 'workflow_dispatch' ||
22+ (
23+ github.event.workflow_run.conclusion == 'success' &&
24+ github.event.workflow_run.head_branch == 'trunk'
25+ )
26+ )
27+
28+ strategy :
29+ fail-fast : false
30+ matrix :
31+ include :
32+ - label : linux-x64
33+ os : ubuntu-latest
34+ target : x86_64-unknown-linux-gnu
35+ exe : ' '
36+ - label : linux-arm64
37+ os : ubuntu-24.04-arm
38+ target : aarch64-unknown-linux-gnu
39+ exe : ' '
40+ - label : windows-x64
41+ os : windows-latest
42+ target : x86_64-pc-windows-msvc
43+ exe : ' .exe'
44+ - label : windows-arm64
45+ os : windows-11-arm
46+ target : aarch64-pc-windows-msvc
47+ exe : ' .exe'
48+ - label : macos-x64
49+ os : macos-15-intel
50+ target : x86_64-apple-darwin
51+ exe : ' '
52+ - label : macos-arm64
53+ os : macos-latest
54+ target : aarch64-apple-darwin
55+ exe : ' '
56+ runs-on : ${{ matrix.os }}
57+ timeout-minutes : 90
58+ permissions :
59+ contents : read # Required to clone the repo.
60+ name : ' build-native-cli-archive (${{ matrix.label }})'
61+
62+ steps :
63+ - uses : actions/checkout@v4
64+ with :
65+ ref : ${{ github.event.workflow_run.head_sha || github.sha }}
66+ submodules : true
67+
68+ - name : Install Rust components
69+ run : |
70+ rustup toolchain install stable --profile minimal
71+ rustup default stable
72+ rustup target add ${{ matrix.target }}
73+
74+ - name : Read package version
75+ shell : bash
76+ run : |
77+ VERSION="$(node -p "require('./lerna.json').version")"
78+ echo "WP_PLAYGROUND_NATIVE_VERSION=$VERSION" >> "$GITHUB_ENV"
79+
80+ - name : Build native CLI package archive
81+ shell : bash
82+ env :
83+ WP_PLAYGROUND_NATIVE_TARGET_TRIPLE : ${{ matrix.target }}
84+ WP_PLAYGROUND_NATIVE_SOURCE_COMMIT : ${{ github.event.workflow_run.head_sha || github.sha }}
85+ WP_PLAYGROUND_NATIVE_PACKAGE_PRECOMPILE : ' 1'
86+ run : |
87+ cargo build --manifest-path packages/playground/cli-native/Cargo.toml --release --bins --target ${{ matrix.target }}
88+ cargo run --manifest-path packages/playground/cli-native/Cargo.toml --release --bin package-native-cli -- \
89+ --binary "packages/playground/cli-native/target/${{ matrix.target }}/release/wp-playground-native${{ matrix.exe }}" \
90+ --name "wp-playground-native-$WP_PLAYGROUND_NATIVE_VERSION-${{ matrix.label }}" \
91+ --precompile-wasmtime \
92+ --smoke-wordpress-server \
93+ --smoke-run-blueprint \
94+ --smoke-build-snapshot
95+
96+ - name : Upload native package archive
97+ uses : actions/upload-artifact@v4
98+ with :
99+ name : wp-playground-native-release-${{ matrix.label }}
100+ path : |
101+ packages/playground/cli-native/target/package/*.zip
102+ packages/playground/cli-native/target/package/*.zip.sha256
103+ packages/playground/cli-native/target/package/*.zip.manifest.json
104+ if-no-files-found : error
105+
15106 create-release :
16107 # Only run on the playground repo. Create a release after a successful
17108 # npm publish on trunk, or when triggered manually.
109+ needs : build-native-cli-archives
18110 if : >
19111 github.repository == 'WordPress/wordpress-playground' &&
20112 (
@@ -29,19 +121,27 @@ jobs:
29121 timeout-minutes : 20
30122 permissions :
31123 contents : write # Required to clone the repo, create the GitHub release, and push the tag.
124+ actions : read # Required to download native CLI package artifacts.
32125
33126 steps :
34127 - uses : actions/checkout@v4
35128 with :
36- ref : ${{ github.event.workflow_run.head_branch || github.ref }}
129+ ref : ${{ github.event.workflow_run.head_sha || github.sha }}
37130
38131 - name : Read version from lerna.json
39132 id : version
40133 run : |
41- VERSION=$(jq -r '.version' lerna.json)
134+ VERSION="$(node -p "require('./ lerna.json').version")"
42135 echo "version=$VERSION" >> "$GITHUB_OUTPUT"
43136 echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
44137
138+ - name : Read the post-run changelog from trunk
139+ shell : bash
140+ run : |
141+ set -euo pipefail
142+ git fetch --depth=1 origin trunk
143+ git show origin/trunk:CHANGELOG.md > "$RUNNER_TEMP/CHANGELOG.md"
144+
45145 - name : Extract changelog for this version
46146 id : changelog
47147 run : |
66166
67167 # While in the section for this version, print lines.
68168 found
69- ' CHANGELOG.md)
169+ ' "$RUNNER_TEMP/ CHANGELOG.md" )
70170 if [ -z "$CHANGELOG" ]; then
71171 CHANGELOG="No changelog entries for this release."
72172 fi
@@ -88,19 +188,40 @@ jobs:
88188 echo "> **Stay up to date:** Click **Watch → Custom → Releases** at the top of this repository to get notified of new releases."
89189 } > /tmp/release-body.md
90190
91- - name : Create GitHub Release
191+ - name : Download native CLI package archives
192+ uses : actions/download-artifact@v4
193+ with :
194+ pattern : wp-playground-native-release-*
195+ path : /tmp/native-cli-release-assets
196+ merge-multiple : true
197+
198+ - name : Verify native CLI release assets
199+ env :
200+ VERSION : ${{ steps.version.outputs.version }}
201+ RELEASE_SHA : ${{ github.event.workflow_run.head_sha || github.sha }}
202+ ASSET_DIR : /tmp/native-cli-release-assets
203+ run : python3 packages/playground/cli-native/scripts/verify-release-assets.py
204+
205+ - name : Create or update GitHub Release
92206 env :
93207 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
94208 run : |
95209 TAG="${{ steps.version.outputs.tag }}"
210+ ASSET_DIR="/tmp/native-cli-release-assets"
211+
212+ if [ ! -d "$ASSET_DIR" ] || [ -z "$(find "$ASSET_DIR" -type f -print -quit)" ]; then
213+ echo "::error::No native CLI release assets were downloaded."
214+ exit 1
215+ fi
96216
97217 # Check if this release already exists
98218 if gh release view "$TAG" &>/dev/null; then
99- echo "Release $TAG already exists, skipping."
100- exit 0
219+ echo "Release $TAG already exists, uploading native CLI assets."
220+ else
221+ gh release create "$TAG" \
222+ --title "WordPress Playground $TAG" \
223+ --notes-file /tmp/release-body.md \
224+ --target "${{ github.event.workflow_run.head_sha || github.sha }}"
101225 fi
102226
103- gh release create "$TAG" \
104- --title "WordPress Playground $TAG" \
105- --notes-file /tmp/release-body.md \
106- --target trunk
227+ gh release upload "$TAG" "$ASSET_DIR"/* --clobber
0 commit comments