Skip to content

Commit

Permalink
feat: game bridge build check version string (#2080)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeSchwert authored Aug 7, 2024
1 parent 5447a9e commit da4fb46
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 29 deletions.
48 changes: 29 additions & 19 deletions .github/workflows/build-game-bridge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,35 @@ jobs:
- name: Update Version Strings
run: cd packages/game-bridge && ./scripts/updateSdkVersion.sh

# - name: Check Unity Version String Updated
# if: ${{ github.event.inputs.game_engine == 'Unity' || github.event.inputs.game_engine == 'Both' }}
# run: |
# UNITY_ARTIFACT_PATH="./packages/game-bridge/dist/unity/index.html"
# UNITY_VERSION_STRING_COUNT=$(cat $UNITY_ARTIFACT_PATH | grep -c -o "ts-immutable-sdk-${{ env.TS_SDK_TAG }}")
# if [ "$UNITY_VERSION_STRING_COUNT" -eq 0 ]; then
# echo "Error: Updated version string not found in $UNITY_ARTIFACT_PATH"
# exit 1
# fi

# - name: Check Unreal Version String Updated
# if: ${{ github.event.inputs.game_engine == 'Unreal' || github.event.inputs.game_engine == 'Both' }}
# run: |
# UNREAL_ARTIFACT_PATH="./packages/game-bridge/dist/unreal/index.js"
# UNREAL_VERSION_STRING_COUNT=$(cat $UNREAL_ARTIFACT_PATH | grep -c -o "ts-immutable-sdk-${{ env.TS_SDK_TAG }}")
# if [ "$UNREAL_VERSION_STRING_COUNT" -eq 0 ]; then
# echo "Error: Updated version string not found in $UNREAL_ARTIFACT_PATH"
# exit 1
# fi
- name: Check Unity Version String Updated
if: ${{ github.event.inputs.game_engine == 'Unity' || github.event.inputs.game_engine == 'Both' }}
run: |
UNITY_ARTIFACT_PATH="./packages/game-bridge/dist/unity/index.html"
if [ ! -f "$UNITY_ARTIFACT_PATH" ]; then
echo "Error: Unity artifact file not found at $UNITY_ARTIFACT_PATH"
exit 1
fi
UNITY_VERSION_STRING_COUNT=$(grep -c -o "ts-immutable-sdk-${{ env.TS_SDK_TAG }}" "$UNITY_ARTIFACT_PATH" || true)
if [ "$UNITY_VERSION_STRING_COUNT" -eq 0 ]; then
echo "Error: Updated version string not found in $UNITY_ARTIFACT_PATH"
exit 1
fi
echo "Unity version string updated successfully"
- name: Check Unreal Version String Updated
if: ${{ github.event.inputs.game_engine == 'Unreal' || github.event.inputs.game_engine == 'Both' }}
run: |
UNREAL_ARTIFACT_PATH="./packages/game-bridge/dist/unreal/index.js"
if [ ! -f "$UNREAL_ARTIFACT_PATH" ]; then
echo "Error: Unreal artifact file not found at $UNREAL_ARTIFACT_PATH"
exit 1
fi
UNREAL_VERSION_STRING_COUNT=$(grep -c -o "ts-immutable-sdk-${{ env.TS_SDK_TAG }}" "$UNREAL_ARTIFACT_PATH" || true)
if [ "$UNREAL_VERSION_STRING_COUNT" -eq 0 ]; then
echo "Error: Updated version string not found in $UNREAL_ARTIFACT_PATH"
exit 1
fi
echo "Unreal version string updated successfully"
- name: Cache build artifacts
uses: actions/cache@v4
Expand Down
28 changes: 18 additions & 10 deletions packages/game-bridge/scripts/updateSdkVersion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
# - TS_SDK_HASH: The git hash of the tag

set -e
set -x
# Enable debug mode (set -x) only in CI environment
if [ -n "$CI" ]; then
set -x
fi

# The files to update
FILE_PATHS=("./dist/unity/index.html" "./dist/unreal/index.js" "./dist/unreal/index.js.map")
FILE_PATHS=("./dist/unity/index.html" "./dist/unreal/index.js")

# check files exist
for FILE_PATH in "${FILE_PATHS[@]}"
Expand Down Expand Up @@ -41,15 +44,20 @@ if [ -z "$CI" ]; then
else
echo "Update SDK version in CI / non-locally"
# Get the current branch name
current_branch=$(git rev-parse --abbrev-ref HEAD)
current_branch=${GITHUB_REF#refs/heads/}

# If current_branch is empty, fall back to git command
if [ -z "$current_branch" ]; then
current_branch=$(git rev-parse --abbrev-ref HEAD)
fi

# # Check if the current branch is "main"
# if [ "$current_branch" == "main" ]; then
# echo "You are on the main branch. Continuing..."
# else
# echo "You are not on the main branch. Exiting..."
# exit 1
# fi
# Check if the current branch is "main"
if [ "$current_branch" == "main" ]; then
echo "You are on the main branch. Continuing..."
else
echo "You are not on the main branch. Exiting..."
exit 1
fi

# Check if TS_SDK_TAG environment variable is set
if [ -z "$TS_SDK_TAG" ]; then
Expand Down

0 comments on commit da4fb46

Please sign in to comment.