|
78 | 78 | shell: bash |
79 | 79 |
|
80 | 80 | - name: Build |
81 | | - run: npx nx build:native -- --target ${{ matrix.target }} |
| 81 | + run: npx nx run @kevinmichaelchen/cel-typescript-core:build:native --target=${{ matrix.target }} |
82 | 82 | env: |
83 | 83 | USE_ZIG: ${{ runner.os == 'Linux' }} |
84 | 84 | shell: bash |
@@ -129,10 +129,22 @@ jobs: |
129 | 129 | node-version: 18 |
130 | 130 | cache: npm |
131 | 131 |
|
132 | | - - name: Download artifacts |
| 132 | + - name: Download all artifacts |
133 | 133 | uses: actions/download-artifact@v4 |
134 | 134 | with: |
135 | | - name: bindings-${{ matrix.target }} |
| 135 | + pattern: bindings-* |
| 136 | + merge-multiple: true |
| 137 | + |
| 138 | + - name: Copy binaries to src for testing |
| 139 | + run: | |
| 140 | + # Copy all .node files found in libs/core to libs/core/src |
| 141 | + echo "Copying all .node binaries to libs/core/src/" |
| 142 | + find "libs/core" -maxdepth 1 -name "*.node" -exec cp {} "libs/core/src/" \; |
| 143 | + |
| 144 | + # Show what was copied |
| 145 | + echo "Files in libs/core/src:" |
| 146 | + find "libs/core/src" -type f -name "*.node" | sort |
| 147 | + shell: bash |
136 | 148 |
|
137 | 149 | - name: Install dependencies |
138 | 150 | run: npm install |
@@ -174,42 +186,116 @@ jobs: |
174 | 186 | pattern: bindings-* |
175 | 187 | merge-multiple: true |
176 | 188 |
|
177 | | - - name: Move artifacts |
| 189 | + - name: Process artifacts and prepare packages |
178 | 190 | run: | |
179 | 191 | echo "Debug: Showing all downloaded artifacts:" |
180 | 192 | find . -type f -name "*.node" -ls |
181 | 193 |
|
182 | | - echo "\nMoving only cel-typescript binaries to root:" |
183 | | - find . -type f -name "cel-typescript.*.node" -exec mv {} . \; |
184 | | -
|
185 | | - echo "\nBinaries in root directory:" |
186 | | - ls -la cel-typescript.*.node |
187 | | -
|
188 | | - # Count our binaries |
189 | | - node_count=$(ls -1 cel-typescript.*.node 2>/dev/null | wc -l) |
190 | | - expected_count=5 # We target 5 platforms |
191 | | -
|
192 | | - echo "\nFound $node_count cel-typescript binaries (expected $expected_count)" |
| 194 | + echo "\nEnsuring binaries exist in their respective package directories:" |
| 195 | + |
| 196 | + # Make sure each package directory has exactly one binary |
| 197 | + # Copy only if not already present in the target directory |
| 198 | + if [ ! -f libs/darwin-arm64/cel-typescript.darwin-arm64.node ]; then |
| 199 | + find . -path "./libs/darwin-arm64" -prune -o -name "cel-typescript.darwin-arm64.node" -exec cp {} libs/darwin-arm64/ \; |
| 200 | + fi |
| 201 | + |
| 202 | + if [ ! -f libs/darwin-x64/cel-typescript.darwin-x64.node ]; then |
| 203 | + find . -path "./libs/darwin-x64" -prune -o -name "cel-typescript.darwin-x64.node" -exec cp {} libs/darwin-x64/ \; |
| 204 | + fi |
| 205 | + |
| 206 | + if [ ! -f libs/linux-x64-gnu/cel-typescript.linux-x64-gnu.node ]; then |
| 207 | + find . -path "./libs/linux-x64-gnu" -prune -o -name "cel-typescript.linux-x64-gnu.node" -exec cp {} libs/linux-x64-gnu/ \; |
| 208 | + fi |
| 209 | + |
| 210 | + if [ ! -f libs/linux-arm64-gnu/cel-typescript.linux-arm64-gnu.node ]; then |
| 211 | + find . -path "./libs/linux-arm64-gnu" -prune -o -name "cel-typescript.linux-arm64-gnu.node" -exec cp {} libs/linux-arm64-gnu/ \; |
| 212 | + fi |
| 213 | + |
| 214 | + if [ ! -f libs/win32-x64-msvc/cel-typescript.win32-x64-msvc.node ]; then |
| 215 | + find . -path "./libs/win32-x64-msvc" -prune -o -name "cel-typescript.win32-x64-msvc.node" -exec cp {} libs/win32-x64-msvc/ \; |
| 216 | + fi |
| 217 | + |
| 218 | + # Verify each package directory has exactly one binary |
| 219 | + darwin_arm64_count=$(find libs/darwin-arm64 -maxdepth 1 -name "cel-typescript.darwin-arm64.node" | wc -l) |
| 220 | + darwin_x64_count=$(find libs/darwin-x64 -maxdepth 1 -name "cel-typescript.darwin-x64.node" | wc -l) |
| 221 | + linux_x64_gnu_count=$(find libs/linux-x64-gnu -maxdepth 1 -name "cel-typescript.linux-x64-gnu.node" | wc -l) |
| 222 | + linux_arm64_gnu_count=$(find libs/linux-arm64-gnu -maxdepth 1 -name "cel-typescript.linux-arm64-gnu.node" | wc -l) |
| 223 | + win32_x64_msvc_count=$(find libs/win32-x64-msvc -maxdepth 1 -name "cel-typescript.win32-x64-msvc.node" | wc -l) |
| 224 | + |
| 225 | + echo "\nVerifying binaries in package directories:" |
| 226 | + echo "darwin-arm64: $darwin_arm64_count" |
| 227 | + echo "darwin-x64: $darwin_x64_count" |
| 228 | + echo "linux-x64-gnu: $linux_x64_gnu_count" |
| 229 | + echo "linux-arm64-gnu: $linux_arm64_gnu_count" |
| 230 | + echo "win32-x64-msvc: $win32_x64_msvc_count" |
193 | 231 | |
194 | | - if [ "$node_count" -ne "$expected_count" ]; then |
195 | | - echo "Error: Expected $expected_count binaries but found $node_count" |
| 232 | + # Error if any platform is missing its binary |
| 233 | + if [ "$darwin_arm64_count" -ne 1 ] || [ "$darwin_x64_count" -ne 1 ] || \ |
| 234 | + [ "$linux_x64_gnu_count" -ne 1 ] || [ "$linux_arm64_gnu_count" -ne 1 ] || \ |
| 235 | + [ "$win32_x64_msvc_count" -ne 1 ]; then |
| 236 | + echo "Error: Each package directory should have exactly one binary" |
196 | 237 | exit 1 |
197 | 238 | fi |
| 239 | + |
| 240 | + # Set version for all packages based on tag |
| 241 | + if [[ "$GITHUB_REF" == refs/tags/v* ]]; then |
| 242 | + VERSION=${GITHUB_REF#refs/tags/v} |
| 243 | + echo "Setting version to $VERSION for all packages" |
| 244 | + |
| 245 | + for pkg in libs/darwin-arm64 libs/darwin-x64 libs/linux-x64-gnu libs/linux-arm64-gnu libs/win32-x64-msvc; do |
| 246 | + jq ".version = \"$VERSION\"" $pkg/package.json > tmp.json && mv tmp.json $pkg/package.json |
| 247 | + done |
| 248 | + |
| 249 | + # Set the core package version too |
| 250 | + jq ".version = \"$VERSION\"" libs/core/package.json > tmp.json && mv tmp.json libs/core/package.json |
| 251 | + |
| 252 | + # Update the optionalDependencies in the core package to use version numbers instead of file paths |
| 253 | + node -e "const pkg = require('./libs/core/package.json'); \ |
| 254 | + if (pkg.optionalDependencies) { \ |
| 255 | + Object.keys(pkg.optionalDependencies).forEach(dep => { \ |
| 256 | + pkg.optionalDependencies[dep] = '$VERSION'; \ |
| 257 | + }); \ |
| 258 | + require('fs').writeFileSync('./libs/core/package.json', JSON.stringify(pkg, null, 2)); \ |
| 259 | + }" |
| 260 | + else |
| 261 | + echo "Not a tag push, skipping version update" |
| 262 | + fi |
198 | 263 |
|
199 | 264 | - name: Build TypeScript |
200 | 265 | run: npm run build:ts |
201 | 266 |
|
202 | | - - name: Verify package contents |
| 267 | + - name: Publish Core Package (Dry Run) |
| 268 | + if: github.event_name == 'pull_request' |
203 | 269 | run: | |
204 | | - echo "Package contents:" |
| 270 | + cd libs/core |
205 | 271 | npm pack --dry-run |
206 | 272 |
|
207 | | - - name: Publish |
| 273 | + - name: Publish Platform Packages (Dry Run) |
| 274 | + if: github.event_name == 'pull_request' |
| 275 | + run: | |
| 276 | + for pkg in darwin-arm64 darwin-x64 linux-x64-gnu linux-arm64-gnu win32-x64-msvc; do |
| 277 | + echo "\n==== Dry run publishing $pkg package ====" |
| 278 | + cd libs/$pkg |
| 279 | + npm pack --dry-run |
| 280 | + cd ../.. |
| 281 | + done |
| 282 | +
|
| 283 | + - name: Publish Core Package |
208 | 284 | if: startsWith(github.ref, 'refs/tags/v') |
209 | | - run: npm publish --provenance --access public |
| 285 | + run: | |
| 286 | + cd libs/core |
| 287 | + npm publish --provenance --access public |
210 | 288 | env: |
211 | 289 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
212 | 290 |
|
213 | | - - name: Publish (Dry Run) |
214 | | - if: github.event_name == 'pull_request' |
215 | | - run: npm publish --dry-run |
| 291 | + - name: Publish Platform Packages |
| 292 | + if: startsWith(github.ref, 'refs/tags/v') |
| 293 | + run: | |
| 294 | + for pkg in darwin-arm64 darwin-x64 linux-x64-gnu linux-arm64-gnu win32-x64-msvc; do |
| 295 | + echo "\n==== Publishing $pkg package ====" |
| 296 | + cd libs/$pkg |
| 297 | + npm publish --provenance --access public |
| 298 | + cd ../.. |
| 299 | + done |
| 300 | + env: |
| 301 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments