From 09f33a840f52fc5b4721e5b4836af9b152e05b06 Mon Sep 17 00:00:00 2001 From: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Date: Thu, 29 Jan 2026 00:36:36 +0200 Subject: [PATCH] chore: trigger.version.ts to set trigger tasks versions in prod (#27333) * chore: trigger.version.ts instead of .env.production * chore: trigger.version.ts instead of .env.production * chore: restore dotenv/config import for local development Co-Authored-By: morgan@cal.com * fixup! chore: trigger.version.ts instead of .env.production * fixup! fixup! chore: trigger.version.ts instead of .env.production --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .github/workflows/draft-release.yml | 14 +++++++++++--- .gitignore | 1 - apps/api/v1/next.config.js | 8 +++++++- apps/api/v1/trigger.version.js | 1 + apps/api/v1/tsconfig.json | 3 ++- apps/api/v2/.env.production | 1 - apps/api/v2/src/app.controller.ts | 5 +---- apps/api/v2/src/app.module.ts | 21 +++++++++------------ apps/api/v2/src/bootstrap.ts | 4 ++-- apps/api/v2/src/main.ts | 8 +++++--- apps/api/v2/trigger.version.ts | 1 + apps/web/.env.production | 1 - apps/web/next.config.ts | 8 ++++++-- apps/web/trigger.version.ts | 1 + 14 files changed, 46 insertions(+), 31 deletions(-) create mode 100644 apps/api/v1/trigger.version.js delete mode 100644 apps/api/v2/.env.production create mode 100644 apps/api/v2/trigger.version.ts delete mode 100644 apps/web/.env.production create mode 100644 apps/web/trigger.version.ts diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index 733927b7b6..196fbac272 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -84,9 +84,17 @@ jobs: - name: Update Env Files run: | VERSION="${{ steps.deploy-trigger.outputs.deploymentVersion }}" - echo "TRIGGER_VERSION=$VERSION" > apps/web/.env.production - echo "TRIGGER_VERSION=$VERSION" > apps/api/v2/.env.production - git add -f apps/web/.env.production apps/api/v2/.env.production + + # Create the TypeScript content + CONTENT="export const TRIGGER_VERSION = '$VERSION';" + + # Write to the specific paths + echo "$CONTENT" > apps/web/trigger.version.ts + echo "$CONTENT" > apps/api/v2/trigger.version.ts + echo "$CONTENT" > apps/api/v1/trigger.version.js + + # Force add to git since these are likely in .gitignore + git add -f apps/web/trigger.version.ts apps/api/v2/trigger.version.ts apps/api/v1/trigger.version.js # 4. Commit everything together - name: Commit changes diff --git a/.gitignore b/.gitignore index 9d2cf5973c..93c93563ae 100644 --- a/.gitignore +++ b/.gitignore @@ -38,7 +38,6 @@ yarn-error.log* .env.development.local .env.test.local .env.production.local -.env.production .env.* !.env.example !.env.appStore.example diff --git a/apps/api/v1/next.config.js b/apps/api/v1/next.config.js index b1631d54c4..efec7b46cf 100644 --- a/apps/api/v1/next.config.js +++ b/apps/api/v1/next.config.js @@ -2,7 +2,7 @@ const { withAxiom } = require("next-axiom"); const { withSentryConfig } = require("@sentry/nextjs"); const { PrismaPlugin } = require("@prisma/nextjs-monorepo-workaround-plugin"); - +const { TRIGGER_VERSION } = require("./trigger.version.js"); const plugins = [withAxiom]; /** @type {import("next").NextConfig} */ @@ -105,4 +105,10 @@ if (process.env.NEXT_PUBLIC_SENTRY_DSN) { ); } +const env = process.env; + +if (process.env.NODE_ENV === "production" || process.env.CALCOM_ENV === "production") { + env.TRIGGER_VERSION = TRIGGER_VERSION; +} + module.exports = () => plugins.reduce((acc, next) => next(acc), nextConfig); diff --git a/apps/api/v1/trigger.version.js b/apps/api/v1/trigger.version.js new file mode 100644 index 0000000000..d28639f24f --- /dev/null +++ b/apps/api/v1/trigger.version.js @@ -0,0 +1 @@ +export const TRIGGER_VERSION = "20260128.1"; diff --git a/apps/api/v1/tsconfig.json b/apps/api/v1/tsconfig.json index b787a2b8bf..d88f6edfcf 100644 --- a/apps/api/v1/tsconfig.json +++ b/apps/api/v1/tsconfig.json @@ -17,7 +17,8 @@ "**/*.ts", "**/*.tsx", "../../../packages/types/*.d.ts", - "../../../packages/types/next-auth.d.ts" + "../../../packages/types/next-auth.d.ts", + "trigger.version.js" ], "exclude": ["**/node_modules/**", "templates", "auth"] } diff --git a/apps/api/v2/.env.production b/apps/api/v2/.env.production deleted file mode 100644 index e71b3f6778..0000000000 --- a/apps/api/v2/.env.production +++ /dev/null @@ -1 +0,0 @@ -TRIGGER_VERSION=20260128.2 diff --git a/apps/api/v2/src/app.controller.ts b/apps/api/v2/src/app.controller.ts index 82295bce91..354dd66441 100644 --- a/apps/api/v2/src/app.controller.ts +++ b/apps/api/v2/src/app.controller.ts @@ -1,7 +1,4 @@ -import { getEnv } from "@/env"; -import { Controller, Get, Version, VERSION_NEUTRAL } from "@nestjs/common"; -import { ApiTags as DocsTags, ApiExcludeController as DocsExcludeController } from "@nestjs/swagger"; - +import { Controller, Get, VERSION_NEUTRAL, Version } from "@nestjs/common"; @Controller() export class AppController { @Get("health") diff --git a/apps/api/v2/src/app.module.ts b/apps/api/v2/src/app.module.ts index 64fa31ef08..5cd62b2545 100644 --- a/apps/api/v2/src/app.module.ts +++ b/apps/api/v2/src/app.module.ts @@ -1,3 +1,11 @@ +import { ThrottlerStorageRedisService } from "@nest-lab/throttler-storage-redis"; +import { BullModule } from "@nestjs/bull"; +import { MiddlewareConsumer, Module, NestModule, RequestMethod } from "@nestjs/common"; +import { ConfigModule } from "@nestjs/config"; +import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR } from "@nestjs/core"; +import { seconds, ThrottlerModule } from "@nestjs/throttler"; +import { SentryGlobalFilter, SentryModule } from "@sentry/nestjs/setup"; +import { AppController } from "./app.controller"; import appConfig from "@/config/app"; import { CustomThrottlerGuard } from "@/lib/throttler-guard"; import { AppLoggerMiddleware } from "@/middleware/app.logger.middleware"; @@ -13,23 +21,12 @@ import { JwtModule } from "@/modules/jwt/jwt.module"; import { PrismaModule } from "@/modules/prisma/prisma.module"; import { RedisModule } from "@/modules/redis/redis.module"; import { RedisService } from "@/modules/redis/redis.service"; -import { ThrottlerStorageRedisService } from "@nest-lab/throttler-storage-redis"; -import { BullModule } from "@nestjs/bull"; -import { MiddlewareConsumer, Module, NestModule, RequestMethod } from "@nestjs/common"; -import { ConfigModule } from "@nestjs/config"; -import { APP_GUARD, APP_INTERCEPTOR, APP_FILTER } from "@nestjs/core"; -import { seconds, ThrottlerModule } from "@nestjs/throttler"; -import { SentryModule, SentryGlobalFilter } from "@sentry/nestjs/setup"; - -import { AppController } from "./app.controller"; @Module({ imports: [ SentryModule.forRoot(), ConfigModule.forRoot({ - ...(process.env.NODE_ENV === "production" - ? { envFilePath: ".env.production" } - : { ignoreEnvFile: true }), + ignoreEnvFile: true, isGlobal: true, load: [appConfig], }), diff --git a/apps/api/v2/src/bootstrap.ts b/apps/api/v2/src/bootstrap.ts index 3c2c2a46ff..9311ceda91 100644 --- a/apps/api/v2/src/bootstrap.ts +++ b/apps/api/v2/src/bootstrap.ts @@ -15,11 +15,11 @@ import type { NestExpressApplication } from "@nestjs/platform-express"; import cookieParser from "cookie-parser"; import { Request } from "express"; import helmet from "helmet"; +import { CalendarServiceExceptionFilter } from "./filters/calendar-service-exception.filter"; +import { TRPCExceptionFilter } from "./filters/trpc-exception.filter"; import { HttpExceptionFilter } from "@/filters/http-exception.filter"; import { PrismaExceptionFilter } from "@/filters/prisma-exception.filter"; import { ZodExceptionFilter } from "@/filters/zod-exception.filter"; -import { CalendarServiceExceptionFilter } from "./filters/calendar-service-exception.filter"; -import { TRPCExceptionFilter } from "./filters/trpc-exception.filter"; const logger: Logger = new Logger("Bootstrap"); diff --git a/apps/api/v2/src/main.ts b/apps/api/v2/src/main.ts index 10599bf4b1..9f5a341067 100644 --- a/apps/api/v2/src/main.ts +++ b/apps/api/v2/src/main.ts @@ -1,7 +1,6 @@ import "dotenv/config"; import { IncomingMessage, Server, ServerResponse } from "node:http"; - import { Logger } from "@nestjs/common"; import { ConfigService } from "@nestjs/config"; import { NestFactory } from "@nestjs/core"; @@ -9,12 +8,15 @@ import type { NestExpressApplication } from "@nestjs/platform-express"; import type { Express, Request, Response } from "express"; import { WinstonModule } from "nest-winston"; import qs from "qs"; -import type { AppConfig } from "@/config/type"; - +import { TRIGGER_VERSION } from "../trigger.version"; import { AppModule } from "./app.module"; import { bootstrap } from "./bootstrap"; import { loggerConfig } from "./lib/logger"; +import type { AppConfig } from "@/config/type"; +if (process.env.NODE_ENV === "production") { + process.env.TRIGGER_VERSION = TRIGGER_VERSION; +} const logger: Logger = new Logger("App"); /** diff --git a/apps/api/v2/trigger.version.ts b/apps/api/v2/trigger.version.ts new file mode 100644 index 0000000000..d28639f24f --- /dev/null +++ b/apps/api/v2/trigger.version.ts @@ -0,0 +1 @@ +export const TRIGGER_VERSION = "20260128.1"; diff --git a/apps/web/.env.production b/apps/web/.env.production deleted file mode 100644 index e71b3f6778..0000000000 --- a/apps/web/.env.production +++ /dev/null @@ -1 +0,0 @@ -TRIGGER_VERSION=20260128.2 diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index 1cf874c6a4..599d8ff108 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -3,15 +3,15 @@ import { config as dotenvConfig } from "dotenv"; import type { NextConfig } from "next"; import type { RouteHas } from "next/dist/lib/load-custom-routes"; import { withAxiom } from "next-axiom"; - import i18nConfig from "./next-i18next.config"; import packageJson from "./package.json"; import { nextJsOrgRewriteConfig, orgUserRoutePath, - orgUserTypeRoutePath, orgUserTypeEmbedRoutePath, + orgUserTypeRoutePath, } from "./pagesAndRewritePaths"; +import { TRIGGER_VERSION } from "./trigger.version"; // adjust path as needed dotenvConfig({ path: "../../.env" }); @@ -58,6 +58,10 @@ const env = process.env as Record; env.NEXT_PUBLIC_CALCOM_VERSION = version; +if (process.env.NODE_ENV === "production" || process.env.CALCOM_ENV === "production") { + env.TRIGGER_VERSION = TRIGGER_VERSION; +} + if (process.env.VERCEL_URL && !process.env.NEXT_PUBLIC_WEBAPP_URL) { env.NEXT_PUBLIC_WEBAPP_URL = `https://${process.env.VERCEL_URL}`; } diff --git a/apps/web/trigger.version.ts b/apps/web/trigger.version.ts new file mode 100644 index 0000000000..d28639f24f --- /dev/null +++ b/apps/web/trigger.version.ts @@ -0,0 +1 @@ +export const TRIGGER_VERSION = "20260128.1";