-
-
Notifications
You must be signed in to change notification settings - Fork 24.5k
feat(workflow): add GitHub Actions workflow for publishing agentflow sdk #5908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
12be48d
feat(workflow): add GitHub Actions workflow for publishing @flowiseai…
jocelynlin-wd c9f043f
chore(workflow): update permissions and add version bump commit step
jocelynlin-wd af96a12
chore(workflow): enhance version bump process with PR creation
jocelynlin-wd 1f7d6af
address review comments
jocelynlin-wd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| 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)' | ||
| 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 | ||
|
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 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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' | ||
|
|
||
|
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 }} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.