Skip to content

Commit 98fdc56

Browse files
authored
chore: create gh action deploy botonic #PLA-2878 (#3020)
<!-- _Set as [Draft PR](https://github.blog/2019-02-14-introducing-draft-pull-requests/) if it's not ready to be merged_. [PR best practices Reference](https://blog.codeminer42.com/on-writing-a-great-pull-request-37c60ce6f31d/) --> ## Description Bash script and gh action to publish a new version of botonic. The gh action calls the bash script when needed <!-- - Must be clear and concise (2-3 lines). - Don't make reviewers think. The description should explain what has been implemented or what it's used for. If a pull request is not descriptive, people will be lazy or not willing to spend much time on it. - Be explicit with the names (don't abbreviate and don't use acronyms that can lead to misleading understanding). - If you consider it appropriate, include the steps to try the new features. --> ## Context <!-- - What problem is trying to solve this pull request? - What are the reasons or business goals of this implementation? - Can I provide visual resources or links to understand better the situation? --> ## Approach taken / Explain the design <!-- - Explain what the code does. - If it's a complex solution, try to provide a sketch. --> ## To document / Usage example <!-- - How this is used? - If possible, provide a snippet of code with a usage example. --> ## Testing The pull request... - has unit tests - has integration tests - doesn't need tests because... **[provide a description]**
1 parent 1cfd9fa commit 98fdc56

File tree

7 files changed

+593
-12
lines changed

7 files changed

+593
-12
lines changed
Lines changed: 392 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,392 @@
1+
name: Botonic Publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_type:
7+
description: 'Type of version upgrade'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- 'patch'
13+
- 'minor'
14+
packages:
15+
description: 'Select packages to deploy'
16+
required: true
17+
type: boolean
18+
all:
19+
description: 'Deploy all packages'
20+
required: false
21+
type: boolean
22+
default: false
23+
botonic-cli:
24+
description: 'Deploy botonic-cli'
25+
required: false
26+
type: boolean
27+
default: false
28+
botonic-core:
29+
description: 'Deploy botonic-core'
30+
required: false
31+
type: boolean
32+
default: false
33+
botonic-dx:
34+
description: 'Deploy botonic-dx'
35+
required: false
36+
type: boolean
37+
default: false
38+
botonic-dx-bundler-rspack:
39+
description: 'Deploy botonic-dx-bundler-rspack'
40+
required: false
41+
type: boolean
42+
default: false
43+
botonic-dx-bundler-webpack:
44+
description: 'Deploy botonic-dx-bundler-webpack'
45+
required: false
46+
type: boolean
47+
default: false
48+
botonic-eslint-config:
49+
description: 'Deploy botonic-eslint-config'
50+
required: false
51+
type: boolean
52+
default: false
53+
botonic-plugin-contentful:
54+
description: 'Deploy botonic-plugin-contentful'
55+
required: false
56+
type: boolean
57+
default: false
58+
botonic-plugin-dashbot:
59+
description: 'Deploy botonic-plugin-dashbot'
60+
required: false
61+
type: boolean
62+
default: false
63+
botonic-plugin-dialogflow:
64+
description: 'Deploy botonic-plugin-dialogflow'
65+
required: false
66+
type: boolean
67+
default: false
68+
botonic-plugin-dynamodb:
69+
description: 'Deploy botonic-plugin-dynamodb'
70+
required: false
71+
type: boolean
72+
default: false
73+
botonic-plugin-flow-builder:
74+
description: 'Deploy botonic-plugin-flow-builder'
75+
required: false
76+
type: boolean
77+
default: false
78+
botonic-plugin-google-analytics:
79+
description: 'Deploy botonic-plugin-google-analytics'
80+
required: false
81+
type: boolean
82+
default: false
83+
botonic-plugin-google-translation:
84+
description: 'Deploy botonic-plugin-google-translation'
85+
required: false
86+
type: boolean
87+
default: false
88+
botonic-plugin-hubtype-analytics:
89+
description: 'Deploy botonic-plugin-hubtype-analytics'
90+
required: false
91+
type: boolean
92+
default: false
93+
botonic-plugin-hubtype-babel:
94+
description: 'Deploy botonic-plugin-hubtype-babel'
95+
required: false
96+
type: boolean
97+
default: false
98+
botonic-plugin-inbenta:
99+
description: 'Deploy botonic-plugin-inbenta'
100+
required: false
101+
type: boolean
102+
default: false
103+
botonic-plugin-knowledge-bases:
104+
description: 'Deploy botonic-plugin-knowledge-bases'
105+
required: false
106+
type: boolean
107+
default: false
108+
botonic-plugin-luis:
109+
description: 'Deploy botonic-plugin-luis'
110+
required: false
111+
type: boolean
112+
default: false
113+
botonic-plugin-segment:
114+
description: 'Deploy botonic-plugin-segment'
115+
required: false
116+
type: boolean
117+
default: false
118+
botonic-plugin-watson:
119+
description: 'Deploy botonic-plugin-watson'
120+
required: false
121+
type: boolean
122+
default: false
123+
botonic-react:
124+
description: 'Deploy botonic-react'
125+
required: false
126+
type: boolean
127+
default: false
128+
129+
permissions:
130+
contents: write
131+
packages: write
132+
133+
jobs:
134+
deploy:
135+
name: Deploy with version bump
136+
runs-on: ubuntu-latest
137+
steps:
138+
- name: Checkout repository
139+
uses: actions/checkout@v4
140+
with:
141+
fetch-depth: 0
142+
token: ${{ secrets.GITHUB_TOKEN }}
143+
144+
- name: Setup Node.js
145+
uses: actions/setup-node@v4
146+
with:
147+
node-version: '20'
148+
cache: 'npm'
149+
cache-dependency-path: '**/package-lock.json'
150+
151+
- name: Install dependencies
152+
run: npm install
153+
154+
- name: Configure NPM
155+
run: |
156+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
157+
158+
# Step 1: Setup helper functions
159+
- name: Setup helper functions
160+
id: helpers
161+
run: |
162+
# Copy the helper script to a temporary location for use
163+
cp scripts/ci/botonic-publish.sh /tmp/botonic-publish.sh
164+
chmod +x /tmp/botonic-publish.sh
165+
echo "Utility functions setup complete"
166+
167+
# Step 2: Calculate new version
168+
- name: Calculate new version
169+
id: version
170+
run: |
171+
source /tmp/botonic-publish.sh
172+
173+
if [[ "${{ github.event.inputs.version_type }}" != "patch" ]]; then
174+
# For major or minor updates, use botonic-core as reference
175+
CURRENT_VERSION=$(get_core_version)
176+
else
177+
# For patch updates, find highest version
178+
CURRENT_VERSION=$(find_highest_version)
179+
fi
180+
181+
NEW_VERSION=$(calculate_new_version "$CURRENT_VERSION" "${{ github.event.inputs.version_type }}")
182+
183+
echo "Current version: $CURRENT_VERSION"
184+
echo "New version will be: $NEW_VERSION"
185+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
186+
187+
# Step 4: Deploy selected packages
188+
- name: Deploy selected packages
189+
id: deploy-packages
190+
if: ${{ github.event.inputs.all != 'true' && github.event.inputs.version_type == 'patch' }}
191+
run: |
192+
source /tmp/botonic-publish.sh
193+
194+
NEW_VERSION=${{ steps.version.outputs.new_version }}
195+
DEPLOYED=""
196+
DEPLOY_CLI="${{ github.event.inputs.botonic-cli == 'true' && 'true' || 'false' }}"
197+
198+
# Deploy each selected package except CLI
199+
if [[ "${{ github.event.inputs.botonic-core }}" == "true" ]]; then
200+
deploy_package "botonic-core" "$NEW_VERSION"
201+
DEPLOYED="${DEPLOYED} botonic-core"
202+
fi
203+
204+
if [[ "${{ github.event.inputs.botonic-dx }}" == "true" ]]; then
205+
deploy_package "botonic-dx" "$NEW_VERSION"
206+
DEPLOYED="${DEPLOYED} botonic-dx"
207+
fi
208+
209+
if [[ "${{ github.event.inputs.botonic-dx-bundler-rspack }}" == "true" ]]; then
210+
deploy_package "botonic-dx-bundler-rspack" "$NEW_VERSION"
211+
DEPLOYED="${DEPLOYED} botonic-dx-bundler-rspack"
212+
fi
213+
214+
if [[ "${{ github.event.inputs.botonic-dx-bundler-webpack }}" == "true" ]]; then
215+
deploy_package "botonic-dx-bundler-webpack" "$NEW_VERSION"
216+
DEPLOYED="${DEPLOYED} botonic-dx-bundler-webpack"
217+
fi
218+
219+
if [[ "${{ github.event.inputs.botonic-eslint-config }}" == "true" ]]; then
220+
deploy_package "botonic-eslint-config" "$NEW_VERSION"
221+
DEPLOYED="${DEPLOYED} botonic-eslint-config"
222+
fi
223+
224+
if [[ "${{ github.event.inputs.botonic-plugin-contentful }}" == "true" ]]; then
225+
deploy_package "botonic-plugin-contentful" "$NEW_VERSION"
226+
DEPLOYED="${DEPLOYED} botonic-plugin-contentful"
227+
fi
228+
229+
if [[ "${{ github.event.inputs.botonic-plugin-dashbot }}" == "true" ]]; then
230+
deploy_package "botonic-plugin-dashbot" "$NEW_VERSION"
231+
DEPLOYED="${DEPLOYED} botonic-plugin-dashbot"
232+
fi
233+
234+
if [[ "${{ github.event.inputs.botonic-plugin-dialogflow }}" == "true" ]]; then
235+
deploy_package "botonic-plugin-dialogflow" "$NEW_VERSION"
236+
DEPLOYED="${DEPLOYED} botonic-plugin-dialogflow"
237+
fi
238+
239+
if [[ "${{ github.event.inputs.botonic-plugin-dynamodb }}" == "true" ]]; then
240+
deploy_package "botonic-plugin-dynamodb" "$NEW_VERSION"
241+
DEPLOYED="${DEPLOYED} botonic-plugin-dynamodb"
242+
fi
243+
244+
if [[ "${{ github.event.inputs.botonic-plugin-flow-builder }}" == "true" ]]; then
245+
deploy_package "botonic-plugin-flow-builder" "$NEW_VERSION"
246+
DEPLOYED="${DEPLOYED} botonic-plugin-flow-builder"
247+
fi
248+
249+
if [[ "${{ github.event.inputs.botonic-plugin-google-analytics }}" == "true" ]]; then
250+
deploy_package "botonic-plugin-google-analytics" "$NEW_VERSION"
251+
DEPLOYED="${DEPLOYED} botonic-plugin-google-analytics"
252+
fi
253+
254+
if [[ "${{ github.event.inputs.botonic-plugin-google-translation }}" == "true" ]]; then
255+
deploy_package "botonic-plugin-google-translation" "$NEW_VERSION"
256+
DEPLOYED="${DEPLOYED} botonic-plugin-google-translation"
257+
fi
258+
259+
if [[ "${{ github.event.inputs.botonic-plugin-hubtype-analytics }}" == "true" ]]; then
260+
deploy_package "botonic-plugin-hubtype-analytics" "$NEW_VERSION"
261+
DEPLOYED="${DEPLOYED} botonic-plugin-hubtype-analytics"
262+
fi
263+
264+
if [[ "${{ github.event.inputs.botonic-plugin-hubtype-babel }}" == "true" ]]; then
265+
deploy_package "botonic-plugin-hubtype-babel" "$NEW_VERSION"
266+
DEPLOYED="${DEPLOYED} botonic-plugin-hubtype-babel"
267+
fi
268+
269+
if [[ "${{ github.event.inputs.botonic-plugin-inbenta }}" == "true" ]]; then
270+
deploy_package "botonic-plugin-inbenta" "$NEW_VERSION"
271+
DEPLOYED="${DEPLOYED} botonic-plugin-inbenta"
272+
fi
273+
274+
if [[ "${{ github.event.inputs.botonic-plugin-knowledge-bases }}" == "true" ]]; then
275+
deploy_package "botonic-plugin-knowledge-bases" "$NEW_VERSION"
276+
DEPLOYED="${DEPLOYED} botonic-plugin-knowledge-bases"
277+
fi
278+
279+
if [[ "${{ github.event.inputs.botonic-plugin-luis }}" == "true" ]]; then
280+
deploy_package "botonic-plugin-luis" "$NEW_VERSION"
281+
DEPLOYED="${DEPLOYED} botonic-plugin-luis"
282+
fi
283+
284+
if [[ "${{ github.event.inputs.botonic-plugin-segment }}" == "true" ]]; then
285+
deploy_package "botonic-plugin-segment" "$NEW_VERSION"
286+
DEPLOYED="${DEPLOYED} botonic-plugin-segment"
287+
fi
288+
289+
if [[ "${{ github.event.inputs.botonic-plugin-watson }}" == "true" ]]; then
290+
deploy_package "botonic-plugin-watson" "$NEW_VERSION"
291+
DEPLOYED="${DEPLOYED} botonic-plugin-watson"
292+
fi
293+
294+
if [[ "${{ github.event.inputs.botonic-react }}" == "true" ]]; then
295+
deploy_package "botonic-react" "$NEW_VERSION"
296+
DEPLOYED="${DEPLOYED} botonic-react"
297+
fi
298+
299+
echo "deployed_packages=${DEPLOYED}" >> $GITHUB_OUTPUT
300+
echo "deploy_cli=${DEPLOY_CLI}" >> $GITHUB_OUTPUT
301+
302+
# Step 5: Deploy all packages (for all=true or major version upgrades)
303+
- name: Deploy all packages
304+
id: deploy-all
305+
if: ${{ github.event.inputs.all == 'true' || github.event.inputs.version_type != 'patch' }}
306+
run: |
307+
source /tmp/botonic-publish.sh
308+
309+
NEW_VERSION=${{ steps.version.outputs.new_version }}
310+
DEPLOYED="All packages"
311+
312+
# Deploy all packages except botonic-cli
313+
for PKG_DIR in packages/*; do
314+
if [ -d "$PKG_DIR" ] && [ "$(basename $PKG_DIR)" != "botonic-cli" ]; then
315+
PACKAGE_NAME=$(basename $PKG_DIR)
316+
deploy_package "$PACKAGE_NAME" "$NEW_VERSION"
317+
fi
318+
done
319+
320+
echo "deployed_packages=${DEPLOYED}" >> $GITHUB_OUTPUT
321+
echo "deploy_cli=true" >> $GITHUB_OUTPUT
322+
323+
# Step 6: Deploy CLI (always last)
324+
- name: Deploy botonic-cli
325+
if: ${{ steps.deploy-packages.outputs.deploy_cli == 'true' || steps.deploy-all.outputs.deploy_cli == 'true' }}
326+
run: |
327+
source /tmp/botonic-publish.sh
328+
329+
echo "Deploying botonic-cli package (always last)"
330+
NEW_VERSION=${{ steps.version.outputs.new_version }}
331+
332+
deploy_package "botonic-cli" "$NEW_VERSION"
333+
334+
# Step 7: Deploy examples (for major version upgrades)
335+
- name: Deploy examples
336+
if: ${{ github.event.inputs.version_type == 'major' }}
337+
run: |
338+
source /tmp/botonic-publish.sh
339+
340+
NEW_VERSION=${{ steps.version.outputs.new_version }}
341+
342+
echo "Deploying examples for major version upgrade"
343+
344+
# Use the function to update dependencies and publish examples
345+
version_and_publish_examples "$NEW_VERSION"
346+
347+
# Step 8: Commit changes
348+
- name: Commit version changes
349+
run: |
350+
git add .
351+
git commit -m "chore: bump version to ${{ steps.version.outputs.new_version }}"
352+
git push
353+
354+
# Step 9: Generate deployment summary
355+
- name: Deployment summary
356+
if: ${{ success() }}
357+
run: |
358+
echo "## Botonic Deployment Summary" >> $GITHUB_STEP_SUMMARY
359+
echo "Version upgrade: **${{ steps.version.outputs.new_version }}** (Type: ${{ github.event.inputs.version_type }})" >> $GITHUB_STEP_SUMMARY
360+
361+
if [[ "${{ github.event.inputs.all }}" == "true" || "${{ github.event.inputs.version_type }}" == "major" ]]; then
362+
PACKAGES="All packages (with botonic-cli published last)"
363+
else
364+
PACKAGES="${{ steps.deploy-packages.outputs.deployed_packages }}"
365+
if [[ "${{ steps.deploy-packages.outputs.deploy_cli }}" == "true" ]]; then
366+
PACKAGES="${PACKAGES} botonic-cli"
367+
fi
368+
fi
369+
370+
echo "Deployed packages: $PACKAGES" >> $GITHUB_STEP_SUMMARY
371+
echo "Deployment completed successfully at $(date)" >> $GITHUB_STEP_SUMMARY
372+
- name: Sending Slack notification (success)
373+
uses: rtCamp/action-slack-notify@v2
374+
if: success()
375+
env:
376+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TEAM_PLATFORM }}
377+
SLACK_USERNAME: Github
378+
SLACK_ICON_EMOJI: ":rocket:"
379+
SLACK_CHANNEL: "#team-botonic"
380+
SLACK_TITLE: "Botonic version ${{ steps.version.outputs.new_version }} published succesfully"
381+
MSG_MINIMAL: true
382+
- name: Sending Slack notification (failure)
383+
uses: rtCamp/action-slack-notify@v2
384+
if: failure()
385+
env:
386+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TEAM_PLATFORM }}
387+
SLACK_USERNAME: Github
388+
SLACK_ICON_EMOJI: ':bell:'
389+
SLACK_COLOR: danger
390+
SLACK_CHANNEL: "#team-botonic"
391+
SLACK_TITLE: "Botonic version ${{ steps.version.outputs.new_version }} failed to publish"
392+
MSG_MINIMAL: true

0 commit comments

Comments
 (0)