diff --git a/.eslintrc.json b/.eslintrc.json index 87f8269c50..79e0c00abd 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,7 +16,8 @@ "dist", "public", "*.spec.js", - "bundle.js" + "bundle.js", + "packages/pro" ], "plugins": ["svelte3"], "extends": ["eslint:recommended"], diff --git a/.github/workflows/deploy-cloud.yaml b/.github/workflows/deploy-cloud.yaml index fa80da846f..d8f1ee88f9 100644 --- a/.github/workflows/deploy-cloud.yaml +++ b/.github/workflows/deploy-cloud.yaml @@ -2,23 +2,29 @@ name: Budibase Deploy Production on: workflow_dispatch: - inputs: - version: - description: Budibase release version. For example - 1.0.0 - required: false jobs: release: runs-on: ubuntu-latest steps: - - name: Fail if branch is not master - if: github.ref != 'refs/heads/master' - run: | - echo "Ref is not master, you must run this job from master." - exit 1 + - name: Fail if not a tag + run: | + if [[ $GITHUB_REF != refs/tags/* ]]; then + echo "Workflow Dispatch can only be run on tags" + exit 1 + fi - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Fail if tag is not in master + run: | + if ! git merge-base --is-ancestor ${{ github.sha }} origin/master; then + echo "Tag is not in master. This pipeline can only execute tags that are present on the master branch" + exit 1 + fi - name: Pull values.yaml from budibase-infra run: | @@ -31,11 +37,7 @@ jobs: - name: Get the latest budibase release version id: version run: | - if [ -z "${{ github.event.inputs.version }}" ]; then - release_version=$(cat lerna.json | jq -r '.version') - else - release_version=${{ github.event.inputs.version }} - fi + release_version=$(cat lerna.json | jq -r '.version') echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - name: Configure AWS Credentials diff --git a/.github/workflows/deploy-preprod.yml b/.github/workflows/deploy-preprod.yml index 57e2504ded..81395bc7e3 100644 --- a/.github/workflows/deploy-preprod.yml +++ b/.github/workflows/deploy-preprod.yml @@ -1,27 +1,35 @@ name: "deploy-preprod" on: workflow_dispatch: - inputs: - version: - description: Budibase release version. For example - 1.0.0 - required: false workflow_call: jobs: deploy-to-legacy-preprod-env: runs-on: ubuntu-latest steps: + - name: Fail if not a tag + run: | + if [[ $GITHUB_REF != refs/tags/* ]]; then + echo "Workflow Dispatch can only be run on tags" + exit 1 + fi + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Fail if tag is not in master + run: | + if ! git merge-base --is-ancestor ${{ github.sha }} origin/master; then + echo "Tag is not in master. This pipeline can only execute tags that are present on the master branch" + exit 1 + fi + - name: Get the latest budibase release version id: version run: | - if [ -z "${{ github.event.inputs.version }}" ]; then - git pull - release_version=$(cat lerna.json | jq -r '.version') - else - release_version=${{ github.event.inputs.version }} - fi + release_version=$(cat lerna.json | jq -r '.version') echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 diff --git a/.github/workflows/release-develop.yml b/.github/workflows/release-develop.yml index 48c51e8457..503fc53194 100644 --- a/.github/workflows/release-develop.yml +++ b/.github/workflows/release-develop.yml @@ -22,6 +22,13 @@ jobs: runs-on: ubuntu-latest steps: + - name: Fail if not a tag + run: | + if [[ $GITHUB_REF != refs/tags/* ]]; then + echo "Workflow Dispatch can only be run on tags" + exit 1 + fi + - uses: actions/checkout@v2 with: submodules: true diff --git a/.github/workflows/release-master.yml b/.github/workflows/release-master.yml index f05d369a34..a4e679e7bf 100644 --- a/.github/workflows/release-master.yml +++ b/.github/workflows/release-master.yml @@ -9,12 +9,6 @@ on: - "v[0-9]+.[0-9]+.[0-9]+" # Exclude all pre-releases - "!v*[0-9]+.[0-9]+.[0-9]+-*" - workflow_dispatch: - inputs: - tags: - description: "Release tag" - required: true - type: boolean env: # Posthog token used by ui at build time @@ -33,12 +27,13 @@ jobs: token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} fetch-depth: 0 - - name: Fail if branch is not master - if: github.ref != 'refs/heads/master' + - name: Fail if tag is not in master run: | - echo "Ref is not master, you must run this job from master." - // Change to "exit 1" when merged. Left to 0 to not fail all the pipelines and not to cause noise - exit 0 + if ! git merge-base --is-ancestor ${{ github.sha }} origin/master; then + echo "Tag is not in master. This pipeline can only execute tags that are present on the master branch" + exit 1 + fi + - uses: actions/setup-node@v1 with: @@ -65,7 +60,6 @@ jobs: - name: Publish budibase packages to NPM env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - RELEASE_VERSION_TYPE: ${{ github.event.inputs.versioning }} run: | # setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default git config --global user.name "Budibase Release Bot" @@ -140,7 +134,6 @@ jobs: - name: Get the latest budibase release version id: version run: | - git pull release_version=$(cat lerna.json | jq -r '.version') echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV diff --git a/.github/workflows/release-selfhost.yml b/.github/workflows/release-selfhost.yml index f5a2f643c3..1ace297ed9 100644 --- a/.github/workflows/release-selfhost.yml +++ b/.github/workflows/release-selfhost.yml @@ -8,16 +8,24 @@ jobs: runs-on: ubuntu-latest steps: - - name: Fail if branch is not master - if: github.ref != 'refs/heads/master' + - name: Fail if not a tag run: | - echo "Ref is not master, you must run this job from master." - exit 1 + if [[ $GITHUB_REF != refs/tags/* ]]; then + echo "Workflow Dispatch can only be run on tags" + exit 1 + fi - uses: actions/checkout@v2 with: fetch_depth: 0 + - name: Fail if tag is not in master + run: | + if ! git merge-base --is-ancestor ${{ github.sha }} origin/master; then + echo "Tag is not in master. This pipeline can only execute tags that are present on the master branch" + exit 1 + fi + - name: Use Node.js 14.x uses: actions/setup-node@v1 with: @@ -78,7 +86,7 @@ jobs: git config user.name "Budibase Helm Bot" git config user.email "<>" git reset --hard - git pull + git fetch mkdir sync echo "Packaging chart to sync dir" helm package charts/budibase --version "$RELEASE_VERSION" --app-version "$RELEASE_VERSION" --destination sync diff --git a/.github/workflows/release-singleimage.yml b/.github/workflows/release-singleimage.yml index cd16574eea..fbf972a866 100644 --- a/.github/workflows/release-singleimage.yml +++ b/.github/workflows/release-singleimage.yml @@ -15,13 +15,24 @@ jobs: matrix: node-version: [14.x] steps: - - name: Fail if branch is not master - if: github.ref != 'refs/heads/master' - run: | - echo "Ref is not master, you must run this job from master." - exit 1 + - name: Fail if not a tag + run: | + if [[ $GITHUB_REF != refs/tags/* ]]; then + echo "Workflow Dispatch can only be run on tags" + exit 1 + fi - name: "Checkout" uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Fail if tag is not in master + run: | + if ! git merge-base --is-ancestor ${{ github.sha }} origin/master; then + echo "Tag is not in master. This pipeline can only execute tags that are present on the master branch" + exit 1 + fi + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index 1dcb16ac56..f361c200a0 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -28,7 +28,7 @@ on: required: true jobs: - tag-prerelease: + tag-release: runs-on: ubuntu-latest steps: @@ -43,9 +43,11 @@ jobs: token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - run: yarn - - name: Tag prerelease + - name: Tag release run: | # setup the username and email. git config --global user.name "Budibase Staging Release Bot" git config --global user.email "<>" - ./scripts/versionCommit.sh ${{ github.event.inputs.versioning }} + BUMP_TYPE_INPUT=${{ github.event.inputs.versioning }} + BUMP_TYPE=${BUMP_TYPE_INPUT:-"patch"} + ./scripts/versionCommit.sh $BUMP_TYPE diff --git a/lerna.json b/lerna.json index e44a4b60c7..1352dd768e 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.6.24-alpha.1", + "version": "2.6.27", "npmClient": "yarn", "packages": [ "packages/backend-core", diff --git a/package.json b/package.json index 3849c65274..ffb3fa775a 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,8 @@ "backend:build": "./scripts/scopeBackend.sh 'lerna run --stream build'", "build:sdk": "lerna run --stream build:sdk", "deps:circular": "madge packages/server/dist/index.js packages/worker/src/index.ts packages/backend-core/dist/src/index.js packages/cli/src/index.js --circular", - "release": "lerna publish ${RELEASE_VERSION_TYPE:-patch} --yes --force-publish --no-git-tag-version --no-push --no-git-reset", - "release:develop": "lerna publish from-package --yes --force-publish --dist-tag develop --exact --no-git-tag-version --no-push --no-git-reset", + "release": "lerna publish from-package --yes --force-publish --no-git-tag-version --no-push --no-git-reset", + "release:develop": "yarn release --dist-tag develop", "restore": "yarn run clean && yarn run bootstrap && yarn run build", "nuke": "yarn run nuke:packages && yarn run nuke:docker", "nuke:packages": "yarn run restore", diff --git a/packages/backend-core/src/events/publishers/user.ts b/packages/backend-core/src/events/publishers/user.ts index 0d08c0a759..43e5355bd5 100644 --- a/packages/backend-core/src/events/publishers/user.ts +++ b/packages/backend-core/src/events/publishers/user.ts @@ -3,6 +3,7 @@ import { Event, User, UserCreatedEvent, + UserDataCollaborationEvent, UserDeletedEvent, UserInviteAcceptedEvent, UserInvitedEvent, @@ -173,6 +174,15 @@ async function passwordReset(user: User) { await publishEvent(Event.USER_PASSWORD_RESET, properties) } +// COLLABORATION + +async function dataCollaboration(users: number) { + const properties: UserDataCollaborationEvent = { + users, + } + await publishEvent(Event.USER_DATA_COLLABORATION, properties) +} + export default { created, updated, @@ -188,4 +198,5 @@ export default { passwordUpdated, passwordResetRequested, passwordReset, + dataCollaboration, } diff --git a/packages/server/src/websockets/builder.ts b/packages/server/src/websockets/builder.ts index 0580a58b42..0f2c43e5ab 100644 --- a/packages/server/src/websockets/builder.ts +++ b/packages/server/src/websockets/builder.ts @@ -1,6 +1,6 @@ import authorized from "../middleware/authorized" import { BaseSocket } from "./websocket" -import { permissions } from "@budibase/backend-core" +import { permissions, events } from "@budibase/backend-core" import http from "http" import Koa from "koa" import { Datasource, Table, SocketSession, ContextUser } from "@budibase/types" @@ -22,6 +22,9 @@ export default class BuilderSocket extends BaseSocket { // Reply with all users in current room const sessions = await this.getRoomSessions(appId) callback({ users: sessions }) + + // Track usage + await events.user.dataCollaboration(sessions.length) }) } diff --git a/packages/types/src/sdk/events/event.ts b/packages/types/src/sdk/events/event.ts index 0d0b166253..f20f1b8fd6 100644 --- a/packages/types/src/sdk/events/event.ts +++ b/packages/types/src/sdk/events/event.ts @@ -26,6 +26,9 @@ export enum Event { USER_PASSWORD_RESET_REQUESTED = "user:password:reset:requested", USER_PASSWORD_RESET = "user:password:reset", + // USER / COLLABORATION + USER_DATA_COLLABORATION = "user:data:collaboration", + // EMAIL EMAIL_SMTP_CREATED = "email:smtp:created", EMAIL_SMTP_UPDATED = "email:smtp:updated", @@ -233,6 +236,7 @@ export const AuditedEventFriendlyName: Record = { [Event.USER_PASSWORD_FORCE_RESET]: undefined, [Event.USER_GROUP_ONBOARDING]: undefined, [Event.USER_ONBOARDING_COMPLETE]: undefined, + [Event.USER_DATA_COLLABORATION]: undefined, // EMAIL [Event.EMAIL_SMTP_CREATED]: `Email configuration created`, diff --git a/packages/types/src/sdk/events/user.ts b/packages/types/src/sdk/events/user.ts index 955f198732..eb3ebe97a5 100644 --- a/packages/types/src/sdk/events/user.ts +++ b/packages/types/src/sdk/events/user.ts @@ -86,3 +86,7 @@ export interface UserPasswordResetEvent extends BaseEvent { email: string } } + +export interface UserDataCollaborationEvent extends BaseEvent { + users: number +} diff --git a/scripts/versionCommit.sh b/scripts/versionCommit.sh index 10e7a9df71..d70f6900e2 100755 --- a/scripts/versionCommit.sh +++ b/scripts/versionCommit.sh @@ -2,7 +2,7 @@ if [ -z "$1" ] then - echo "Error: version number is required. Usage: $0 [major|minor|patch|prerelease]" + echo "Error: bump type is required. Usage: $0 [major|minor|patch|prerelease]" exit 1 fi