release.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. name: Release
  2. # Manually triggered ("Run workflow"). On trigger it:
  3. # 1. reads the version from package.json,
  4. # 2. builds a self-contained bundle for every platform (one runner — there's no
  5. # native compilation, so cross-packaging is fine),
  6. # 3. creates the GitHub Release (tag v<version>) with all archives, using the
  7. # release notes from CHANGELOG.md,
  8. # 4. publishes the npm thin-installer (shim + per-platform packages).
  9. #
  10. # Before triggering: bump package.json and make sure CHANGELOG.md has the matching
  11. # section (## [<version>], or ## [Unreleased]). Set the NPM_TOKEN repo secret.
  12. on:
  13. workflow_dispatch: {}
  14. permissions:
  15. contents: write # create the GitHub Release + tag
  16. jobs:
  17. release:
  18. runs-on: ubuntu-latest
  19. steps:
  20. - uses: actions/checkout@v4
  21. - uses: actions/setup-node@v4
  22. with:
  23. node-version: 22
  24. registry-url: https://registry.npmjs.org
  25. - run: npm ci
  26. - name: Ensure zip/unzip
  27. run: sudo apt-get update -qq && sudo apt-get install -y -qq zip unzip
  28. - name: Build all platform bundles
  29. run: |
  30. for t in darwin-arm64 darwin-x64 linux-x64 linux-arm64 win32-x64 win32-arm64; do
  31. bash scripts/build-bundle.sh "$t"
  32. done
  33. ls -lh release
  34. - name: Resolve version
  35. id: ver
  36. run: echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
  37. - name: Release notes from CHANGELOG.md
  38. run: |
  39. V="${{ steps.ver.outputs.version }}"
  40. node scripts/extract-release-notes.mjs "$V" > notes.md 2>/dev/null \
  41. || node scripts/extract-release-notes.mjs Unreleased > notes.md 2>/dev/null || true
  42. if [ ! -s notes.md ]; then
  43. echo "::error::No release notes in CHANGELOG.md for [$V] or [Unreleased]."
  44. exit 1
  45. fi
  46. echo "----- release notes -----"; cat notes.md
  47. - name: Create GitHub Release
  48. env:
  49. GH_TOKEN: ${{ github.token }}
  50. run: |
  51. gh release create "v${{ steps.ver.outputs.version }}" \
  52. release/codegraph-* \
  53. --title "v${{ steps.ver.outputs.version }}" \
  54. --notes-file notes.md
  55. - name: Publish to npm
  56. env:
  57. NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
  58. run: |
  59. bash scripts/pack-npm.sh "${{ steps.ver.outputs.version }}"
  60. # Platform packages first, then the main shim (which depends on them).
  61. for dir in release/npm/codegraph-* release/npm/main; do
  62. echo "publishing $dir"
  63. ( cd "$dir" && npm publish --access public )
  64. done