Skip to content

Commit 09f33a8

Browse files
chore: trigger.version.ts to set trigger tasks versions in prod (calcom#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 <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>
1 parent 16cb9a3 commit 09f33a8

14 files changed

Lines changed: 46 additions & 31 deletions

.github/workflows/draft-release.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,17 @@ jobs:
8484
- name: Update Env Files
8585
run: |
8686
VERSION="${{ steps.deploy-trigger.outputs.deploymentVersion }}"
87-
echo "TRIGGER_VERSION=$VERSION" > apps/web/.env.production
88-
echo "TRIGGER_VERSION=$VERSION" > apps/api/v2/.env.production
89-
git add -f apps/web/.env.production apps/api/v2/.env.production
87+
88+
# Create the TypeScript content
89+
CONTENT="export const TRIGGER_VERSION = '$VERSION';"
90+
91+
# Write to the specific paths
92+
echo "$CONTENT" > apps/web/trigger.version.ts
93+
echo "$CONTENT" > apps/api/v2/trigger.version.ts
94+
echo "$CONTENT" > apps/api/v1/trigger.version.js
95+
96+
# Force add to git since these are likely in .gitignore
97+
git add -f apps/web/trigger.version.ts apps/api/v2/trigger.version.ts apps/api/v1/trigger.version.js
9098

9199
# 4. Commit everything together
92100
- name: Commit changes

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ yarn-error.log*
3838
.env.development.local
3939
.env.test.local
4040
.env.production.local
41-
.env.production
4241
.env.*
4342
!.env.example
4443
!.env.appStore.example

apps/api/v1/next.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const { withAxiom } = require("next-axiom");
33
const { withSentryConfig } = require("@sentry/nextjs");
44
const { PrismaPlugin } = require("@prisma/nextjs-monorepo-workaround-plugin");
5-
5+
const { TRIGGER_VERSION } = require("./trigger.version.js");
66
const plugins = [withAxiom];
77

88
/** @type {import("next").NextConfig} */
@@ -105,4 +105,10 @@ if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
105105
);
106106
}
107107

108+
const env = process.env;
109+
110+
if (process.env.NODE_ENV === "production" || process.env.CALCOM_ENV === "production") {
111+
env.TRIGGER_VERSION = TRIGGER_VERSION;
112+
}
113+
108114
module.exports = () => plugins.reduce((acc, next) => next(acc), nextConfig);

apps/api/v1/trigger.version.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const TRIGGER_VERSION = "20260128.1";

apps/api/v1/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"**/*.ts",
1818
"**/*.tsx",
1919
"../../../packages/types/*.d.ts",
20-
"../../../packages/types/next-auth.d.ts"
20+
"../../../packages/types/next-auth.d.ts",
21+
"trigger.version.js"
2122
],
2223
"exclude": ["**/node_modules/**", "templates", "auth"]
2324
}

apps/api/v2/.env.production

Lines changed: 0 additions & 1 deletion
This file was deleted.

apps/api/v2/src/app.controller.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import { getEnv } from "@/env";
2-
import { Controller, Get, Version, VERSION_NEUTRAL } from "@nestjs/common";
3-
import { ApiTags as DocsTags, ApiExcludeController as DocsExcludeController } from "@nestjs/swagger";
4-
1+
import { Controller, Get, VERSION_NEUTRAL, Version } from "@nestjs/common";
52
@Controller()
63
export class AppController {
74
@Get("health")

apps/api/v2/src/app.module.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
import { ThrottlerStorageRedisService } from "@nest-lab/throttler-storage-redis";
2+
import { BullModule } from "@nestjs/bull";
3+
import { MiddlewareConsumer, Module, NestModule, RequestMethod } from "@nestjs/common";
4+
import { ConfigModule } from "@nestjs/config";
5+
import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR } from "@nestjs/core";
6+
import { seconds, ThrottlerModule } from "@nestjs/throttler";
7+
import { SentryGlobalFilter, SentryModule } from "@sentry/nestjs/setup";
8+
import { AppController } from "./app.controller";
19
import appConfig from "@/config/app";
210
import { CustomThrottlerGuard } from "@/lib/throttler-guard";
311
import { AppLoggerMiddleware } from "@/middleware/app.logger.middleware";
@@ -13,23 +21,12 @@ import { JwtModule } from "@/modules/jwt/jwt.module";
1321
import { PrismaModule } from "@/modules/prisma/prisma.module";
1422
import { RedisModule } from "@/modules/redis/redis.module";
1523
import { RedisService } from "@/modules/redis/redis.service";
16-
import { ThrottlerStorageRedisService } from "@nest-lab/throttler-storage-redis";
17-
import { BullModule } from "@nestjs/bull";
18-
import { MiddlewareConsumer, Module, NestModule, RequestMethod } from "@nestjs/common";
19-
import { ConfigModule } from "@nestjs/config";
20-
import { APP_GUARD, APP_INTERCEPTOR, APP_FILTER } from "@nestjs/core";
21-
import { seconds, ThrottlerModule } from "@nestjs/throttler";
22-
import { SentryModule, SentryGlobalFilter } from "@sentry/nestjs/setup";
23-
24-
import { AppController } from "./app.controller";
2524

2625
@Module({
2726
imports: [
2827
SentryModule.forRoot(),
2928
ConfigModule.forRoot({
30-
...(process.env.NODE_ENV === "production"
31-
? { envFilePath: ".env.production" }
32-
: { ignoreEnvFile: true }),
29+
ignoreEnvFile: true,
3330
isGlobal: true,
3431
load: [appConfig],
3532
}),

apps/api/v2/src/bootstrap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import type { NestExpressApplication } from "@nestjs/platform-express";
1515
import cookieParser from "cookie-parser";
1616
import { Request } from "express";
1717
import helmet from "helmet";
18+
import { CalendarServiceExceptionFilter } from "./filters/calendar-service-exception.filter";
19+
import { TRPCExceptionFilter } from "./filters/trpc-exception.filter";
1820
import { HttpExceptionFilter } from "@/filters/http-exception.filter";
1921
import { PrismaExceptionFilter } from "@/filters/prisma-exception.filter";
2022
import { ZodExceptionFilter } from "@/filters/zod-exception.filter";
21-
import { CalendarServiceExceptionFilter } from "./filters/calendar-service-exception.filter";
22-
import { TRPCExceptionFilter } from "./filters/trpc-exception.filter";
2323

2424
const logger: Logger = new Logger("Bootstrap");
2525

apps/api/v2/src/main.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import "dotenv/config";
22

33
import { IncomingMessage, Server, ServerResponse } from "node:http";
4-
54
import { Logger } from "@nestjs/common";
65
import { ConfigService } from "@nestjs/config";
76
import { NestFactory } from "@nestjs/core";
87
import type { NestExpressApplication } from "@nestjs/platform-express";
98
import type { Express, Request, Response } from "express";
109
import { WinstonModule } from "nest-winston";
1110
import qs from "qs";
12-
import type { AppConfig } from "@/config/type";
13-
11+
import { TRIGGER_VERSION } from "../trigger.version";
1412
import { AppModule } from "./app.module";
1513
import { bootstrap } from "./bootstrap";
1614
import { loggerConfig } from "./lib/logger";
15+
import type { AppConfig } from "@/config/type";
1716

17+
if (process.env.NODE_ENV === "production") {
18+
process.env.TRIGGER_VERSION = TRIGGER_VERSION;
19+
}
1820
const logger: Logger = new Logger("App");
1921

2022
/**

0 commit comments

Comments
 (0)