Skip to content

Publish vv0.3.3

Publish vv0.3.3 #23

Workflow file for this run

name: Build & Publish SDKs
run-name: "Publish v${{ inputs.version || github.ref_name }}"
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 0.1.0)'
required: true
type: string
publish_typescript:
description: 'Publish TypeScript client to npm'
required: false
type: boolean
default: true
publish_python:
description: 'Publish Python SDK to PyPI'
required: false
type: boolean
default: true
publish_mcp:
description: 'Publish MCP server to npm'
required: false
type: boolean
default: true
env:
NODE_VERSION: '20'
PYTHON_VERSION: '3.11'
PNPM_VERSION: '8'
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
publish_ts: ${{ steps.flags.outputs.publish_ts }}
publish_py: ${{ steps.flags.outputs.publish_py }}
publish_mcp: ${{ steps.flags.outputs.publish_mcp }}
steps:
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ inputs.version }}"
else
# Extract version from tag (remove 'v' prefix)
VERSION="${GITHUB_REF#refs/tags/v}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
echo "Publishing version: $VERSION"
- name: Determine publish flags
id: flags
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "publish_ts=${{ inputs.publish_typescript }}" >> $GITHUB_OUTPUT
echo "publish_py=${{ inputs.publish_python }}" >> $GITHUB_OUTPUT
echo "publish_mcp=${{ inputs.publish_mcp }}" >> $GITHUB_OUTPUT
else
echo "publish_ts=true" >> $GITHUB_OUTPUT
echo "publish_py=true" >> $GITHUB_OUTPUT
echo "publish_mcp=true" >> $GITHUB_OUTPUT
fi
publish-typescript:
needs: prepare
if: needs.prepare.outputs.publish_ts == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
defaults:
run:
working-directory: packages/flowforge-client-ts
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: pnpm install
- name: Update version in package.json
run: |
VERSION="${{ needs.prepare.outputs.version }}"
jq --arg v "$VERSION" '.version = $v' package.json > package.json.tmp
mv package.json.tmp package.json
echo "Updated package.json to version $VERSION"
- name: Type check
run: pnpm typecheck
- name: Build
run: pnpm build
- name: Publish to npm
run: pnpm publish --no-git-checks --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-python:
needs: prepare
if: needs.prepare.outputs.publish_py == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
defaults:
run:
working-directory: packages/flowforge-sdk
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build
- name: Update version in pyproject.toml
run: |
VERSION="${{ needs.prepare.outputs.version }}"
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml
echo "Updated pyproject.toml to version $VERSION"
- name: Build package
run: python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: packages/flowforge-sdk/dist/
publish-mcp:
needs: prepare
if: needs.prepare.outputs.publish_mcp == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
defaults:
run:
working-directory: packages/flowforge-mcp
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: pnpm install
- name: Update version in package.json
run: |
VERSION="${{ needs.prepare.outputs.version }}"
jq --arg v "$VERSION" '.version = $v' package.json > package.json.tmp
mv package.json.tmp package.json
echo "Updated package.json to version $VERSION"
- name: Build
run: pnpm build
- name: Publish to npm
run: pnpm publish --no-git-checks --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
create-release:
needs: [prepare, publish-typescript, publish-python, publish-mcp]
if: always() && (needs.publish-typescript.result == 'success' || needs.publish-python.result == 'success' || needs.publish-mcp.result == 'success')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ needs.prepare.outputs.version }}"
TAG="${{ needs.prepare.outputs.tag }}"
# Build release notes
NOTES="## Packages Published\n\n"
if [ "${{ needs.publish-typescript.result }}" = "success" ]; then
NOTES+="- **flowforge-client** v${VERSION} on [npm](https://www.npmjs.com/package/flowforge-client)\n"
fi
if [ "${{ needs.publish-python.result }}" = "success" ]; then
NOTES+="- **flowforge-sdk** v${VERSION} on [PyPI](https://pypi.org/project/flowforge-sdk/)\n"
fi
if [ "${{ needs.publish-mcp.result }}" = "success" ]; then
NOTES+="- **flowforge-mcp-server** v${VERSION} on [npm](https://www.npmjs.com/package/flowforge-mcp-server)\n"
fi
NOTES+="\n## What's Changed\n"
# Check if release already exists
if gh release view "$TAG" &>/dev/null; then
echo "Release $TAG already exists, updating..."
echo -e "$NOTES" | gh release edit "$TAG" --notes-file -
else
echo "Creating release $TAG..."
echo -e "$NOTES" | gh release create "$TAG" \
--title "v${VERSION}" \
--notes-file - \
--generate-notes
fi