Skip to content

Commit 09f2a15

Browse files
feat(workflow): add GitHub Actions workflow for publishing agentflow sdk (#5908)
* feat(workflow): add GitHub Actions workflow for publishing @flowiseai/agentflow - Introduced a new workflow to handle version bumps and publishing of the @flowiseai/agentflow package. - Supports various version bump types (prerelease, patch, minor, major, custom) and allows for custom version input. - Includes a dry-run step to validate the version and simulate the publish process before actual deployment. - Configured to use pnpm for dependency management and publishing tasks. * chore(workflow): update permissions and add version bump commit step - Changed permissions for the GitHub Actions workflow to allow write access for contents. - Added a step to commit and push the version bump for the @flowiseai/agentflow package after publishing. * chore(workflow): enhance version bump process with PR creation - Added permission for pull-requests in the GitHub Actions workflow. - Modified the version bump step to create a new branch and open a pull request after committing the version bump for the @flowiseai/agentflow package. * address review comments
1 parent cf36fb7 commit 09f2a15

1 file changed

Lines changed: 152 additions & 0 deletions

File tree

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Publish @flowiseai/agentflow
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
bump:
6+
description: 'Version bump type'
7+
required: true
8+
type: choice
9+
default: 'prerelease'
10+
options:
11+
- prerelease
12+
- patch
13+
- minor
14+
- major
15+
- custom
16+
custom_version:
17+
description: 'Custom version (only used when bump is "custom", e.g. 1.0.0-beta.1)'
18+
required: false
19+
type: string
20+
tag:
21+
description: 'npm dist-tag'
22+
required: false
23+
type: choice
24+
default: 'dev'
25+
options:
26+
- dev
27+
- latest
28+
29+
jobs:
30+
dry-run:
31+
runs-on: ubuntu-latest
32+
permissions:
33+
contents: read
34+
outputs:
35+
version: ${{ steps.resolve-version.outputs.version }}
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- uses: pnpm/action-setup@v2
40+
with:
41+
version: 10.26.0
42+
43+
- uses: actions/setup-node@v4
44+
with:
45+
node-version: '18.15.0'
46+
registry-url: 'https://registry.npmjs.org'
47+
48+
- name: Validate custom version
49+
if: inputs.bump == 'custom'
50+
run: |
51+
if [ -z "$CUSTOM_VERSION" ]; then
52+
echo "::error::custom_version is required when bump is 'custom'"
53+
exit 1
54+
fi
55+
npx semver "$CUSTOM_VERSION" || (echo "::error::Invalid semver: $CUSTOM_VERSION" && exit 1)
56+
env:
57+
CUSTOM_VERSION: ${{ inputs.custom_version }}
58+
59+
- name: Install dependencies
60+
run: pnpm install --frozen-lockfile
61+
env:
62+
PUPPETEER_SKIP_DOWNLOAD: 'true'
63+
64+
- name: Set version
65+
run: |
66+
if [ "$BUMP" = "custom" ]; then
67+
pnpm --filter @flowiseai/agentflow exec npm version "$CUSTOM_VERSION" --no-git-tag-version
68+
else
69+
pnpm --filter @flowiseai/agentflow exec npm version "$BUMP" --preid dev --no-git-tag-version
70+
fi
71+
env:
72+
BUMP: ${{ inputs.bump }}
73+
CUSTOM_VERSION: ${{ inputs.custom_version }}
74+
75+
- name: Resolve version
76+
id: resolve-version
77+
run: |
78+
VERSION=$(node -p "require('./packages/agentflow/package.json').version")
79+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
80+
echo "## Version to publish: \`$VERSION\`" >> "$GITHUB_STEP_SUMMARY"
81+
echo "## Tag: \`${{ inputs.tag }}\`" >> "$GITHUB_STEP_SUMMARY"
82+
83+
- name: Package contents
84+
run: pnpm --filter @flowiseai/agentflow exec npm pack --dry-run
85+
86+
- name: Dry run publish
87+
run: pnpm --filter @flowiseai/agentflow publish --no-git-checks --dry-run --tag ${{ inputs.tag }}
88+
env:
89+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
90+
91+
publish:
92+
needs: dry-run
93+
runs-on: ubuntu-latest
94+
environment: npm-publish
95+
permissions:
96+
contents: write
97+
pull-requests: write
98+
steps:
99+
- uses: actions/checkout@v4
100+
101+
- uses: pnpm/action-setup@v2
102+
with:
103+
version: 10.26.0
104+
105+
- uses: actions/setup-node@v4
106+
with:
107+
node-version: '18.15.0'
108+
registry-url: 'https://registry.npmjs.org'
109+
110+
- name: Install dependencies
111+
run: pnpm install --frozen-lockfile
112+
env:
113+
PUPPETEER_SKIP_DOWNLOAD: 'true'
114+
115+
- name: Set version
116+
run: |
117+
if [ "$BUMP" = "custom" ]; then
118+
pnpm --filter @flowiseai/agentflow exec npm version "$CUSTOM_VERSION" --no-git-tag-version
119+
else
120+
pnpm --filter @flowiseai/agentflow exec npm version "$BUMP" --preid dev --no-git-tag-version
121+
fi
122+
env:
123+
BUMP: ${{ inputs.bump }}
124+
CUSTOM_VERSION: ${{ inputs.custom_version }}
125+
126+
- name: Log version
127+
run: |
128+
echo "Publishing version: ${{ needs.dry-run.outputs.version }}"
129+
echo "Tag: ${{ inputs.tag }}"
130+
131+
- name: Publish
132+
run: pnpm --filter @flowiseai/agentflow publish --no-git-checks --tag ${{ inputs.tag }}
133+
env:
134+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
135+
136+
- name: Create version bump PR
137+
run: |
138+
VERSION="${{ needs.dry-run.outputs.version }}"
139+
BRANCH="chore/bump-agentflow-${VERSION}"
140+
git config user.name "github-actions[bot]"
141+
git config user.email "github-actions[bot]@users.noreply.github.com"
142+
git checkout -b "$BRANCH"
143+
git add packages/agentflow/package.json
144+
git commit -m "chore: bump @flowiseai/agentflow to ${VERSION}"
145+
git push -u origin "$BRANCH"
146+
gh pr create \
147+
--title "chore: bump @flowiseai/agentflow to ${VERSION}" \
148+
--body "Automated version bump after publishing \`@flowiseai/agentflow@${VERSION}\` to npm with tag \`${{ inputs.tag }}\`." \
149+
--base main \
150+
--head "$BRANCH"
151+
env:
152+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)