|
| 1 | +name: Hermes Plugin — Build Prebuilds & Publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "Version to publish (e.g. 1.0.0 or 1.0.0-beta.1)" |
| 8 | + required: true |
| 9 | + tag: |
| 10 | + description: "npm dist-tag (latest for production, beta/next/alpha for testing)" |
| 11 | + required: true |
| 12 | + default: "latest" |
| 13 | + |
| 14 | +defaults: |
| 15 | + run: |
| 16 | + working-directory: apps/memos-local-plugin |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: write |
| 20 | + |
| 21 | +jobs: |
| 22 | + build-prebuilds: |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + include: |
| 26 | + - os: macos-14 |
| 27 | + platform: darwin-arm64 |
| 28 | + - os: macos-15 |
| 29 | + platform: darwin-x64 |
| 30 | + - os: ubuntu-latest |
| 31 | + platform: linux-x64 |
| 32 | + - os: windows-latest |
| 33 | + platform: win32-x64 |
| 34 | + runs-on: ${{ matrix.os }} |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + |
| 38 | + - uses: actions/setup-node@v4 |
| 39 | + with: |
| 40 | + node-version: 22 |
| 41 | + |
| 42 | + - name: Install dependencies |
| 43 | + run: npm install |
| 44 | + |
| 45 | + - name: Rebuild for x64 under Rosetta (darwin-x64 only) |
| 46 | + if: matrix.platform == 'darwin-x64' |
| 47 | + run: | |
| 48 | + arch -x86_64 npm rebuild better-sqlite3 |
| 49 | +
|
| 50 | + - name: Collect prebuild |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + mkdir -p prebuilds/${{ matrix.platform }} |
| 54 | + cp node_modules/better-sqlite3/build/Release/better_sqlite3.node prebuilds/${{ matrix.platform }}/ |
| 55 | +
|
| 56 | + - name: Upload prebuild artifact |
| 57 | + uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: prebuild-hermes-${{ matrix.platform }} |
| 60 | + path: apps/memos-local-plugin/prebuilds/${{ matrix.platform }}/better_sqlite3.node |
| 61 | + |
| 62 | + publish: |
| 63 | + needs: build-prebuilds |
| 64 | + runs-on: ubuntu-latest |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v4 |
| 67 | + |
| 68 | + - uses: actions/setup-node@v4 |
| 69 | + with: |
| 70 | + node-version: 22 |
| 71 | + registry-url: https://registry.npmjs.org |
| 72 | + |
| 73 | + - name: Download all prebuilds |
| 74 | + uses: actions/download-artifact@v4 |
| 75 | + with: |
| 76 | + path: apps/memos-local-plugin/prebuilds |
| 77 | + pattern: prebuild-hermes-* |
| 78 | + merge-multiple: false |
| 79 | + |
| 80 | + - name: Organize prebuilds |
| 81 | + run: | |
| 82 | + cd prebuilds |
| 83 | + for dir in prebuild-hermes-*; do |
| 84 | + platform="${dir#prebuild-hermes-}" |
| 85 | + mkdir -p "$platform" |
| 86 | + mv "$dir/better_sqlite3.node" "$platform/" |
| 87 | + rmdir "$dir" |
| 88 | + done |
| 89 | + echo "Prebuilds collected:" |
| 90 | + find . -name "*.node" -exec ls -lh {} \; |
| 91 | +
|
| 92 | + - name: Install dependencies (skip native build) |
| 93 | + run: npm install --ignore-scripts |
| 94 | + |
| 95 | + - name: Bump version |
| 96 | + run: npm version ${{ inputs.version }} --no-git-tag-version --allow-same-version |
| 97 | + |
| 98 | + - name: Publish to npm |
| 99 | + run: npm publish --access public --tag ${{ inputs.tag }} |
| 100 | + env: |
| 101 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 102 | + |
| 103 | + - name: Create git tag and push |
| 104 | + working-directory: . |
| 105 | + run: | |
| 106 | + git config user.name "github-actions[bot]" |
| 107 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 108 | + git add apps/memos-local-plugin/package.json |
| 109 | + if ! git diff --staged --quiet; then |
| 110 | + git commit -m "release: hermes-plugin v${{ inputs.version }}" |
| 111 | + fi |
| 112 | + git tag "hermes-plugin-v${{ inputs.version }}" |
| 113 | + git push origin HEAD --tags |
0 commit comments