diff --git a/.github/workflows/docker-api.yml b/.github/workflows/docker-api.yml new file mode 100644 index 00000000..f6638af8 --- /dev/null +++ b/.github/workflows/docker-api.yml @@ -0,0 +1,51 @@ +name: Build and Push Docker API Image + +on: + push: + branches: + - 'main' + tags: + - 'v*' + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: hexastack/hexabot-api + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + id: docker_login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push API Docker image + uses: docker/build-push-action@v6 + with: + context: ./api/ + target: production + file: ./api/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker-base.yml b/.github/workflows/docker-base.yml new file mode 100644 index 00000000..72c29775 --- /dev/null +++ b/.github/workflows/docker-base.yml @@ -0,0 +1,50 @@ +name: Build and Push Docker Base Image + +on: + push: + branches: + - 'main' + tags: + - 'v*' + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: hexastack/hexabot-base + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + id: docker_login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Base Docker base image + uses: docker/build-push-action@v6 + with: + context: ./api/ + file: ./api/Dockerfile.base + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker-nlu.yml b/.github/workflows/docker-nlu.yml new file mode 100644 index 00000000..df28941c --- /dev/null +++ b/.github/workflows/docker-nlu.yml @@ -0,0 +1,50 @@ +name: Build and Push Docker NLU Image + +on: + push: + branches: + - 'main' + tags: + - 'v*' + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: hexastack/hexabot-nlu + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + id: docker_login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push NLU Docker image + uses: docker/build-push-action@v6 + with: + context: ./nlu/ + file: ./nlu/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker-ui.yml b/.github/workflows/docker-ui.yml new file mode 100644 index 00000000..2de6939a --- /dev/null +++ b/.github/workflows/docker-ui.yml @@ -0,0 +1,51 @@ +name: Build and Push Docker UI Image + +on: + push: + branches: + - 'main' + tags: + - 'v*' + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: hexastack/hexabot-ui + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + id: docker_login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Frontend Docker image + uses: docker/build-push-action@v6 + with: + context: ./ + target: production + file: ./frontend/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 25c2ebb1..00000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,94 +0,0 @@ -name: Build and Push Docker Images - -on: - push: - branches: ["main"] - workflow_dispatch: - -jobs: - paths-filter: - runs-on: ubuntu-latest - outputs: - frontend: ${{ steps.filter.outputs.frontend }} - api: ${{ steps.filter.outputs.api }} - widget: ${{ steps.filter.outputs.widget }} - nlu: ${{ steps.filter.outputs.nlu }} - steps: - - uses: actions/checkout@v4 - - name: Filter paths - id: filter - uses: dorny/paths-filter@v3 - with: - filters: | - frontend: - - 'frontend/**' - api: - - 'api/**' - widget: - - 'widget/**' - nlu: - - 'nlu/**' - - build-and-push: - runs-on: ubuntu-latest - needs: - - paths-filter - steps: - - name: Check out repository code - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - id: docker_login - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push Frontend Docker image - if: ${{ needs.paths-filter.outputs.frontend == 'true' }} - uses: docker/build-push-action@v6 - with: - context: ./ - file: ./frontend/Dockerfile - platforms: linux/amd64,linux/arm64 - push: true - target: production - tags: hexastack/hexabot-ui:latest - - - name: Build and push API Docker image - if: ${{ needs.paths-filter.outputs.api == 'true' }} - uses: docker/build-push-action@v6 - with: - context: ./api/ - target: production - file: ./api/Dockerfile - platforms: linux/amd64,linux/arm64 - push: true - tags: hexastack/hexabot-api:latest - - - name: Build and push Widget Docker image - if: ${{ needs.paths-filter.outputs.widget == 'true' }} - uses: docker/build-push-action@v6 - with: - context: ./widget/ - file: ./widget/Dockerfile - platforms: linux/amd64,linux/arm64 - target: production - push: true - tags: hexastack/hexabot-widget:latest - - - name: Build and push NLU Docker image - if: ${{ needs.paths-filter.outputs.nlu == 'true' }} - uses: docker/build-push-action@v6 - with: - context: ./nlu/ - file: ./nlu/Dockerfile - platforms: linux/amd64,linux/arm64 - push: true - tags: hexastack/hexabot-nlu:latest diff --git a/.github/workflows/hexabot-npm.yml b/.github/workflows/hexabot-npm.yml new file mode 100644 index 00000000..e7d16237 --- /dev/null +++ b/.github/workflows/hexabot-npm.yml @@ -0,0 +1,58 @@ +name: Publish Hexabot (API Typescript) NPM Package + +on: + push: + tags: + - 'v*' + workflow_dispatch: # Allow manual trigger + +jobs: + publish-package: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' # Ensure it matches your project requirements + cache: 'npm' + + - name: Navigate to API Folder + run: cd api/ + + - name: Install dependencies + run: npm ci + + - name: Build the package + run: npm run build + + - name: Determine release type + id: determine-release + run: | + if [[ "${{ github.ref }}" == refs/tags/v* ]]; then + echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV + if [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.0$ ]]; then + echo "release=minor" >> $GITHUB_ENV + elif [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "release=patch" >> $GITHUB_ENV + else + echo "release=none" >> $GITHUB_ENV + fi + else + echo "release=none" >> $GITHUB_ENV + fi + + - name: Login to npm + if: env.release != 'none' + uses: actions/setup-node@v3 + with: + registry-url: 'https://registry.npmjs.org/' + node-version: '18' + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish to npm + if: env.release != 'none' + run: npm publish diff --git a/.github/workflows/widget-npm.yml b/.github/workflows/widget-npm.yml new file mode 100644 index 00000000..c3765784 --- /dev/null +++ b/.github/workflows/widget-npm.yml @@ -0,0 +1,58 @@ +name: Publish Hexabot Widget NPM Package + +on: + push: + tags: + - 'v*' + workflow_dispatch: # Allow manual trigger + +jobs: + publish-package: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' # Ensure it matches your project requirements + cache: 'npm' + + - name: Navigate to Widget Folder + run: cd widget/ + + - name: Install dependencies + run: npm ci + + - name: Build the package + run: npm run build + + - name: Determine release type + id: determine-release + run: | + if [[ "${{ github.ref }}" == refs/tags/v* ]]; then + echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV + if [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.0$ ]]; then + echo "release=minor" >> $GITHUB_ENV + elif [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "release=patch" >> $GITHUB_ENV + else + echo "release=none" >> $GITHUB_ENV + fi + else + echo "release=none" >> $GITHUB_ENV + fi + + - name: Login to npm + if: env.release != 'none' + uses: actions/setup-node@v3 + with: + registry-url: 'https://registry.npmjs.org/' + node-version: '18' + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish to npm + if: env.release != 'none' + run: npm publish diff --git a/api/package.json b/api/package.json index 41e88d9c..720bd778 100644 --- a/api/package.json +++ b/api/package.json @@ -39,13 +39,7 @@ "typecheck": "tsc --noEmit", "reset": "npm install && npm run containers:restart", "reset:hard": "npm clean-install && npm run containers:rebuild", - "migrate": "npx ts-migrate-mongoose --config-path ./migrations/config/migrate.ts", - "docker:build-base": "docker build --pull --rm -f Dockerfile.base -t hexabot-base:latest .", - "docker:tag-base": "docker tag hexabot-base:latest hexastack/hexabot-base:latest", - "docker:push-base": "docker push hexastack/hexabot-base:latest", - "docker:release-base": "npm run docker:build-base && npm run docker:tag-base && npm run docker:push-base", - "npm:release": "npm version patch && npm publish", - "release": "npm run build && npm run npm:release && npm run docker:release-base" + "migrate": "npx ts-migrate-mongoose --config-path ./migrations/config/migrate.ts" }, "dependencies": { "@nestjs-modules/mailer": "^1.11.2", @@ -178,4 +172,4 @@ "@/(.*)": "/$1" } } -} +} \ No newline at end of file diff --git a/bump-version.sh b/bump-version.sh new file mode 100755 index 00000000..194a0085 --- /dev/null +++ b/bump-version.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Ensure script exits on any command failure +set -e + +# Check if a release type argument is provided +if [ -z "$1" ]; then + echo "Usage: $0 " + echo "release-type: patch | minor" + exit 1 +fi + +RELEASE_TYPE=$1 +ROOT_DIR=$(pwd) + +if [[ "$RELEASE_TYPE" != "patch" && "$RELEASE_TYPE" != "minor" ]]; then + echo "Invalid release type. Use 'patch' or 'minor'." + exit 1 +fi + +echo "Executing release: $RELEASE_TYPE" + +# Execute the appropriate npm release command +if [[ "$RELEASE_TYPE" == "patch" ]]; then + npm run release:patch +elif [[ "$RELEASE_TYPE" == "minor" ]]; then + npm run release:minor +fi + +# Retrieve the new version from package.json +NEW_VERSION=$(jq -r '.version' "$ROOT_DIR/package.json") + +if [ -z "$NEW_VERSION" ]; then + echo "Failed to retrieve the version from package.json." + exit 1 +fi + + +# Commit and push changes +echo "Committing and pushing changes..." +git add . +git commit -m "build: v$NEW_VERSION" + +# Add git tag +echo "Tagging version v$NEW_VERSION" +git tag "v$NEW_VERSION" +git push origin main --tags + +echo "Release ($RELEASE_TYPE) completed successfully." diff --git a/frontend/.dockerignore b/frontend/.dockerignore index b6b7a04f..6b9e549c 100644 --- a/frontend/.dockerignore +++ b/frontend/.dockerignore @@ -11,3 +11,4 @@ LICENSE .next *.swp /scripts +*.sh diff --git a/frontend/package.json b/frontend/package.json index b32bec32..08178918 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "hexabot-ui", "private": true, - "version": "2.0.0", + "version": "2.0.17", "description": "Hexabot is a solution for creating and managing chatbots across multiple channels, leveraging AI for advanced conversational capabilities. It provides a user-friendly interface for building, training, and deploying chatbots with integrated support for various messaging platforms.", "author": "Hexastack", "license": "AGPL-3.0-only", diff --git a/package-lock.json b/package-lock.json index b4d808c9..fd9dbbdb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "hexabot", - "version": "2.0.0", + "version": "2.0.17", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "hexabot", - "version": "2.0.0", + "version": "2.0.17", "license": "AGPL-3.0-only", "workspaces": [ "frontend", @@ -45,7 +45,7 @@ }, "frontend": { "name": "hexabot-ui", - "version": "2.0.0", + "version": "2.0.18", "license": "AGPL-3.0-only", "dependencies": { "@chatscope/chat-ui-kit-react": "^2.0.3", @@ -9771,7 +9771,7 @@ }, "widget": { "name": "hexabot-chat-widget", - "version": "2.0.3", + "version": "2.0.18", "license": "AGPL-3.0-only", "dependencies": { "@types/emoji-js": "^3.5.2", diff --git a/package.json b/package.json index bb74c01a..46cefdfa 100644 --- a/package.json +++ b/package.json @@ -5,14 +5,18 @@ "frontend", "widget" ], - "version": "2.0.0", + "version": "2.0.17", "description": "Hexabot is a solution for creating and managing chatbots across multiple channels, leveraging AI for advanced conversational capabilities. It provides a user-friendly interface for building, training, and deploying chatbots with integrated support for various messaging platforms.", "author": "Hexastack", "license": "AGPL-3.0-only", "scripts": { "prepare": "husky install", "dev:frontend": "npm run dev --workspace=frontend", - "dev:widget": "npm run dev --workspace=widget" + "dev:widget": "npm run dev --workspace=widget", + "release:api:patch": "cd api/ && npm version --git-tag-version false --commit-hooks false patch", + "release:api:minor": "cd api/ && npm version --git-tag-version false --commit-hooks false minor", + "release:patch": "npm run release:api:patch && npm version --git-tag-version false --commit-hooks false --workspaces patch", + "release:minor": "npm run release:api:minor && npm version --git-tag-version false --commit-hooks false --workspaces minor" }, "devDependencies": { "@commitlint/cli": "^19.3.0", diff --git a/widget/package.json b/widget/package.json index 8fac6ff7..62d806f9 100644 --- a/widget/package.json +++ b/widget/package.json @@ -1,6 +1,6 @@ { "name": "hexabot-chat-widget", - "version": "2.0.3", + "version": "2.0.17", "description": "Hexabot is a solution for creating and managing chatbots across multiple channels, leveraging AI for advanced conversational capabilities. It provides a user-friendly interface for building, training, and deploying chatbots with integrated support for various messaging platforms.", "author": "Hexastack", "license": "AGPL-3.0-only", @@ -14,8 +14,7 @@ "lint:fix": "eslint . --ext ts,tsx --fix", "preview": "vite preview", "serve": "npx http-server ./dist/", - "typecheck": "tsc --noEmit", - "release": "npm run build && npm version patch && npm publish" + "typecheck": "tsc --noEmit" }, "dependencies": { "@types/emoji-js": "^3.5.2",