This repository was archived by the owner on Aug 7, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
282 lines (251 loc) · 10.3 KB
/
Copy pathrelease-please.yml
File metadata and controls
282 lines (251 loc) · 10.3 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
name: Release
on:
push:
branches: [main]
permissions:
contents: write
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.check.outputs.should_release }}
version: ${{ steps.check.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if version changed
id: check
run: |
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
# Get latest tag
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
LATEST_VERSION=${LATEST_TAG#v}
echo "Current version: $VERSION"
echo "Latest tag: $LATEST_TAG (version: $LATEST_VERSION)"
if [ "$VERSION" != "$LATEST_VERSION" ]; then
# Verify this is a newer version (not older)
# sort -V -C returns 0 if input is sorted; if [old, new] is sorted, new IS newer
printf '%s\n%s\n' "$LATEST_VERSION" "$VERSION" | sort -V -C && IS_NEWER=true || IS_NEWER=false
if [ "$IS_NEWER" = "true" ] || [ "$LATEST_VERSION" = "0.0.0" ]; then
echo "should_release=true" >> $GITHUB_OUTPUT
echo "New version detected, will release $VERSION"
else
echo "should_release=false" >> $GITHUB_OUTPUT
echo "Version $VERSION is not newer than $LATEST_VERSION, skipping release"
fi
else
echo "should_release=false" >> $GITHUB_OUTPUT
echo "Version unchanged, skipping release"
fi
release:
needs: check-version
if: needs.check-version.outputs.should_release == 'true'
runs-on: ubuntu-latest
outputs:
version: ${{ needs.check-version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Create and push tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ needs.check-version.outputs.version }}" -m "Release v${{ needs.check-version.outputs.version }}"
git push origin "v${{ needs.check-version.outputs.version }}"
build:
needs: [check-version, release]
if: needs.check-version.outputs.should_release == 'true'
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
asset_name: lambda-cli-x86_64-unknown-linux-gnu
npm_os: linux
npm_arch: x64
- os: macos-latest
target: x86_64-apple-darwin
asset_name: lambda-cli-x86_64-apple-darwin
npm_os: darwin
npm_arch: x64
- os: macos-latest
target: aarch64-apple-darwin
asset_name: lambda-cli-aarch64-apple-darwin
npm_os: darwin
npm_arch: arm64
- os: windows-latest
target: x86_64-pc-windows-msvc
asset_name: lambda-cli-x86_64-pc-windows-msvc
npm_os: win32
npm_arch: x64
steps:
- uses: actions/checkout@v4
with:
ref: v${{ needs.check-version.outputs.version }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build release
run: cargo build --release --target ${{ matrix.target }}
- name: Create tarball (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar -czvf ../../../${{ matrix.asset_name }}.tar.gz lambda lambda-mcp
- name: Create tarball (Windows)
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../${{ matrix.asset_name }}.zip lambda.exe lambda-mcp.exe
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: ${{ matrix.asset_name }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}
- name: Create npm platform package
run: |
mkdir -p npm-pkg/bin
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp target/${{ matrix.target }}/release/lambda-mcp.exe npm-pkg/bin/
else
cp target/${{ matrix.target }}/release/lambda-mcp npm-pkg/bin/
chmod +x npm-pkg/bin/lambda-mcp
fi
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cat > npm-pkg/package.json << EOF
{
"name": "@strand-ai/lambda-mcp-${{ matrix.npm_os }}-${{ matrix.npm_arch }}",
"version": "${{ needs.check-version.outputs.version }}",
"description": "Platform-specific binary for lambda-mcp (${{ matrix.npm_os }}-${{ matrix.npm_arch }})",
"os": ["${{ matrix.npm_os }}"],
"cpu": ["${{ matrix.npm_arch }}"],
"repository": { "type": "git", "url": "https://github.com/Strand-AI/lambda-cli" },
"license": "MIT"
}
EOF
else
cat > npm-pkg/package.json << EOF
{
"name": "@strand-ai/lambda-mcp-${{ matrix.npm_os }}-${{ matrix.npm_arch }}",
"version": "${{ needs.check-version.outputs.version }}",
"description": "Platform-specific binary for lambda-mcp (${{ matrix.npm_os }}-${{ matrix.npm_arch }})",
"os": ["${{ matrix.npm_os }}"],
"cpu": ["${{ matrix.npm_arch }}"],
"repository": { "type": "git", "url": "https://github.com/Strand-AI/lambda-cli" },
"license": "MIT",
"scripts": { "postinstall": "chmod +x bin/lambda-mcp 2>/dev/null || true" }
}
EOF
fi
shell: bash
- name: Upload npm package artifact
uses: actions/upload-artifact@v4
with:
name: npm-lambda-mcp-${{ matrix.npm_os }}-${{ matrix.npm_arch }}
path: npm-pkg/
publish:
needs: [check-version, release, build]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.check-version.outputs.version }}
files: |
artifacts/**/*.tar.gz
artifacts/**/*.zip
generate_release_notes: true
update-homebrew:
needs: [check-version, release, publish]
runs-on: ubuntu-latest
steps:
- name: Compute SHA256
id: sha256
run: |
TARBALL_URL="https://github.com/${{ github.repository }}/archive/refs/tags/v${{ needs.check-version.outputs.version }}.tar.gz"
SHA256=$(curl -sL "$TARBALL_URL" | sha256sum | cut -d' ' -f1)
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
- name: Checkout homebrew-tap
uses: actions/checkout@v4
with:
repository: Strand-AI/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: homebrew-tap
- name: Update formula
run: |
cat > homebrew-tap/Formula/lambda-cli.rb << 'EOF'
class LambdaCli < Formula
desc "Unofficial CLI and MCP server for Lambda cloud GPU instances"
homepage "https://github.com/Strand-AI/lambda-cli"
url "https://github.com/Strand-AI/lambda-cli/archive/refs/tags/v${{ needs.check-version.outputs.version }}.tar.gz"
sha256 "${{ steps.sha256.outputs.sha256 }}"
license "MIT"
head "https://github.com/Strand-AI/lambda-cli.git", branch: "main"
depends_on "rust" => :build
def install
system "cargo", "build", "--release"
bin.install "target/release/lambda"
bin.install "target/release/lambda-mcp"
end
test do
assert_match "lambda", shell_output("#{bin}/lambda --version")
end
end
EOF
- name: Commit and push
run: |
cd homebrew-tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/lambda-cli.rb
git commit -m "lambda-cli: update to ${{ needs.check-version.outputs.version }}"
git push
publish-npm:
needs: [check-version, release, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: v${{ needs.check-version.outputs.version }}
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Download npm package artifacts
uses: actions/download-artifact@v4
with:
pattern: npm-lambda-mcp-*
path: npm-packages
- name: Publish platform packages
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
for pkg_dir in npm-packages/npm-lambda-mcp-*/; do
echo "Publishing $pkg_dir"
cd "$pkg_dir"
npm publish --access public
cd -
done
- name: Prepare and publish main package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd npm/lambda-mcp
# Update version in package.json
sed -i 's/"version": "0.0.0"/"version": "${{ needs.check-version.outputs.version }}"/' package.json
# Update optional dependency versions
sed -i 's/"@strand-ai\/lambda-mcp-linux-x64": "0.0.0"/"@strand-ai\/lambda-mcp-linux-x64": "${{ needs.check-version.outputs.version }}"/' package.json
sed -i 's/"@strand-ai\/lambda-mcp-darwin-x64": "0.0.0"/"@strand-ai\/lambda-mcp-darwin-x64": "${{ needs.check-version.outputs.version }}"/' package.json
sed -i 's/"@strand-ai\/lambda-mcp-darwin-arm64": "0.0.0"/"@strand-ai\/lambda-mcp-darwin-arm64": "${{ needs.check-version.outputs.version }}"/' package.json
sed -i 's/"@strand-ai\/lambda-mcp-win32-x64": "0.0.0"/"@strand-ai\/lambda-mcp-win32-x64": "${{ needs.check-version.outputs.version }}"/' package.json
npm install
npm run build
npm publish --access public