Skip to content

Botonic Publish

Botonic Publish #26

Workflow file for this run

name: Botonic Publish
on:
workflow_dispatch:
inputs:
version_type:
description: 'Type of version upgrade'
required: true
default: 'patch'
type: choice
options:
- 'patch'
- 'minor'
packages:
description: 'Select packages to deploy (comma-separated)'
required: true
type: string
default: ''
deploy_all:
description: 'Deploy all packages'
required: false
type: boolean
default: false
permissions:
contents: write
packages: write
jobs:
deploy:
name: Deploy with version bump
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Install dependencies
run: npm install
- name: Configure NPM
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
# Step 1: Setup helper functions
- name: Setup helper functions
id: helpers
run: |
# Copy the helper script to a temporary location for use
cp scripts/ci/botonic-publish.sh /tmp/botonic-publish.sh
chmod +x /tmp/botonic-publish.sh
echo "Utility functions setup complete"
# Step 2: Calculate new version
- name: Calculate new version
id: version
run: |
source /tmp/botonic-publish.sh
if [[ "${{ github.event.inputs.version_type }}" != "patch" ]]; then
# For major or minor updates, use botonic-core as reference
CURRENT_VERSION=$(get_core_version)
else
# For patch updates, find highest version
CURRENT_VERSION=$(find_highest_version)
fi
NEW_VERSION=$(calculate_new_version "$CURRENT_VERSION" "${{ github.event.inputs.version_type }}")
echo "Current version: $CURRENT_VERSION"
echo "New version will be: $NEW_VERSION"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
# Step 4: Deploy selected packages
- name: Deploy selected packages
id: deploy-packages
if: ${{ github.event.inputs.deploy_all != 'true' }}
run: |
source /tmp/botonic-publish.sh
NEW_VERSION=${{ steps.version.outputs.new_version }}
DEPLOYED=""
# Convert comma-separated string to array
IFS=',' read -ra PACKAGES <<< "${{ github.event.inputs.packages }}"
# Deploy each selected package
for PKG in "${PACKAGES[@]}"; do
PKG=$(echo $PKG | xargs) # Trim whitespace
if [ -d "packages/$PKG" ]; then
deploy_package "$PKG" "$NEW_VERSION"
DEPLOYED="${DEPLOYED} $PKG"
fi
done
echo "deployed_packages=${DEPLOYED}" >> $GITHUB_OUTPUT
# Step 5: Deploy all packages (for all=true or major version upgrades)
- name: Deploy all packages
id: deploy-all
if: ${{ github.event.inputs.deploy_all == 'true' }}
run: |
source /tmp/botonic-publish.sh
NEW_VERSION=${{ steps.version.outputs.new_version }}
DEPLOYED="All packages"
# Deploy all packages
for PKG_DIR in packages/*; do
if [ -d "$PKG_DIR" ]; then
PACKAGE_NAME=$(basename $PKG_DIR)
deploy_package "$PACKAGE_NAME" "$NEW_VERSION"
fi
done
echo "deployed_packages=${DEPLOYED}" >> $GITHUB_OUTPUT
# Step 7: Deploy examples (for major version upgrades)
- name: Deploy examples
if: ${{ github.event.inputs.version_type == 'major' }}
run: |
source /tmp/botonic-publish.sh
NEW_VERSION=${{ steps.version.outputs.new_version }}
echo "Deploying examples for major version upgrade"
# Use the function to update dependencies and publish examples
version_and_publish_examples "$NEW_VERSION"
# Step 8: Commit changes
- name: Commit version changes
run: |
git add .
git commit -m "chore: bump version to ${{ steps.version.outputs.new_version }}"
git push
# Step 9: Generate deployment summary
- name: Deployment summary
if: ${{ success() }}
run: |
echo "## Botonic Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "Version upgrade: **${{ steps.version.outputs.new_version }}** (Type: ${{ github.event.inputs.version_type }})" >> $GITHUB_STEP_SUMMARY
if [[ "${{ github.event.inputs.deploy_all }}" == "true" || "${{ github.event.inputs.version_type }}" == "major" ]]; then
PACKAGES="All packages"
else
PACKAGES="${{ steps.deploy-packages.outputs.deployed_packages }}"
fi
echo "Deployed packages: $PACKAGES" >> $GITHUB_STEP_SUMMARY
echo "Deployment completed successfully at $(date)" >> $GITHUB_STEP_SUMMARY
- name: Sending Slack notification (success)
uses: rtCamp/action-slack-notify@v2
if: success()
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TEAM_PLATFORM }}
SLACK_USERNAME: Github
SLACK_ICON_EMOJI: ':rocket:'
SLACK_CHANNEL: '#team-botonic'
SLACK_TITLE: 'Botonic version ${{ steps.version.outputs.new_version }} published succesfully'
MSG_MINIMAL: true
- name: Sending Slack notification (failure)
uses: rtCamp/action-slack-notify@v2
if: failure()
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TEAM_PLATFORM }}
SLACK_USERNAME: Github
SLACK_ICON_EMOJI: ':bell:'
SLACK_COLOR: danger
SLACK_CHANNEL: '#team-botonic'
SLACK_TITLE: 'Botonic version ${{ steps.version.outputs.new_version }} failed to publish'
MSG_MINIMAL: true