|
79 | 79 | restore-keys: | |
80 | 80 | ${{ runner.os }}-npm- |
81 | 81 | - uses: goto-bus-stop/setup-zig@v2 |
82 | | - if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' || matrix.settings.target == 'armv7-unknown-linux-musleabihf' }} |
| 82 | + if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }} |
83 | 83 | with: |
84 | | - version: 0.13.0 |
| 84 | + version: 0.14.0 |
85 | 85 | - name: Setup toolchain |
86 | 86 | run: ${{ matrix.settings.setup }} |
87 | 87 | if: ${{ matrix.settings.setup }} |
@@ -176,114 +176,89 @@ jobs: |
176 | 176 | run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim npm test |
177 | 177 |
|
178 | 178 | publish: |
179 | | - name: Publish to npm |
| 179 | + name: Publish |
180 | 180 | # Only run on tag pushes or release publish events |
181 | | - if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release' |
182 | 181 | needs: |
183 | 182 | - test-macOS-binding |
184 | 183 | - test-linux-x64-gnu-binding |
185 | 184 | runs-on: ubuntu-latest |
186 | 185 | steps: |
187 | | - - name: Debug release info |
188 | | - run: | |
189 | | - echo "GitHub Ref: ${{ github.ref }}" |
190 | | - echo "Event Name: ${{ github.event_name }}" |
191 | | - echo "Release Tag: ${{ github.event.release.tag_name }}" |
192 | | -
|
193 | 186 | - uses: actions/checkout@v4 |
194 | | - with: |
195 | | - fetch-depth: 0 |
196 | | - |
197 | 187 | - name: Setup node |
198 | 188 | uses: actions/setup-node@v4 |
199 | 189 | with: |
200 | 190 | node-version: 20 |
201 | | - registry-url: 'https://registry.npmjs.org' |
202 | 191 | cache: 'npm' |
203 | | - |
204 | 192 | - name: Install dependencies |
205 | 193 | run: npm install |
206 | | - |
207 | 194 | - name: Download all artifacts |
208 | 195 | uses: actions/download-artifact@v4 |
209 | 196 | with: |
210 | 197 | path: artifacts |
211 | | - |
212 | | - - name: Debug artifact structure |
213 | | - run: | |
214 | | - echo "Artifact directory structure:" |
215 | | - find artifacts -type f | sort |
216 | | -
|
217 | 198 | - name: Create npm directory structure |
218 | 199 | run: | |
219 | 200 | # Create npm directory structure |
220 | 201 | mkdir -p npm/darwin-x64 |
221 | 202 | mkdir -p npm/darwin-arm64 |
222 | 203 | mkdir -p npm/linux-x64-gnu |
223 | | -
|
224 | | - - name: Move artifacts to root |
225 | | - run: | |
226 | | - # Copy artifacts to root for GitHub release |
227 | | - find artifacts -name "*.node" -type f -exec cp {} . \; |
228 | | -
|
229 | | - - name: Run artifacts script |
| 204 | + - name: Move artifacts |
230 | 205 | run: npm run artifacts |
231 | | - |
232 | 206 | - name: List packages |
| 207 | + run: ls -R ./npm |
| 208 | + shell: bash |
| 209 | + - name: Create platform package.json files |
233 | 210 | run: | |
234 | | - echo "Files in npm directories:" |
235 | | - ls -la npm/ || echo "No npm directory" |
236 | | - ls -la npm/*/ || echo "No platform subdirectories" |
237 | | -
|
238 | | - echo "Files in root:" |
239 | | - ls -la *.node || echo "No .node files in root" |
240 | | -
|
241 | | - - name: Verify package version matches release |
242 | | - id: verify_version |
243 | | - run: | |
244 | | - # Determine version from tag or release |
245 | | - if [ "${{ github.event_name }}" == "release" ]; then |
246 | | - TAG_NAME="${{ github.event.release.tag_name }}" |
247 | | - else |
248 | | - TAG_NAME="${{ github.ref_name }}" |
249 | | - fi |
| 211 | + # Determine version from commit message or package.json |
| 212 | + VERSION=$(node -p "require('./package.json').version") |
250 | 213 |
|
251 | | - # Remove 'v' prefix if present |
252 | | - RELEASE_VERSION="${TAG_NAME#v}" |
| 214 | + # Create package.json files in each platform directory |
| 215 | + cat > npm/darwin-x64/package.json << EOF |
| 216 | + { |
| 217 | + "name": "${PACKAGE_NAME}-darwin-x64", |
| 218 | + "version": "${VERSION}", |
| 219 | + "os": ["darwin"], |
| 220 | + "cpu": ["x64"], |
| 221 | + "main": "${APP_NAME}.node", |
| 222 | + "files": ["${APP_NAME}.node"] |
| 223 | + } |
| 224 | + EOF |
253 | 225 |
|
254 | | - # Get current version from package.json |
255 | | - PACKAGE_VERSION=$(node -p "require('./package.json').version") |
| 226 | + cat > npm/darwin-arm64/package.json << EOF |
| 227 | + { |
| 228 | + "name": "${PACKAGE_NAME}-darwin-arm64", |
| 229 | + "version": "${VERSION}", |
| 230 | + "os": ["darwin"], |
| 231 | + "cpu": ["arm64"], |
| 232 | + "main": "${APP_NAME}.node", |
| 233 | + "files": ["${APP_NAME}.node"] |
| 234 | + } |
| 235 | + EOF |
256 | 236 |
|
257 | | - echo "Release version: $RELEASE_VERSION" |
258 | | - echo "Package version: $PACKAGE_VERSION" |
259 | | -
|
260 | | - # Skip version update if already correct |
261 | | - if [ "$RELEASE_VERSION" = "$PACKAGE_VERSION" ]; then |
262 | | - echo "Version already matches, no update needed" |
| 237 | + cat > npm/linux-x64-gnu/package.json << EOF |
| 238 | + { |
| 239 | + "name": "${PACKAGE_NAME}-linux-x64-gnu", |
| 240 | + "version": "${VERSION}", |
| 241 | + "os": ["linux"], |
| 242 | + "cpu": ["x64"], |
| 243 | + "main": "${APP_NAME}.node", |
| 244 | + "files": ["${APP_NAME}.node"] |
| 245 | + } |
| 246 | + EOF |
| 247 | + - name: Publish |
| 248 | + run: | |
| 249 | + npm config set provenance true |
| 250 | + if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; |
| 251 | + then |
| 252 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc |
| 253 | + npm publish --access public |
| 254 | + elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+"; |
| 255 | + then |
| 256 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc |
| 257 | + npm publish --tag next --access public |
263 | 258 | else |
264 | | - echo "Updating version from $PACKAGE_VERSION to $RELEASE_VERSION" |
265 | | - npm version $RELEASE_VERSION --no-git-tag-version |
266 | | -
|
267 | | - # Also update version in platform-specific package.json files |
268 | | - for dir in npm/darwin-x64 npm/darwin-arm64 npm/linux-x64-gnu; do |
269 | | - if [ -f "$dir/package.json" ]; then |
270 | | - node -e "const pkg = require('./$dir/package.json'); pkg.version = '$RELEASE_VERSION'; require('fs').writeFileSync('./$dir/package.json', JSON.stringify(pkg, null, 2));" |
271 | | - fi |
272 | | - done |
| 259 | + echo "Not a release, skipping publish" |
273 | 260 | fi |
274 | | -
|
275 | | - - name: Publish to npm |
276 | | - run: npm publish --access public |
277 | 261 | env: |
278 | | - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
279 | | - |
280 | | - - name: Update release with binaries |
281 | | - uses: softprops/action-gh-release@v1 |
282 | | - with: |
283 | | - files: | |
284 | | - *.node |
285 | | - # If triggered by a tag push, create a release |
286 | | - tag_name: ${{ github.ref_name }} |
287 | | - # Only generate release notes if one doesn't exist |
288 | | - generate_release_notes: ${{ github.event_name != 'release' }} |
| 262 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 263 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
289 | 264 |
|
0 commit comments