publish-prerelease.yml•3.83 kB
name: Publish Pre-release to npm
on:
push:
branches:
- develop
- beta
- alpha
workflow_dispatch:
inputs:
tag:
description: 'Pre-release tag'
required: true
default: 'beta'
type: choice
options:
- alpha
- beta
- rc
jobs:
publish-prerelease:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
ref: ${{ github.ref }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
env:
LETTA_BASE_URL: ${{ secrets.LETTA_BASE_URL || 'https://test.letta.com/v1' }}
LETTA_PASSWORD: ${{ secrets.LETTA_PASSWORD || 'test-password' }}
- name: Check code quality
run: |
npm run lint
npm run format:check
- name: Configure Git
run: |
git config user.name "GitHub Actions Bot"
git config user.email "actions@github.com"
- name: Determine pre-release tag
id: tag
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
else
# Map branch names to tags
case "${{ github.ref_name }}" in
develop) echo "tag=beta" >> $GITHUB_OUTPUT ;;
beta) echo "tag=beta" >> $GITHUB_OUTPUT ;;
alpha) echo "tag=alpha" >> $GITHUB_OUTPUT ;;
*) echo "tag=beta" >> $GITHUB_OUTPUT ;;
esac
fi
- name: Get current version
id: current-version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Generate pre-release version
id: prerelease-version
run: |
CURRENT_VERSION=${{ steps.current-version.outputs.version }}
TAG=${{ steps.tag.outputs.tag }}
TIMESTAMP=$(date +%Y%m%d%H%M%S)
# Create pre-release version (e.g., 1.1.0-beta.20240121120000)
PRERELEASE_VERSION="${CURRENT_VERSION}-${TAG}.${TIMESTAMP}"
echo "version=${PRERELEASE_VERSION}" >> $GITHUB_OUTPUT
# Update package.json with pre-release version
npm version ${PRERELEASE_VERSION} --no-git-tag-version
- name: Build package
run: npm pack
- name: Publish to npm with tag
run: npm publish --tag ${{ steps.tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create pre-release tag
run: |
git add package.json package-lock.json
git commit -m "chore: pre-release ${{ steps.prerelease-version.outputs.version }} [skip ci]"
git tag "v${{ steps.prerelease-version.outputs.version }}"
git push origin ${{ github.ref_name }}
git push origin "v${{ steps.prerelease-version.outputs.version }}"
- name: Notify success
if: success()
run: |
echo "✅ Successfully published pre-release!"
echo "Version: letta-mcp-server@${{ steps.prerelease-version.outputs.version }}"
echo "Tag: ${{ steps.tag.outputs.tag }}"
echo ""
echo "Install with:"
echo "npm install -g letta-mcp-server@${{ steps.tag.outputs.tag }}"
echo ""
echo "View at: https://www.npmjs.com/package/letta-mcp-server/v/${{ steps.prerelease-version.outputs.version }}"