Skip to content

Commit

Permalink
feat: add version info to environment (#4256) (#4257)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoopDog authored Nov 12, 2024
1 parent e589a84 commit 2a41e35
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 19 deletions.
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
"version": "2.1.1",
"private": true,
"scripts": {
"dev:ncpi-catalog": "./scripts/dev.sh ncpi-catalog dev && next dev",
"build-dev:ncpi-catalog": "scripts/common-build.sh ncpi-catalog dev && next build && npm run postbuild",
"build-prod:ncpi-catalog": "./scripts/common-build.sh ncpi-catalog prod && next build && npm run postbuild",
"dev:anvil-catalog": "./scripts/dev.sh anvil-catalog dev && next dev",
"build-dev:anvil-catalog": "scripts/common-build.sh anvil-catalog dev && next build && npm run postbuild",
"build-prod:anvil-catalog": "./scripts/common-build.sh anvil-catalog prod && next build && npm run postbuild",
"dev:lungmap": "./scripts/dev.sh lungmap dev && next dev",
"build-dev:lungmap": "./scripts/common-build.sh lungmap dev && next build && npm run postbuild",
"build-prod:lungmap": "./scripts/common-build.sh lungmap prod && next build && npm run postbuild",
"dev:anvil-cmg": "./scripts/dev.sh anvil-cmg dev && next dev",
"build:anvil-cmg": "./scripts/build.sh anvil-cmg && next build && npm run postbuild",
"build-cc-dev:anvil-cmg": "./scripts/common-build.sh anvil-cmg cc-dev && next build && npm run postbuild",
"dev:hca-dcp": "./scripts/dev.sh hca-dcp dev && next dev",
"dev:cc-ma-dev:hca-dcp": "./scripts/dev.sh hca-dcp cc-ma-dev && next dev",
"build-dev:hca-dcp": "./scripts/common-build.sh hca-dcp dev && next build && npm run postbuild",
"build-cc-ma-dev:hca-dcp": "./scripts/common-build.sh hca-dcp cc-ma-dev && next build && npm run postbuild",
"build-ma-dev:hca-dcp": "./scripts/common-build.sh hca-dcp ma-dev && next build && npm run postbuild",
"build-ma-prod:hca-dcp": "./scripts/common-build.sh hca-dcp ma-prod && next build && npm run postbuild",
"build-prod:hca-dcp": "./scripts/build.sh hca-dcp prod && next build && npm run postbuild",
"dev:ncpi-catalog": "./scripts/dev.sh ncpi-catalog dev && ./scripts/set-version.sh dev && next dev",
"build-dev:ncpi-catalog": "scripts/common-build.sh ncpi-catalog dev && ./scripts/set-version.sh && next build && npm run postbuild",
"build-prod:ncpi-catalog": "./scripts/common-build.sh ncpi-catalog prod && ./scripts/set-version.sh && next build && npm run postbuild",
"dev:anvil-catalog": "./scripts/dev.sh anvil-catalog dev && ./scripts/set-version.sh dev && next dev",
"build-dev:anvil-catalog": "scripts/common-build.sh anvil-catalog dev && ./scripts/set-version.sh && next build && npm run postbuild",
"build-prod:anvil-catalog": "./scripts/common-build.sh anvil-catalog prod && ./scripts/set-version.sh && next build && npm run postbuild",
"dev:lungmap": "./scripts/dev.sh lungmap dev && ./scripts/set-version.sh dev && next dev",
"build-dev:lungmap": "./scripts/common-build.sh lungmap dev && ./scripts/set-version.sh && next build && npm run postbuild",
"build-prod:lungmap": "./scripts/common-build.sh lungmap prod && ./scripts/set-version.sh && next build && npm run postbuild",
"dev:anvil-cmg": "./scripts/dev.sh anvil-cmg dev && ./scripts/set-version.sh dev && next dev",
"build:anvil-cmg": "./scripts/build.sh anvil-cmg && ./scripts/set-version.sh && next build && npm run postbuild",
"build-cc-dev:anvil-cmg": "./scripts/common-build.sh anvil-cmg cc-dev && ./scripts/set-version.sh && next build && npm run postbuild",
"dev:hca-dcp": "./scripts/dev.sh hca-dcp dev && ./scripts/set-version.sh dev && next dev",
"dev:cc-ma-dev:hca-dcp": "./scripts/dev.sh hca-dcp cc-ma-dev && ./scripts/set-version.sh dev && next dev",
"build-dev:hca-dcp": "./scripts/common-build.sh hca-dcp dev && ./scripts/set-version.sh && next build && npm run postbuild",
"build-cc-ma-dev:hca-dcp": "./scripts/common-build.sh hca-dcp cc-ma-dev && ./scripts/set-version.sh && next build && npm run postbuild",
"build-ma-dev:hca-dcp": "./scripts/common-build.sh hca-dcp ma-dev && ./scripts/set-version.sh && next build && npm run postbuild",
"build-ma-prod:hca-dcp": "./scripts/common-build.sh hca-dcp ma-prod && ./scripts/set-version.sh && next build && npm run postbuild",
"build-prod:hca-dcp": "./scripts/build.sh hca-dcp prod && ./scripts/set-version.sh && next build && npm run postbuild",
"postbuild": "next-sitemap --config next-sitemap.config.mjs",
"start": "npx serve out",
"lint": "next lint --dir .",
Expand Down
23 changes: 23 additions & 0 deletions scripts/set-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -e

TARGET_ENV_FILE=".env.production"
if [ "$1" == "dev" ]; then
TARGET_ENV_FILE=".env.development"
fi

# Get the current git hash
GIT_HASH=$(git rev-parse HEAD)

# Get the current date and time in PST
BUILD_DATE=$(TZ="America/Los_Angeles" date +"%Y-%m-%d %H:%M:%S %Z")

# Get the current code version from git
VERSION=$(git tag --points-at HEAD)

# Append these values as NEXT_PUBLIC variables
echo "NEXT_PUBLIC_GIT_HASH='$GIT_HASH'" >> "$TARGET_ENV_FILE"
echo "NEXT_PUBLIC_BUILD_DATE='$BUILD_DATE'" >> "$TARGET_ENV_FILE"
echo "NEXT_PUBLIC_VERSION='$VERSION'" >> "$TARGET_ENV_FILE"

echo "Environment variables added to $TARGET_ENV_FILE"

0 comments on commit 2a41e35

Please sign in to comment.