Skip to content

Commit 85d404a

Browse files
Merge branch 'main' into DVR-342-example-app-content-parser
2 parents ba1bcf9 + 5a30af2 commit 85d404a

File tree

119 files changed

+768
-3121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+768
-3121
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package.json @immutable/passport
1717
/packages/passport @immutable/passport
1818
/packages/x-provider @immutable/passport
1919
/packages/checkout @immutable/passport
20-
/packages/checkout/widgets-lib @immutable/passport
20+
/packages/checkout/widgets-lib @immutable/gamefi
2121
/packages/blockchain-data @immutable/activation
2222
/packages/minting-backend @shineli1984
2323
/packages/webhook @shineli1984

.github/scripts/check-docs-deployed.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ then
88
echo "VERSION is not set"
99
exit 1
1010
fi
11-
11+
MAJOR_VERSION=$(echo $VERSION | sed -E 's/^(prelease-)?([0-9]+)\..*/\2/')
1212
# this command will send a GET request to the docs site, the -s option silences the output,
1313
# the -o option redirects the output to /dev/null, and the -w option formats the output to only return the HTTP status code
14-
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://docs.immutable.com/sdk-references/ts-immutable-sdk/$VERSION/)
14+
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://docs.immutable.com/sdk-references/ts-immutable-sdk/v$MAJOR_VERSION/)
1515

1616
if [ "$HTTP_STATUS" -ne 200 ]; then
1717
echo "SDK reference docs for v$VERSION are not deployed. Check Netlify for the build status. https://app.netlify.com/sites/imx-docs-prod/deploys"

.github/scripts/check-docs-version.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@ then
1515
exit 1
1616
fi
1717

18-
# check a docs folder with the same version exists in $CLONE_DIR
19-
if [ -d "$CLONE_DIR/api-docs/sdk-references/ts-immutable-sdk/$VERSION" ]; then
20-
echo "There is already a docs folder for v$VERSION. Please create a separate PR to update the SDK reference docs for v$VERSION."
21-
exit 1
22-
fi
18+
# Extract major version only
19+
MAJOR_VERSION=$(echo $VERSION | cut -d. -f1)
2320

24-
# check the version contains `alpha` string
25-
if echo "$VERSION" | grep -q "alpha"; then
26-
echo "Skipping docs generation for alpha version"
27-
exit 1
28-
fi
21+
echo "Checking if docs folder for v$VERSION / v$MAJOR_VERSION exists"
22+
23+
# Remove any check for existing folders - we want to overwrite
24+
25+
echo "Will generate docs for v$VERSION in the v$MAJOR_VERSION folder"

.github/scripts/push-docs.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ then
1515
exit 1
1616
fi
1717

18-
# Do not remove the trailing period!!!
19-
# https://dev.to/ackshaey/macos-vs-linux-the-cp-command-will-trip-you-up-2p00
18+
# Extract major version only - handle both regular and prelease tags
19+
MAJOR_VERSION=$(echo $VERSION | sed -E 's/^(prelease-)?([0-9]+)\..*/\2/')
20+
# Use v{MAJOR} format for the folder
2021
INPUT_SOURCE_FOLDER="./docs/."
2122
INPUT_DESTINATION_REPO="immutable/docs"
2223
INPUT_DESTINATION_HEAD_BRANCH="ts-immutable-sdk-docs-$VERSION"
23-
INPUT_DESTINATION_FOLDER="$CLONE_DIR/api-docs/sdk-references/ts-immutable-sdk/$VERSION"
24+
INPUT_DESTINATION_FOLDER="$CLONE_DIR/api-docs/sdk-references/ts-immutable-sdk/v$MAJOR_VERSION"
2425

2526
if [ -z "$INPUT_PULL_REQUEST_REVIEWERS" ]
2627
then
@@ -30,6 +31,12 @@ else
3031
fi
3132

3233
echo "Copying contents to git repo"
34+
# Clear existing vX folder if it exists
35+
if [ -d "$INPUT_DESTINATION_FOLDER" ]; then
36+
echo "Cleaning existing v$MAJOR_VERSION folder..."
37+
rm -rf "$INPUT_DESTINATION_FOLDER"/*
38+
fi
39+
3340
mkdir -p $INPUT_DESTINATION_FOLDER
3441

3542
if [ -d "$INPUT_DESTINATION_FOLDER" ]; then

.github/scripts/update-docs-link.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,27 @@ then
1515
exit 1
1616
fi
1717

18+
# Extract major version for folder paths
19+
MAJOR_VERSION=$(echo $VERSION | cut -d. -f1)
20+
1821
(
1922
cd $CLONE_DIR;
2023
FILE=src/components/UnifiedSDKLink/index.tsx
2124
if [ "$(uname)" == "Darwin" ]; then
2225
# On Mac OS, sed requires an empty string as an argument to -i to avoid creating a backup file
23-
sed -i '' -E "s/SDK_VERSION = '.*'/SDK_VERSION = '$VERSION'/g;" $FILE
26+
sed -i '' -E "s/SDK_VERSION = '.*'/SDK_VERSION = 'v$MAJOR_VERSION'/g;" $FILE
2427
else
25-
sed -i -E "s/SDK_VERSION = '.*'/SDK_VERSION = '$VERSION'/g;" $FILE
28+
sed -i -E "s/SDK_VERSION = '.*'/SDK_VERSION = 'v$MAJOR_VERSION'/g;" $FILE
2629
fi
2730

2831
FILE2=sidebars/sidebars-docs.js
2932
if [ "$(uname)" == "Darwin" ]; then
3033
# On Mac OS, sed requires an empty string as an argument to -i to avoid creating a backup file
31-
sed -i '' -E "s/SDK_VERSION = '.*'/SDK_VERSION = '$VERSION'/g;" $FILE2
34+
sed -i '' -E "s/SDK_VERSION = '.*'/SDK_VERSION = 'v$MAJOR_VERSION'/g;" $FILE2
3235
else
33-
sed -i -E "s/SDK_VERSION = '.*'/SDK_VERSION = '$VERSION'/g;" $FILE2
36+
sed -i -E "s/SDK_VERSION = '.*'/SDK_VERSION = 'v$MAJOR_VERSION'/g;" $FILE2
3437
fi
3538

36-
3739
major=$(echo $VERSION | awk '{
3840
split($0, a, ".");
3941
print a[1];

.github/workflows/build-game-bridge.yaml

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,41 +64,32 @@ jobs:
6464
- name: Set TS SDK hash
6565
run: echo "TS_SDK_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
6666

67-
- name: Build Game Bridge
68-
run: pnpm nx run @imtbl/game-bridge:build --skip-nx-cache
69-
70-
- name: Update Version Strings
71-
run: cd packages/game-bridge && ./scripts/updateSdkVersion.sh
72-
73-
- name: Check Unity Version String Updated
74-
if: ${{ github.event.inputs.game_engine == 'Unity' || github.event.inputs.game_engine == 'Both' }}
67+
- name: Update 'version' in 'sdk/package.json' from '0.0.0' to '${{ env.TS_SDK_TAG }}'
7568
run: |
76-
UNITY_ARTIFACT_PATH="./packages/game-bridge/dist/unity/index.html"
77-
if [ ! -f "$UNITY_ARTIFACT_PATH" ]; then
78-
echo "Error: Unity artifact file not found at $UNITY_ARTIFACT_PATH"
79-
exit 1
80-
fi
81-
UNITY_VERSION_STRING_COUNT=$(grep -c -o "ts-immutable-sdk-${{ env.TS_SDK_TAG }}" "$UNITY_ARTIFACT_PATH" || true)
82-
if [ "$UNITY_VERSION_STRING_COUNT" -eq 0 ]; then
83-
echo "Error: Updated version string not found in $UNITY_ARTIFACT_PATH"
84-
exit 1
69+
if [[ "$OSTYPE" == "darwin"* ]]; then
70+
sed -i '' "s/\"version\": \"0.0.0\"/\"version\": \"${{ env.TS_SDK_TAG }}\"/g" sdk/package.json
71+
else
72+
sed -i "s/\"version\": \"0.0.0\"/\"version\": \"${{ env.TS_SDK_TAG }}\"/g" sdk/package.json
8573
fi
86-
echo "Unity version string updated successfully"
8774
88-
- name: Check Unreal Version String Updated
89-
if: ${{ github.event.inputs.game_engine == 'Unreal' || github.event.inputs.game_engine == 'Both' }}
75+
- name: Update 'sdkVersionTag' in 'packages/game-bridge/src/index.ts' from '__SDK_VERSION__' to '${{ env.TS_SDK_TAG }}'
9076
run: |
91-
UNREAL_ARTIFACT_PATH="./packages/game-bridge/dist/unreal/index.js"
92-
if [ ! -f "$UNREAL_ARTIFACT_PATH" ]; then
93-
echo "Error: Unreal artifact file not found at $UNREAL_ARTIFACT_PATH"
94-
exit 1
77+
if [[ "$OSTYPE" == "darwin"* ]]; then
78+
sed -i '' "s/__SDK_VERSION__/${{ env.TS_SDK_TAG }}/g" packages/game-bridge/src/index.ts
79+
else
80+
sed -i "s/__SDK_VERSION__/${{ env.TS_SDK_TAG }}/g" packages/game-bridge/src/index.ts
9581
fi
96-
UNREAL_VERSION_STRING_COUNT=$(grep -c -o "ts-immutable-sdk-${{ env.TS_SDK_TAG }}" "$UNREAL_ARTIFACT_PATH" || true)
97-
if [ "$UNREAL_VERSION_STRING_COUNT" -eq 0 ]; then
98-
echo "Error: Updated version string not found in $UNREAL_ARTIFACT_PATH"
99-
exit 1
82+
83+
- name: Update 'sdkVersionSha' in 'packages/game-bridge/src/index.ts' from '__SDK_VERSION_SHA__' to '${{ env.TS_SDK_HASH }}'
84+
run: |
85+
if [[ "$OSTYPE" == "darwin"* ]]; then
86+
sed -i '' "s/__SDK_VERSION_SHA__/${{ env.TS_SDK_HASH }}/g" packages/game-bridge/src/index.ts
87+
else
88+
sed -i "s/__SDK_VERSION_SHA__/${{ env.TS_SDK_HASH }}/g" packages/game-bridge/src/index.ts
10089
fi
101-
echo "Unreal version string updated successfully"
90+
91+
- name: Build Game Bridge
92+
run: pnpm nx run @imtbl/game-bridge:build --skip-nx-cache
10293

10394
- name: Cache build artifacts
10495
uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f

.github/workflows/pr.yaml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,6 @@ jobs:
8080
- name: Setup playwright
8181
uses: ./.github/actions/setup-playwright
8282

83-
# Temporary disabled until we can release v2, since the tests are failing due to breaking changes
84-
# - name: Prepare Checkout SDK bundle for @examples/commerce-widget-nextjs
85-
# run: pnpm --filter @imtbl/checkout-sdk prepare:examplesdk
86-
87-
# - name: Prepare widgets bundle for @examples/commerce-widget-nextjs
88-
# run: pnpm --filter @imtbl/checkout-widgets prepare:examplewidgets
89-
9083
- name: Test examples
9184
run: pnpm test:examples
9285

@@ -137,25 +130,9 @@ jobs:
137130

138131
- name: Prepare tests
139132
run: pnpm prepare:tests
140-
141-
# Temporary disabled until we can release v2, since the tests are failing due to breaking changes
142-
# - name: Install SDK at current version for @tests/checkout-widgets-nextjs
143-
# run: pnpm --filter @tests/checkout-widgets-nextjs add @imtbl/sdk@$(npm view @imtbl/sdk version)
144-
145-
# - name: Build @tests/checkout-widgets-nextjs
146-
# run: pnpm --filter @tests/checkout-widgets-nextjs build
147-
148-
# - name: Prepare Checkout SDK bundle for @tests/checkout-widgets-nextjs
149-
# run: pnpm --filter @imtbl/checkout-sdk prepare:testsdk
150-
151-
# - name: Prepare widgets bundle for @tests/checkout-widgets-nextjs
152-
# run: pnpm --filter @imtbl/checkout-widgets prepare:testwidgets
153133

154134
- name: Update modules
155135
run: pnpm install --frozen-lockfile=false
156136

157-
- name: Setup playwright
158-
uses: ./.github/actions/setup-playwright
159-
160137
- name: Run functional tests
161138
run: pnpm --filter "@tests/*" --parallel func-test:ci

.github/workflows/publish.yaml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,6 @@ jobs:
105105

106106
- name: Build SDK & Checkout Widgets
107107
run: pnpm build
108-
109-
- name: Generate version.json
110-
if: (env.DRY_RUN) == 'false'
111-
run: |
112-
echo '{ "version": "$(jq -r '.version' ./sdk/package.json)" }' > ./sdk/version.json
113-
cp ./sdk/version.json ./sdk/dist/
114108

115109
- name: Pack SDK & Checkout Widgets packages and dependencies
116110
run: pnpm pack-npm-packages
@@ -128,8 +122,8 @@ jobs:
128122
- name: Tag Git Pre-Release
129123
if: ${{ startsWith(env.RELEASE_TYPE, 'pre') }}
130124
run: |
131-
git tag -a $(jq -r '.version' ./sdk/package.json) -m "$(jq -r '.version' ./sdk/package.json)"
132-
git push origin $(jq -r '.version' ./sdk/package.json)
125+
git tag -a "prelease-$(jq -r '.version' ./sdk/package.json)" -m "$(jq -r '.version' ./sdk/package.json)"
126+
git push origin "prelease-$(jq -r '.version' ./sdk/package.json)"
133127
134128
- name: Release to NPM
135129
id: npm_release
@@ -177,7 +171,7 @@ jobs:
177171
echo "Waiting for NPM registry to reflect version: $VERSION"
178172
179173
for i in {1..20}; do
180-
LATEST_VERSION=$(if [[ "${{ startsWith(env.RELEASE_TYPE, 'pre') }}" == "true" ]]; then npm view @imtbl/sdk@alpha version; else npm view @imtbl/sdk@latest version; fi)
174+
LATEST_VERSION=$(if [[ "${{ startsWith(env.RELEASE_TYPE, 'pre') }}" == "true" ]]; then npm view @imtbl/sdk@alpha version; else npm view @imtbl/checkout-widgets@latest version; fi)
181175
if [[ "$LATEST_VERSION" == "$VERSION" ]]; then
182176
echo "NPM registry updated to version: $LATEST_VERSION"
183177
exit 0
@@ -189,9 +183,9 @@ jobs:
189183
echo "NPM registry failed to update after 5 minutes."
190184
exit 1
191185
192-
- name: Purge CDN Cache for version.json
186+
- name: Purge CDN Cache for Checkout Widgets
193187
id: purge_cdn
194188
if: ${{ !startsWith(env.RELEASE_TYPE, 'pre') }} && env.DRY_RUN == 'false'
195189
run: |
196-
curl -X GET https://purge.jsdelivr.net/npm/@imtbl/sdk@latest/dist/version.json
197-
echo "CDN cache purged for https://cdn.jsdelivr.net/npm/@imtbl/sdk@latest/dist/version.json"
190+
curl -X GET https://purge.jsdelivr.net/npm/@imtbl/checkout-widgets@latest
191+
echo "CDN cache purged for https://cdn.jsdelivr.net/npm/@imtbl/checkout-widgets@latest"

.github/workflows/title-validation.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ on:
77
types:
88
- opened
99
- edited
10-
merge_group:
11-
branches:
12-
- main
1310

1411
permissions:
1512
pull-requests: read
@@ -20,7 +17,6 @@ env:
2017
jobs:
2118
title-validation:
2219
name: Validate PR title
23-
if: ${{ github.event.action == 'opened' || github.event.changes.title.from }}
2420
runs-on: ubuntu-latest
2521
steps:
2622
- uses: amannn/action-semantic-pull-request@40166f00814508ec3201fc8595b393d451c8cd80

CONTRIBUTING.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
- [Creating Pull Requests](#creating-pull-requests)
1313
- [Title](#title)
1414
- [Description](#description)
15+
- [Publishing](#publishing)
16+
- [v2](#v2)
17+
- [v1 (legacy)](#v1-legacy)
1518

1619
## Setting Up Your Environment
1720

@@ -148,4 +151,69 @@ When creating PR descriptions, start it with a section on one-line Customer Impa
148151
* `Deprecated` for soon-to-be removed features.
149152
* `Removed` for now removed features.
150153
* `Fixed` for any bug fixes.
151-
* `Security` in case of vulnerabilities.
154+
* `Security` in case of vulnerabilities.
155+
156+
## Publishing
157+
158+
### v2
159+
160+
To publish a new version of the v2 SDK:
161+
162+
1. **Ensure your changes are merged into the `main` branch**
163+
- All v2 SDK changes must be merged into the main branch
164+
165+
2. **Run the publish GitHub Action**
166+
- Go to Actions tab in the repository
167+
- Select the "Publish to NPM" workflow
168+
- Click "Run workflow"
169+
- Select the `main` branch
170+
- Choose the appropriate release type:
171+
- `prerelease`: Increments the prerelease version (e.g., 2.0.0-alpha.1 → 2.0.0-alpha.2)
172+
- `prepatch`: Increments the patch version and adds prerelease suffix (e.g., 2.0.0 → 2.0.1-alpha.0)
173+
- `preminor`: Increments the minor version and adds prerelease suffix (e.g., 2.0.0 → 2.1.0-alpha.0)
174+
- `premajor`: Increments the major version and adds prerelease suffix (e.g., 2.0.0 → 3.0.0-alpha.0)
175+
- `patch`: Increments the patch version (e.g., 2.0.0 → 2.0.1)
176+
- `minor`: Increments the minor version (e.g., 2.0.0 → 2.1.0)
177+
- `major`: Increments the major version (e.g., 2.0.0 → 3.0.0)
178+
- Note: Major version releases can only be performed by administrators or authorized SDK team members
179+
- Optionally check "Dry run" to simulate the publishing process without actually publishing
180+
- Click "Run workflow"
181+
182+
3. **Monitor the workflow execution**
183+
- The workflow will build the SDK, generate version files, create a GitHub release (for non-prerelease versions), and publish to npm
184+
- If successful, Slack notifications will be sent to the SDK team
185+
- The CDN cache will be purged for non-prerelease versions to ensure the latest version is available
186+
187+
Note: Prerelease versions are published with the `alpha` tag on npm, while regular releases are published with the `latest` tag.
188+
189+
### v1 (legacy)
190+
191+
The v1 SDK is maintained in the `legacy-v1` branch and uses a different publishing process.
192+
193+
To publish a new version of the v1 SDK:
194+
195+
1. **Ensure your changes are merged into the `legacy-v1` branch**
196+
- All v1 SDK changes must be merged into the legacy-v1 branch
197+
198+
2. **Run the publish GitHub Action**
199+
- Go to Actions tab in the repository
200+
- Select the "Publish to NPM" workflow
201+
- Click "Run workflow"
202+
- Select the `legacy-v1` branch
203+
- Choose the appropriate release type:
204+
- `alpha`: Publishes a prerelease version with the "alpha-legacy" tag
205+
- `release`: Publishes a stable release with the "legacy" tag
206+
- Choose the appropriate upgrade type:
207+
- `none`: Only increments the revision for alpha releases, no change for stable releases
208+
- `patch`: Increments the patch version (e.g., 1.0.0 → 1.0.1)
209+
- `minor`: Increments the minor version (e.g., 1.0.0 → 1.1.0)
210+
- Optionally check "Dry run" to simulate the publishing process without actually publishing
211+
- Click "Run workflow"
212+
213+
3. **Monitor the workflow execution**
214+
- The workflow will validate the version (ensuring it starts with "1."), run tests, build the SDK, and publish to npm
215+
- For stable releases, it will also create a GitHub release and purge the CDN cache
216+
- If successful, Slack notifications will be sent to the SDK team
217+
218+
Note: The v1 SDK publish workflow will only accept version numbers that start with "1." to ensure it publishes legacy versions.
219+

0 commit comments

Comments
 (0)