forked from letta-ai/letta-code
-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (158 loc) · 6.6 KB
/
Copy pathrelease.yml
File metadata and controls
186 lines (158 loc) · 6.6 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
name: Publish release
on:
push:
branches:
- main
paths:
- package.json
- package-lock.json
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
environment: npm-publish
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Detect release bump commit
id: detect
run: |
set -euo pipefail
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "should_publish=true" >> $GITHUB_OUTPUT
echo "subject=manual publish dispatch" >> $GITHUB_OUTPUT
exit 0
fi
SUBJECT=$(git log --format=%s "${{ github.event.before }}..${{ github.sha }}" | grep -E '^chore: bump version to ' | tail -n 1 || true)
if [ -z "$SUBJECT" ]; then
echo "should_publish=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "should_publish=true" >> $GITHUB_OUTPUT
echo "subject=$SUBJECT" >> $GITHUB_OUTPUT
- name: Configure Git
if: steps.detect.outputs.should_publish == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Setup Bun
if: steps.detect.outputs.should_publish == 'true'
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.0
- name: Setup Node (bundled npm 11 for OIDC publishing)
if: steps.detect.outputs.should_publish == 'true'
uses: actions/setup-node@v6
with:
node-version: "24.13.0"
registry-url: "https://registry.npmjs.org"
- name: Derive release metadata
if: steps.detect.outputs.should_publish == 'true'
id: version
run: |
set -euo pipefail
git fetch --tags origin
VERSION=$(jq -r '.version' package.json)
PACKAGE_NAME=$(jq -r '.name' package.json)
TAG="v$VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "package_name=$PACKAGE_NAME" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
if [[ "$VERSION" == *-* ]]; then
PRERELEASE_LABEL=$(echo "$VERSION" | sed -E 's/^[0-9]+\.[0-9]+\.[0-9]+-([^.]+)(\..*)?$/\1/')
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "npm_tag=$PRERELEASE_LABEL" >> $GITHUB_OUTPUT
echo "previous_tag=" >> $GITHUB_OUTPUT
else
PREVIOUS_TAG=$(
curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
"https://api.github.com/repos/${{ github.repository }}/releases?per_page=100" \
| jq -r --arg tag "$TAG" '
map(select(.draft == false and .prerelease == false and .tag_name != $tag))
| sort_by(.published_at // .created_at)
| last
| .tag_name // empty
' || true
)
if [ -z "$PREVIOUS_TAG" ]; then
PREVIOUS_TAG=$(
git tag --sort=-version:refname \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
| grep -Fxv "$TAG" \
| head -n 1 || true
)
fi
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "npm_tag=latest" >> $GITHUB_OUTPUT
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
fi
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "tag_exists=true" >> $GITHUB_OUTPUT
else
echo "tag_exists=false" >> $GITHUB_OUTPUT
fi
if npm view "$PACKAGE_NAME@$VERSION" version >/dev/null 2>&1; then
echo "npm_published=true" >> $GITHUB_OUTPUT
else
echo "npm_published=false" >> $GITHUB_OUTPUT
fi
- name: Install dependencies
if: steps.detect.outputs.should_publish == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bun install
- name: Lint & Type Check
if: steps.detect.outputs.should_publish == 'true'
run: bun run check
- name: Build bundle
if: steps.detect.outputs.should_publish == 'true'
run: bun run build
- name: Smoke test - help
if: steps.detect.outputs.should_publish == 'true'
run: ./letta.js --help
- name: Smoke test - version
if: steps.detect.outputs.should_publish == 'true'
run: ./letta.js --version || echo "Version flag not implemented yet"
- name: Integration smoke test (real API)
if: steps.detect.outputs.should_publish == 'true'
env:
LETTA_API_KEY: ${{ secrets.LETTA_API_KEY }}
run: ./letta.js --prompt "ping" --tools "" --permission-mode plan
- name: Create release tag on merged main commit
if: steps.detect.outputs.should_publish == 'true' && steps.version.outputs.tag_exists != 'true'
run: |
git tag "${{ steps.version.outputs.tag }}" "${{ github.sha }}"
git push origin "${{ steps.version.outputs.tag }}"
- name: Publish to npm
if: steps.detect.outputs.should_publish == 'true' && steps.version.outputs.npm_published != 'true'
run: npm publish --access public --tag ${{ steps.version.outputs.npm_tag }}
- name: Create GitHub Release
if: steps.detect.outputs.should_publish == 'true' && steps.version.outputs.is_prerelease == 'false' && steps.version.outputs.previous_tag != ''
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
target_commitish: ${{ github.sha }}
name: Release ${{ steps.version.outputs.tag }}
previous_tag: ${{ steps.version.outputs.previous_tag }}
generate_release_notes: true
files: letta.js
fail_on_unmatched_files: true
- name: Create GitHub Release (no previous tag)
if: steps.detect.outputs.should_publish == 'true' && steps.version.outputs.is_prerelease == 'false' && steps.version.outputs.previous_tag == ''
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
target_commitish: ${{ github.sha }}
name: Release ${{ steps.version.outputs.tag }}
generate_release_notes: true
files: letta.js
fail_on_unmatched_files: true