|
| 1 | +name: OpenClaw Plugin — Build Prebuilds & Publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "Version to publish (e.g. 1.0.4 or 1.0.4-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-openclaw |
| 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-13 |
| 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: Collect prebuild |
| 46 | + shell: bash |
| 47 | + run: | |
| 48 | + mkdir -p prebuilds/${{ matrix.platform }} |
| 49 | + cp node_modules/better-sqlite3/build/Release/better_sqlite3.node prebuilds/${{ matrix.platform }}/ |
| 50 | +
|
| 51 | + - name: Upload prebuild artifact |
| 52 | + uses: actions/upload-artifact@v4 |
| 53 | + with: |
| 54 | + name: prebuild-${{ matrix.platform }} |
| 55 | + path: apps/memos-local-openclaw/prebuilds/${{ matrix.platform }}/better_sqlite3.node |
| 56 | + |
| 57 | + publish: |
| 58 | + needs: build-prebuilds |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v4 |
| 62 | + |
| 63 | + - uses: actions/setup-node@v4 |
| 64 | + with: |
| 65 | + node-version: 22 |
| 66 | + registry-url: https://registry.npmjs.org |
| 67 | + |
| 68 | + - name: Download all prebuilds |
| 69 | + uses: actions/download-artifact@v4 |
| 70 | + with: |
| 71 | + path: apps/memos-local-openclaw/prebuilds |
| 72 | + pattern: prebuild-* |
| 73 | + merge-multiple: false |
| 74 | + |
| 75 | + - name: Organize prebuilds |
| 76 | + run: | |
| 77 | + cd prebuilds |
| 78 | + for dir in prebuild-*; do |
| 79 | + platform="${dir#prebuild-}" |
| 80 | + mkdir -p "$platform" |
| 81 | + mv "$dir/better_sqlite3.node" "$platform/" |
| 82 | + rmdir "$dir" |
| 83 | + done |
| 84 | + echo "Prebuilds collected:" |
| 85 | + find . -name "*.node" -exec ls -lh {} \; |
| 86 | +
|
| 87 | + - name: Install dependencies (skip native build) |
| 88 | + run: npm install --ignore-scripts |
| 89 | + |
| 90 | + - name: Bump version |
| 91 | + run: npm version ${{ inputs.version }} --no-git-tag-version |
| 92 | + |
| 93 | + - name: Publish to npm |
| 94 | + run: npm publish --access public --tag ${{ inputs.tag }} |
| 95 | + env: |
| 96 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 97 | + |
| 98 | + - name: Create git tag and push |
| 99 | + working-directory: . |
| 100 | + run: | |
| 101 | + git config user.name "github-actions[bot]" |
| 102 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 103 | + git add apps/memos-local-openclaw/package.json |
| 104 | + git commit -m "release: openclaw-plugin v${{ inputs.version }}" |
| 105 | + git tag "openclaw-plugin-v${{ inputs.version }}" |
| 106 | + git push origin HEAD --tags |
0 commit comments