Skip to content

Commit

Permalink
fix: game bridge version strings (#2049)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeSchwert authored Aug 1, 2024
1 parent b639c09 commit 1a9a15a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/build-game-bridge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ env:
DRY_RUN: ${{ github.event.inputs.dry_run }}
GH_TOKEN: ${{ secrets.TS_IMMUTABLE_SDK_GITHUB_TOKEN }}
SDK_TEAM_MEMBERS: ${{ secrets.SDK_TEAM_MEMBERS }}
CI: ${{ github.env.CI }}

jobs:
build-game-bridge:
Expand Down Expand Up @@ -64,14 +65,19 @@ jobs:
run: echo "TS_SDK_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV

- name: Build Game Bridge
run: yarn nx run @imtbl/game-bridge:build
run: yarn nx run @imtbl/game-bridge:build --skip-nx-cache

- name: Cache build artifacts
uses: actions/cache@v4
with:
path: ./packages/game-bridge/dist
key: "${{ runner.os }}-game-bridge-build-${{ env.TS_SDK_TAG }}"

- name: Upload Game Bridge Build
uses: actions/upload-artifact@v4
with:
path: ./packages/game-bridge/dist

create-unity-pr:
name: Create Unity PR
needs: build-game-bridge
Expand Down Expand Up @@ -192,11 +198,9 @@ jobs:
cd ..
- name: Copy Game Bridge Build
# TODO: Update this to copy the correct file
run: cp -r ./packages/game-bridge/dist/unreal/index.js ./unreal-immutable-sdk/Web/index.js

- name: Commit Changes
# TODO: Update this to copy the correct file
run: |
cd unreal-immutable-sdk
git add Web/index.js
Expand Down
46 changes: 21 additions & 25 deletions packages/game-bridge/scripts/updateSdkVersion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
# - TS_SDK_HASH: The git hash of the tag

set -e
if [ -n "$CI" ]; then
set -x
fi
set -x

# The files to update
FILE_PATHS=("./dist/unity/index.html" "./dist/unreal/index.js" "./dist/unreal/index.js.map")
Expand All @@ -22,8 +20,26 @@ do
fi
done

# Check if running in a CI environment
if [ -n "$CI" ]; then
# if running locally, set the environment variables
if [ -z "$CI" ]; then
export TS_SDK_TAG=$(git describe --tags --abbrev=0)
export TS_SDK_HASH=$(git rev-parse $TS_SDK_TAG)

# get the hash of the current HEAD
export TS_SDK_LOCAL_HEAD_HASH=$(git rev-parse HEAD)

# check the hash matches the has from the tag
if [ "$TS_SDK_HASH" != "$TS_SDK_LOCAL_HEAD_HASH" ]; then
# warn the user that the current tag does not match the current HEAD
# but continue with the update
echo "[!!!WARNING!!!]"
echo "[!!!WARNING!!!]"
echo "[!!!WARNING!!!] The current tag does not match the current HEAD. Do not commit this game brige to the Game SDK repos..."
echo "[!!!WARNING!!!]"
echo "[!!!WARNING!!!]"
fi
else
echo "Update SDK version in CI / non-locally"
# Get the current branch name
current_branch=$(git rev-parse --abbrev-ref HEAD)

Expand Down Expand Up @@ -57,26 +73,6 @@ if [ -n "$CI" ]; then
fi
fi

# if running locally, set the environment variables
if [ ! -n "$CI" ]; then
export TS_SDK_TAG=$(git describe --tags --abbrev=0)
export TS_SDK_HASH=$(git rev-parse $TS_SDK_TAG)

# get the hash of the current HEAD
export TS_SDK_LOCAL_HEAD_HASH=$(git rev-parse HEAD)

# check the hash matches the has from the tag
if [ "$TS_SDK_HASH" != "$TS_SDK_LOCAL_HEAD_HASH" ]; then
# warn the user that the current tag does not match the current HEAD
# but continue with the update
echo "[!!!WARNING!!!]"
echo "[!!!WARNING!!!]"
echo "[!!!WARNING!!!] The current tag does not match the current HEAD. Do not commit this game brige to the Game SDK repos..."
echo "[!!!WARNING!!!]"
echo "[!!!WARNING!!!]"
fi
fi

echo "Updating __SDK_VERSION__ to $TS_SDK_TAG"
echo "Updating __SDK_VERSION_SHA__ to $TS_SDK_HASH"

Expand Down

0 comments on commit 1a9a15a

Please sign in to comment.