Auto-update @letta-ai/letta-client #3270
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto-update @letta-ai/letta-client | |
| on: | |
| schedule: | |
| - cron: '0 * * * *' # Run every hour | |
| workflow_dispatch: # Allow manual trigger | |
| push: | |
| paths: | |
| - '.github/workflows/auto-update-letta-client.yml' | |
| pull_request: | |
| paths: | |
| - '.github/workflows/auto-update-letta-client.yml' | |
| jobs: | |
| check-and-update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Get current letta-client version | |
| id: current-version | |
| run: | | |
| CURRENT_VERSION=$(npm list @letta-ai/letta-client --depth=0 --json | jq -r '.dependencies["@letta-ai/letta-client"].version') | |
| echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "Current @letta-ai/letta-client version: $CURRENT_VERSION" | |
| - name: Get latest letta-client version | |
| id: latest-version | |
| run: | | |
| LATEST_VERSION=$(npm view @letta-ai/letta-client version) | |
| echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT | |
| echo "Latest @letta-ai/letta-client version: $LATEST_VERSION" | |
| - name: Compare versions and update if needed | |
| id: update-check | |
| run: | | |
| if [ "${{ steps.current-version.outputs.current }}" != "${{ steps.latest-version.outputs.latest }}" ]; then | |
| echo "Version mismatch detected. Updating..." | |
| echo "needs_update=true" >> $GITHUB_OUTPUT | |
| # Update the dependency | |
| npm install @letta-ai/letta-client@${{ steps.latest-version.outputs.latest }} | |
| # Bump SDK version (patch) | |
| npm version patch --no-git-tag-version | |
| NEW_SDK_VERSION=$(node -p "require('./package.json').version") | |
| echo "new_sdk_version=$NEW_SDK_VERSION" >> $GITHUB_OUTPUT | |
| echo "Updated SDK version to: $NEW_SDK_VERSION" | |
| else | |
| echo "Versions match. No update needed." | |
| echo "needs_update=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Run tests | |
| if: steps.update-check.outputs.needs_update == 'true' | |
| run: | | |
| npm run build | |
| npm run test | |
| env: | |
| LETTA_API_KEY: ${{ secrets.LETTA_API_KEY }} | |
| PROJECT_ID: ${{ secrets.PROJECT_ID }} | |
| - name: Commit changes | |
| if: steps.update-check.outputs.needs_update == 'true' | |
| run: | | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Action" | |
| git add package.json package-lock.json | |
| git commit -m "chore: update @letta-ai/letta-client to ${{ steps.latest-version.outputs.latest }} and bump SDK to ${{ steps.update-check.outputs.new_sdk_version }} | |
| 🤖 Automatically updated @letta-ai/letta-client version" | |
| npm version patch | |
| - name: Push changes | |
| if: steps.update-check.outputs.needs_update == 'true' && github.ref == 'refs/heads/main' | |
| run: | | |
| git push origin HEAD:main | |
| - name: Run release workflow | |
| if: steps.update-check.outputs.needs_update == 'true' && github.ref == 'refs/heads/main' | |
| run: | | |
| gh workflow run release.yml --ref main --field version=${{ steps.latest-version.outputs.latest }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create summary | |
| run: | | |
| if [ "${{ steps.update-check.outputs.needs_update }}" == "true" ]; then | |
| echo "## ✅ Update Completed" >> $GITHUB_STEP_SUMMARY | |
| echo "- Updated @letta-ai/letta-client from ${{ steps.current-version.outputs.current }} to ${{ steps.latest-version.outputs.latest }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- Bumped SDK version to ${{ steps.update-check.outputs.new_sdk_version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- Release workflow will trigger automatically from push to main" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "## ℹ️ No Update Needed" >> $GITHUB_STEP_SUMMARY | |
| echo "- Current version ${{ steps.current-version.outputs.current }} is already the latest" >> $GITHUB_STEP_SUMMARY | |
| fi |