forked from MemTensor/MemOS
-
Notifications
You must be signed in to change notification settings - Fork 0
184 lines (160 loc) · 6.42 KB
/
Copy pathopenclaw-plugin-publish.yml
File metadata and controls
184 lines (160 loc) · 6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: OpenClaw Plugin — Build Prebuilds & Publish
on:
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 1.0.4 or 1.0.4-beta.1)"
required: true
tag:
description: "npm dist-tag (latest for production, beta/next/alpha for testing)"
required: true
default: "latest"
git_ref:
description: "Optional Git ref to build/publish (branch, tag, or SHA), e.g. mem-agent-0512. Leave blank to use the branch selected in Run workflow."
required: false
default: ""
concurrency:
group: openclaw-plugin-publish-${{ github.workflow }}-${{ github.repository }}
cancel-in-progress: false
defaults:
run:
working-directory: apps/memos-local-openclaw
permissions:
contents: write
pull-requests: write
jobs:
build-prebuilds:
strategy:
matrix:
include:
- os: macos-14
platform: darwin-arm64
- os: macos-15
platform: darwin-x64
- os: ubuntu-latest
platform: linux-x64
- os: windows-latest
platform: win32-x64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.git_ref != '' && inputs.git_ref || github.ref }}
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: npm install
- name: Rebuild for x64 under Rosetta (darwin-x64 only)
if: matrix.platform == 'darwin-x64'
run: |
arch -x86_64 npm rebuild better-sqlite3
- name: Collect prebuild
shell: bash
run: |
mkdir -p prebuilds/${{ matrix.platform }}
cp node_modules/better-sqlite3/build/Release/better_sqlite3.node prebuilds/${{ matrix.platform }}/
- name: Upload prebuild artifact
uses: actions/upload-artifact@v4
with:
name: prebuild-${{ matrix.platform }}
path: apps/memos-local-openclaw/prebuilds/${{ matrix.platform }}/better_sqlite3.node
publish:
needs: build-prebuilds
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.git_ref != '' && inputs.git_ref || github.ref }}
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- name: Download all prebuilds
uses: actions/download-artifact@v4
with:
path: apps/memos-local-openclaw/prebuilds
pattern: prebuild-*
merge-multiple: false
- name: Organize prebuilds
run: |
cd prebuilds
for dir in prebuild-*; do
platform="${dir#prebuild-}"
mkdir -p "$platform"
mv "$dir/better_sqlite3.node" "$platform/"
rmdir "$dir"
done
echo "Prebuilds collected:"
find . -name "*.node" -exec ls -lh {} \;
- name: Install dependencies (skip native build)
run: npm install --ignore-scripts
- name: Generate telemetry credentials
run: node scripts/generate-telemetry-credentials.cjs
env:
MEMOS_ARMS_ENDPOINT: ${{ secrets.MEMOS_ARMS_ENDPOINT }}
MEMOS_ARMS_PID: ${{ secrets.MEMOS_ARMS_PID }}
MEMOS_ARMS_ENV: ${{ secrets.MEMOS_ARMS_ENV }}
- name: Bump version
# Branch may already have this version in package.json (e.g. after a prior merge); npm errors without this flag.
run: npm version ${{ inputs.version }} --no-git-tag-version --allow-same-version
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
PACKAGE_NAME: "@memtensor/memos-local-openclaw-plugin"
RELEASE_VERSION: ${{ inputs.version }}
NPM_DIST_TAG: ${{ inputs.tag }}
run: |
if npm view "${PACKAGE_NAME}@${RELEASE_VERSION}" version >/dev/null 2>&1; then
echo "${PACKAGE_NAME}@${RELEASE_VERSION} already exists on npm; skipping publish."
else
npm publish --access public --tag "${NPM_DIST_TAG}"
fi
- name: Create release tag and PR
working-directory: .
env:
GH_TOKEN: ${{ github.token }}
RELEASE_VERSION: ${{ inputs.version }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
release_tag="openclaw-plugin-v${RELEASE_VERSION}"
release_branch="release/${release_tag}"
release_title="release: openclaw-plugin v${RELEASE_VERSION}"
git add apps/memos-local-openclaw/package.json
created_release_commit=false
if ! git diff --staged --quiet; then
git commit -m "${release_title}"
created_release_commit=true
fi
if [ "${created_release_commit}" = "true" ]; then
remote_branch_sha="$(git ls-remote --heads origin "${release_branch}" | awk '{print $1}')"
if [ -n "${remote_branch_sha}" ]; then
git push --force-with-lease="refs/heads/${release_branch}:${remote_branch_sha}" origin "HEAD:refs/heads/${release_branch}"
else
git push origin "HEAD:refs/heads/${release_branch}"
fi
fi
if git ls-remote --exit-code --tags origin "refs/tags/${release_tag}" >/dev/null 2>&1; then
echo "Tag ${release_tag} already exists on origin; leaving it unchanged."
else
git tag "${release_tag}"
git push origin "refs/tags/${release_tag}"
fi
if [ "${created_release_commit}" = "true" ]; then
if gh pr view "${release_branch}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then
echo "Release PR already exists for ${release_branch}."
else
gh pr create \
--repo "${GITHUB_REPOSITORY}" \
--base "${DEFAULT_BRANCH}" \
--head "${release_branch}" \
--title "${release_title}" \
--body "Bumps apps/memos-local-openclaw/package.json for the published npm release ${RELEASE_VERSION}." \
|| echo "::warning::Failed to create release PR automatically. Open a PR from ${release_branch} to ${DEFAULT_BRANCH}."
fi
else
echo "No version bump changes to open as a PR."
fi