Files
mcp-use__mcp-use/.github/workflows/railway-deploy.yml
Enrico Toniato ed0fadbb01 Canary (#1200)
* Fix/move-zod-to-peer (#1198)

* chore: update pnpm-lock.yaml and package.json to include zod dependency in mcp-use package and test_app configuration

* feat(cli): implement TypeScript file collection and transpilation with esbuild

- Added `collectTsFiles` function to gather TypeScript files based on tsconfig patterns using Node.js built-ins.
- Introduced `transpileWithEsbuild` function to handle TypeScript transpilation, improving performance and memory usage.
- Updated build command to utilize esbuild for transpilation and added an option to skip TypeScript type checking with `--no-typecheck`.

* chore: enter canary prerelease mode

* chore(typescript): version packages (canary)

* chore: update package dependencies in TypeScript libraries (#1199)

* chore: update package dependencies in TypeScript libraries

- Bump `qs` version from `>=6.14.1` to `>=6.14.2`.
- Add new dependencies: `flatted`, `tar`, `hono`, `@hono/node-server`, `express-rate-limit`, `dompurify`, `minimatch`, `rollup`, `@modelcontextprotocol/sdk`, `ai`, `ajv`, `axios`, `body-parser`, `brace-expansion`, `@isaacs/brace-expansion`, `form-data`, `lodash`, and `@eslint/plugin-kit`.
- Update `tar` version from `^7.5.9` to `^7.5.11` in multiple packages.
- Update `hono` version from `^4.11.10` to `^4.12.7` in relevant packages.
- Update `@modelcontextprotocol/sdk` version from `^1.26.0` to `^1.27.1` in relevant packages.
- Update `express-rate-limit` version from `^7.4.1` to `>=8.2.2` in the example server feature.

* chore: remove ajv dependency from TypeScript libraries

- Removed `ajv` dependency from `package.json` and `pnpm-lock.yaml`.
- Updated peer dependencies for `ajv-formats` to use `^8.0.0` instead of `>=8.18.0`.
- Added new dependencies: `fast-json-stable-stringify`, `json-schema-traverse`, and `uri-js` with their respective versions.

* fix: ensure widget parameter is non-null in setupWidgetRoutes

- Updated the widget parameter retrieval in setupWidgetRoutes to use a non-null assertion, ensuring that the widget variable is always defined when serving static assets and widget index.html files.

* chore(typescript): version packages (canary)

* fix(typescript): use file:// URL in tsImport to fix Windows crash (#1193)

* fix(typescript): use file:// URL in tsImport to fix Windows crash

The tsImport call was passing serverFilePath (raw OS path) instead of
serverFileUrl (file:// URL), causing ERR_UNSUPPORTED_ESM_URL_SCHEME on Windows.

Fixes #1171

* fix(typescript): also fix file:// URL in generate-types and add Windows CI

The original fix addressed tsImport in the dev command but missed the
same bug in generateToolRegistryTypesForServer (used by generate-types
and postinstall). Also adds Windows to the CLI test matrix so
platform-specific path issues are caught in CI.

* fix(typescript): fix Windows path separator issues in CLI tests

- display-package-versions: use path.join instead of hardcoded forward-slash path
- tsx-resolution: use path.join in assertions to handle backslash separators
- cli-integration: skip when dist/index.cjs build artifact is missing

---------

Co-authored-by: Enrico Toniato <2827496+tonxxd@users.noreply.github.com>

* chore(typescript): version packages (canary)

* fix(workflows): enhance environment variable usage in GitHub Actions

- Updated multiple workflow files to use environment variables for better readability and maintainability.
- Replaced direct references to GitHub context variables with environment variables in `claude.yml`, `conformance.yml`, `create-app-e2e-canary.yml`, `railway-deploy.yml`, and `typescript-pr-preview.yml`.
- Improved conditional checks in scripts to utilize these environment variables, streamlining the workflow logic.

* refactor(tests): format playwrightArgs for better readability

- Reformatted the addition of `--grep-invert` arguments in the run-test-matrix script to improve code clarity and maintainability.

* refactor(cli, mcp-use): update type generation functions to return success status (#1201)

- Modified `generateToolRegistryTypesForServer` and `generateToolRegistryTypes` to return a boolean indicating success or failure instead of void.
- Updated CLI commands to handle and log success or error messages based on the type generation outcome.
- Enhanced error handling in type generation to prevent server crashes while providing feedback on failures.

* chore(typescript): version packages (canary)

* chore(docs): update changelog for v0.24.5 and v1.21.5 releases

- Added entries for v0.24.5, detailing dependency updates and fixes for security alerts.
- Included v1.21.5 changes, highlighting Zod peer dependency adjustments, esbuild transpilation improvements, and Windows path handling fixes.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: guoyangzhen <upgyz@qq.com>
2026-03-17 13:06:26 +01:00

194 lines
7.9 KiB
YAML

name: Railway Deploy
on:
workflow_run:
workflows: ["TypeScript Release"]
types:
- completed
workflow_dispatch:
inputs:
branch:
description: 'Branch to deploy from (canary or main)'
required: true
type: choice
options:
- canary
- main
jobs:
deploy:
name: Deploy to Railway
runs-on: ubuntu-latest
# For workflow_run: only run if the release workflow completed successfully
# For workflow_dispatch: always run
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
permissions:
actions: read
steps:
- name: Determine branch (manual trigger)
if: github.event_name == 'workflow_dispatch'
id: branch-info
env:
INPUT_BRANCH: ${{ github.event.inputs.branch }}
run: |
BRANCH="$INPUT_BRANCH"
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
echo "packages_published=true" >> $GITHUB_OUTPUT
echo "✅ Manual deployment triggered for branch: $BRANCH"
- name: Validate workflow run source (automatic trigger)
if: github.event_name == 'workflow_run'
uses: actions/github-script@v7
id: validate-source
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
// Validate that the workflow_run is from the same repository (not a fork)
const workflowRun = context.payload.workflow_run;
const isSameRepo = workflowRun.repository.full_name === `${context.repo.owner}/${context.repo.repo}`;
if (!isSameRepo) {
core.setFailed(`❌ Security: Workflow run is from a different repository (${workflowRun.repository.full_name}). Only runs from ${context.repo.owner}/${context.repo.repo} are allowed.`);
return;
}
core.info(`✅ Workflow run validated: ${workflowRun.repository.full_name}`);
core.setOutput('is_valid', 'true');
- name: Check for deployment marker (automatic trigger)
if: github.event_name == 'workflow_run' && steps.validate-source.outputs.is_valid == 'true'
uses: actions/github-script@v7
id: check-marker
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const { data: artifacts } = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
const marker = artifacts.artifacts.find(a => a.name === 'railway-deploy-marker');
if (!marker) {
core.setOutput('packages_published', 'false');
core.info('⚠️ No deployment marker found - packages were not published, skipping deployment');
return;
}
core.setOutput('packages_published', 'true');
core.setOutput('artifact_id', marker.id);
core.info('✅ Deployment marker found - packages were published');
- name: Download and parse marker file (automatic trigger)
if: github.event_name == 'workflow_run' && steps.check-marker.outputs.packages_published == 'true'
uses: actions/github-script@v7
id: marker-info
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ARTIFACT_ID: ${{ steps.check-marker.outputs.artifact_id }}
with:
script: |
const { data: download } = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: parseInt(process.env.ARTIFACT_ID),
archive_format: 'zip',
});
const fs = require('fs');
const { execSync } = require('child_process');
const path = require('path');
// Save zip file
const zipPath = path.join(process.env.RUNNER_TEMP, 'marker.zip');
fs.writeFileSync(zipPath, Buffer.from(download));
// Extract zip using unzip command
const extractPath = path.join(process.env.RUNNER_TEMP, 'marker');
fs.mkdirSync(extractPath, { recursive: true });
execSync(`unzip -q "${zipPath}" -d "${extractPath}"`);
// Read marker file
const markerPath = path.join(extractPath, '.railway-deploy-marker');
const markerContent = fs.readFileSync(markerPath, 'utf8');
// Parse branch from marker
const branchMatch = markerContent.match(/branch=(.+)/);
const branch = branchMatch ? branchMatch[1].trim() : null;
core.setOutput('branch', branch);
core.info(`📦 Branch from marker: ${branch}`);
- name: Determine Service ID
id: config
if: |
(github.event_name == 'workflow_dispatch') ||
(github.event_name == 'workflow_run' && steps.validate-source.outputs.is_valid == 'true' && steps.check-marker.outputs.packages_published == 'true')
env:
EVENT_NAME: ${{ github.event_name }}
BRANCH_INFO_BRANCH: ${{ steps.branch-info.outputs.branch }}
MARKER_INFO_BRANCH: ${{ steps.marker-info.outputs.branch }}
run: |
# Get branch from either manual trigger or automatic trigger
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
BRANCH="$BRANCH_INFO_BRANCH"
else
BRANCH="$MARKER_INFO_BRANCH"
fi
if [ "$BRANCH" = "canary" ]; then
echo "service_id=${{ secrets.RAILWAY_SERVICE_ID_CANARY }}" >> $GITHUB_OUTPUT
echo "environment=canary" >> $GITHUB_OUTPUT
ENVIRONMENT="canary"
elif [ "$BRANCH" = "main" ]; then
echo "service_id=${{ secrets.RAILWAY_SERVICE_ID_PROD }}" >> $GITHUB_OUTPUT
echo "environment=production" >> $GITHUB_OUTPUT
ENVIRONMENT="production"
else
echo "⚠️ Unknown branch: $BRANCH, skipping deployment"
echo "should_deploy=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "should_deploy=true" >> $GITHUB_OUTPUT
echo "✅ Will deploy to $ENVIRONMENT (branch: $BRANCH)"
- name: Checkout Repo
if: steps.config.outputs.should_deploy == 'true'
uses: actions/checkout@v4
with:
# For manual trigger: use input branch (already validated as canary/main)
# For automatic trigger: use branch from validated marker (not workflow_run.head_branch for security)
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || steps.marker-info.outputs.branch }}
fetch-depth: 0
- name: Deploy to Railway
if: steps.config.outputs.should_deploy == 'true'
env:
SERVICE_ID: ${{ steps.config.outputs.service_id }}
ENVIRONMENT: ${{ steps.config.outputs.environment }}
EVENT_NAME: ${{ github.event_name }}
INPUT_BRANCH: ${{ github.event.inputs.branch }}
run: |
if [ -z "$SERVICE_ID" ]; then
echo "⚠️ Service ID not configured for $ENVIRONMENT, skipping deployment"
exit 0
fi
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
echo "🚀 Manually deploying to Railway ($ENVIRONMENT) from latest commit on $INPUT_BRANCH..."
else
echo "🚀 Deploying to Railway ($ENVIRONMENT) after package publish..."
fi
docker run --rm \
-e RAILWAY_TOKEN="${{ secrets.RAILWAY_TOKEN }}" \
-v "$PWD:/workspace" \
-w /workspace \
ghcr.io/railwayapp/cli:latest \
railway up --service=$SERVICE_ID
echo "✅ Successfully deployed to Railway"