release.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. name: Release
  2. # Manually triggered ("Run workflow"). Builds a self-contained bundle for each
  3. # platform on its own runner (no cross-compile), publishes a GitHub Release with
  4. # all archives, and publishes the npm thin-installer (shim + per-platform
  5. # packages). Bump package.json + finalize the CHANGELOG before triggering.
  6. on:
  7. workflow_dispatch:
  8. inputs:
  9. version:
  10. description: "Version to release (default: package.json version)"
  11. required: false
  12. type: string
  13. publish_npm:
  14. description: "Publish to npm"
  15. required: false
  16. type: boolean
  17. default: true
  18. permissions:
  19. contents: write # create the GitHub Release + tag
  20. jobs:
  21. build:
  22. name: Build ${{ matrix.target }}
  23. runs-on: ${{ matrix.os }}
  24. strategy:
  25. fail-fast: false
  26. matrix:
  27. include:
  28. - { target: darwin-arm64, os: macos-14 }
  29. - { target: darwin-x64, os: macos-13 }
  30. - { target: linux-x64, os: ubuntu-latest }
  31. - { target: linux-arm64, os: ubuntu-24.04-arm }
  32. # Windows (win32-x64 / win32-arm64): TODO — build-bundle.sh is unix-only.
  33. steps:
  34. - uses: actions/checkout@v4
  35. - uses: actions/setup-node@v4
  36. with:
  37. node-version: 22
  38. - run: npm ci
  39. - name: Build bundle
  40. run: bash scripts/build-bundle.sh ${{ matrix.target }}
  41. - uses: actions/upload-artifact@v4
  42. with:
  43. name: bundle-${{ matrix.target }}
  44. path: release/codegraph-${{ matrix.target }}.tar.gz
  45. if-no-files-found: error
  46. release:
  47. name: Publish release
  48. needs: build
  49. runs-on: ubuntu-latest
  50. steps:
  51. - uses: actions/checkout@v4
  52. - uses: actions/setup-node@v4
  53. with:
  54. node-version: 22
  55. registry-url: https://registry.npmjs.org
  56. - run: npm ci
  57. - name: Resolve version
  58. id: ver
  59. run: |
  60. V="${{ inputs.version }}"
  61. [ -n "$V" ] || V="$(node -p "require('./package.json').version")"
  62. echo "version=$V" >> "$GITHUB_OUTPUT"
  63. - name: Collect bundles
  64. uses: actions/download-artifact@v4
  65. with:
  66. path: artifacts
  67. pattern: bundle-*
  68. merge-multiple: true
  69. - run: mkdir -p release && cp artifacts/*.tar.gz release/ && ls -lh release
  70. - name: Release notes
  71. id: notes
  72. run: |
  73. if node scripts/extract-release-notes.mjs "${{ steps.ver.outputs.version }}" > /tmp/notes.md 2>/dev/null && [ -s /tmp/notes.md ]; then
  74. echo "file=/tmp/notes.md" >> "$GITHUB_OUTPUT"
  75. fi
  76. - name: Create GitHub Release
  77. env:
  78. GH_TOKEN: ${{ github.token }}
  79. run: |
  80. TAG="v${{ steps.ver.outputs.version }}"
  81. if [ -n "${{ steps.notes.outputs.file }}" ]; then
  82. gh release create "$TAG" release/*.tar.gz --title "$TAG" --notes-file "${{ steps.notes.outputs.file }}"
  83. else
  84. gh release create "$TAG" release/*.tar.gz --title "$TAG" --generate-notes
  85. fi
  86. - name: Publish to npm
  87. if: ${{ inputs.publish_npm }}
  88. env:
  89. NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
  90. run: |
  91. bash scripts/pack-npm.sh "${{ steps.ver.outputs.version }}"
  92. # Platform packages first, then the main shim (which depends on them).
  93. for dir in release/npm/codegraph-* release/npm/main; do
  94. echo "publishing $dir"
  95. ( cd "$dir" && npm publish --access public )
  96. done