Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add version info to environment (#2548) #2549

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "2.1.0",
"private": true,
"scripts": {
"dev": "./scripts/dev.sh data-portal && next dev",
"build-dev:data-portal": "scripts/common-build.sh data-portal dev && next build && npm run postbuild",
"build-prod:data-portal": "./scripts/common-build.sh data-portal prod && next build && npm run postbuild",
"dev": "./scripts/dev.sh data-portal && ./scripts/set-version.sh dev && next dev",
"build-dev:data-portal": "./scripts/common-build.sh data-portal dev && ./scripts/set-version.sh && next build && npm run postbuild",
"build-prod:data-portal": "./scripts/common-build.sh data-portal prod && ./scripts/set-version.sh && next build && npm run postbuild",
"build": "next build",
"start": "npx serve out",
"lint": "next lint",
Expand Down
5 changes: 0 additions & 5 deletions scripts/build.sh

This file was deleted.

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"
Loading