diff --git a/.github/workflows/sentry-release.yml b/.github/workflows/sentry-release.yml new file mode 100644 index 00000000..173a7e1a --- /dev/null +++ b/.github/workflows/sentry-release.yml @@ -0,0 +1,36 @@ +name: Sentry release source maps +on: + push: + branches: + - main + - dev + paths: + - 'apps/core/src/**' + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Node 16 + uses: actions/setup-node@v2 + with: + node-version: '16' + + - name: Install projects dependencies + uses: bahmutov/npm-install@v1 + + - name: Generate sourcemaps from build + run: yarn build:prod --filter=@sharingan/core + + - name: Create a Sentry release + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: sharingan + SENTRY_PROJECT: backend + VERSION: ${{ github.sha }} + run: | + curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION="2.2.0" bash + sentry-cli releases new "$VERSION" + sentry-cli releases files "$VERSION" upload-sourcemaps ./apps/core/build + sentry-cli releases finalize "$VERSION" diff --git a/apps/core/package.json b/apps/core/package.json index 9f4e9a06..00e8bc8e 100644 --- a/apps/core/package.json +++ b/apps/core/package.json @@ -9,7 +9,7 @@ "clean": "rm -rf .turbo dist build logs", "dev": "nodemon --watch \"*.ts\" --exec \"ts-node\" ./src/index.ts", "lint": "eslint src", - "build:prod": "esbuild ./src/index.ts --bundle --platform=node --outfile=build/index.js", + "build:prod": "esbuild ./src/index.ts --bundle --sourcemap --platform=node --outfile=build/index.js", "test": "jest", "gql:gen:types": "yarn graphql-codegen" }, diff --git a/apps/core/src/server/rest.ts b/apps/core/src/server/rest.ts index 4255d71f..95577963 100644 --- a/apps/core/src/server/rest.ts +++ b/apps/core/src/server/rest.ts @@ -1,4 +1,4 @@ -import express, { Application } from 'express'; +import express, { Application, Request, Response } from 'express'; import { authenticationRoute } from '../resources/authentication/routes'; import { errorHandlerMiddleware } from './middleware/error-middleware'; @@ -16,6 +16,10 @@ export const setupRestEndpoints = (app: Application) => { app.use('/', router); app.use('/', authenticationRoute()); + app.get('/', (_req: Request, res: Response) => { + res.json({ message: 'Hello from Sharingan!' }); + }); + app.use(notFoundMiddleware); app.use(errorHandlerMiddleware); diff --git a/package.json b/package.json index 781afb1c..de30fcd8 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "build": "turbo run build", + "build:prod": "turbo run build:prod", "build:backend": "turbo run build --filter=!@sharingan/web", "dev": "turbo run dev --no-cache --parallel --continue", "lint": "turbo run lint", diff --git a/turbo.json b/turbo.json index 49fbfaf7..d78c029c 100644 --- a/turbo.json +++ b/turbo.json @@ -52,6 +52,10 @@ "dependsOn": ["^build"], "outputs": [] }, + "build:prod": { + "dependsOn": ["^build"], + "outputs": ["build/**"] + }, "lint": { "outputs": [] },