Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions .github/workflows/publish-agentflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: Publish @flowiseai/agentflow
on:
workflow_dispatch:
inputs:
bump:
description: 'Version bump type'
required: true
type: choice
default: 'prerelease'
options:
- prerelease
- patch
- minor
- major
- custom
custom_version:
description: 'Custom version (only used when bump is "custom", e.g. 1.0.0-beta.1)'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a risk with how we accept a string value for custom version that is interpolated directly into the shell below?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shell injection fix — all ${{ inputs.custom_version }} and ${{ inputs.bump }} are now passed via env: blocks and referenced as $CUSTOM_VERSION / $BUMP in shell. This prevents injection since env vars are safely quoted, unlike ${{ }} which is interpolated directly into the shell script before execution.

required: false
type: string
tag:
description: 'npm dist-tag'
required: false
type: choice
default: 'dev'
options:
- dev
- latest

jobs:
dry-run:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
version: ${{ steps.resolve-version.outputs.version }}
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
Comment thread
jocelynlin-wd marked this conversation as resolved.
with:
version: 10.26.0

- uses: actions/setup-node@v4
with:
node-version: '18.15.0'
registry-url: 'https://registry.npmjs.org'

- name: Validate custom version
if: inputs.bump == 'custom'
run: |
if [ -z "$CUSTOM_VERSION" ]; then
echo "::error::custom_version is required when bump is 'custom'"
exit 1
fi
npx semver "$CUSTOM_VERSION" || (echo "::error::Invalid semver: $CUSTOM_VERSION" && exit 1)
env:
CUSTOM_VERSION: ${{ inputs.custom_version }}

- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
PUPPETEER_SKIP_DOWNLOAD: 'true'

- name: Set version
run: |
if [ "$BUMP" = "custom" ]; then
pnpm --filter @flowiseai/agentflow exec npm version "$CUSTOM_VERSION" --no-git-tag-version
else
pnpm --filter @flowiseai/agentflow exec npm version "$BUMP" --preid dev --no-git-tag-version
fi
env:
BUMP: ${{ inputs.bump }}
CUSTOM_VERSION: ${{ inputs.custom_version }}

- name: Resolve version
id: resolve-version
run: |
VERSION=$(node -p "require('./packages/agentflow/package.json').version")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "## Version to publish: \`$VERSION\`" >> "$GITHUB_STEP_SUMMARY"
echo "## Tag: \`${{ inputs.tag }}\`" >> "$GITHUB_STEP_SUMMARY"

- name: Package contents
run: pnpm --filter @flowiseai/agentflow exec npm pack --dry-run

- name: Dry run publish
run: pnpm --filter @flowiseai/agentflow publish --no-git-checks --dry-run --tag ${{ inputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

publish:
needs: dry-run
runs-on: ubuntu-latest
environment: npm-publish
permissions:
contents: write
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for PR creation, will review if we really want PR creation since it will require us to either give github actions write permission to the repo or use a fine-grained PAT for the PR creation job.

pull-requests: write
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
with:
version: 10.26.0

- uses: actions/setup-node@v4
with:
node-version: '18.15.0'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
PUPPETEER_SKIP_DOWNLOAD: 'true'

Comment thread
yau-wd marked this conversation as resolved.
- name: Set version
run: |
if [ "$BUMP" = "custom" ]; then
pnpm --filter @flowiseai/agentflow exec npm version "$CUSTOM_VERSION" --no-git-tag-version
else
pnpm --filter @flowiseai/agentflow exec npm version "$BUMP" --preid dev --no-git-tag-version
fi
env:
BUMP: ${{ inputs.bump }}
CUSTOM_VERSION: ${{ inputs.custom_version }}

- name: Log version
run: |
echo "Publishing version: ${{ needs.dry-run.outputs.version }}"
echo "Tag: ${{ inputs.tag }}"

- name: Publish
run: pnpm --filter @flowiseai/agentflow publish --no-git-checks --tag ${{ inputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create version bump PR
run: |
VERSION="${{ needs.dry-run.outputs.version }}"
BRANCH="chore/bump-agentflow-${VERSION}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$BRANCH"
git add packages/agentflow/package.json
git commit -m "chore: bump @flowiseai/agentflow to ${VERSION}"
git push -u origin "$BRANCH"
gh pr create \
--title "chore: bump @flowiseai/agentflow to ${VERSION}" \
--body "Automated version bump after publishing \`@flowiseai/agentflow@${VERSION}\` to npm with tag \`${{ inputs.tag }}\`." \
--base main \
--head "$BRANCH"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}