diff --git a/.github/workflows/check-sdk-version.yaml b/.github/workflows/check-sdk-version.yaml new file mode 100644 index 0000000..771ad1b --- /dev/null +++ b/.github/workflows/check-sdk-version.yaml @@ -0,0 +1,20 @@ +name: Test - Check SDK version + +on: + pull_request + +jobs: + check-sdk-version: + runs-on: ubuntu-20.04 + + steps: + - name: 🏗 Setup repo + uses: actions/checkout@v3 + + - name: 📦 Check it is using the latest version of the SDK + uses: actions/setup-node@v3 + with: + node-version: 18.12.1 + - run: corepack enable + - run: yarn install --immutable + - run: yarn run updateSdkVersion $GITHUB_BASE_REF check \ No newline at end of file diff --git a/.github/workflows/master-pr-tests.yaml b/.github/workflows/master-pr-tests.yaml deleted file mode 100644 index 04b04bc..0000000 --- a/.github/workflows/master-pr-tests.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Test - Master branch PR - -on: - pull_request: - branches: - - master - # triggers when a PR with target to master is opened - -jobs: - check-sdk-version: - runs-on: ubuntu-20.04 - - steps: - - name: 🏗 Setup repo - uses: actions/checkout@v3 - - - name: 📦 Check it is using the latest version of the SDK - uses: actions/setup-node@v3 - with: - node-version: 18.12.1 - - run: corepack enable - - run: echo "YARNLOCK_SHA256_OLD=$(sha256sum yarn.lock)" >> $GITHUB_ENV - - run: yarn up @tonomy/tonomy-id-sdk - - run: echo "YARNLOCK_SHA256_NEW=$(sha256sum yarn.lock)" >> $GITHUB_ENV - - run: if [ "$YARNLOCK_SHA256_NEW" != "$YARNLOCK_SHA256_OLD" ]; then exit 1; fi - # if this step fails, make sure the Tonomy SDK is set to the latest package - # try `yarn up @tonomy/tonomy-id-sdk` and - # then test locally, if it works, then commit changes to package.json and yarn.lock \ No newline at end of file diff --git a/README.md b/README.md index f69bf6d..296018f 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,6 @@ yarn install ``` -For the `development` branch - -```bash -yarn add @tonomy/tonomy-id-sdk@development -``` - ## Running the app ```bash @@ -29,6 +23,14 @@ yarn run start:dev yarn run start:prod ``` +## Update the Tonomy-ID-SDK version to the latest + +```bash +yarn run updateSdkVersion development +# or +yarn run updateSdkVersion master +``` + ## Environment variables and configuration `NODE_ENV` - Determines which config file in `./src/config` to use diff --git a/package.json b/package.json index 65ca0c2..e7c9d08 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "test:watch": "jest --watch", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "jest --config ./test/jest-e2e.json" + "test:e2e": "jest --config ./test/jest-e2e.json", + "updateSdkVersion": "./update_sdk_version.sh" }, "dependencies": { "@nestjs/common": "^10.2.3", @@ -27,7 +28,7 @@ "@nestjs/platform-socket.io": "^10.2.3", "@nestjs/swagger": "^7.1.10", "@nestjs/websockets": "^10.2.3", - "@tonomy/tonomy-id-sdk": "^0.15.0-development.2", + "@tonomy/tonomy-id-sdk": "0.15.0-development.3", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", "hcaptcha": "^0.1.1", diff --git a/update_sdk_version.sh b/update_sdk_version.sh new file mode 100755 index 0000000..6e1ec00 --- /dev/null +++ b/update_sdk_version.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +BRANCH=${1-default} +CHECK=${2-default} + +echo "yarn run updateSdkVersion $@" + +set +e + +# Get the latest version of the SDK for the correct npmjs tag based on branch +if [ "${BRANCH}" == "master" ]; then + VERSION=$(npm view @tonomy/tonomy-id-sdk version) +elif [ "${BRANCH}" == "development" ]; then + VERSION=$(npm view @tonomy/tonomy-id-sdk@development version) +else + # Print help + echo "Usage: yarn run updateSdkVersion master|development [check]" + echo "" + echo "Example: yarn run updateSdkVersion development" + echo "Example: yarn run updateSdkVersion master check" + echo "" + exit 1 +fi + +# Get the sha256sum of yarn.lock before updating the SDK +YARNLOCK_SHA256_OLD=$(sha256sum yarn.lock) + +# Update the SDK +echo "Updating package @tonomy/tonomy-id-sdk@${VERSION}" +yarn up "@tonomy/tonomy-id-sdk@${VERSION}" + +# Get the sha256sum of yarn.lock after updating the SDK +YARNLOCK_SHA256_NEW=$(sha256sum yarn.lock) + +if [ "${CHECK}" == "check" ]; then + echo "Checking if yarn.lock has changed" + if [ "${YARNLOCK_SHA256_NEW}" != "${YARNLOCK_SHA256_OLD}" ]; then + echo "yarn.lock has changed while updating @tonomy/tonomy-id-sdk@${VERSION}" + echo "Please run \"yarn run installSdkVersion\" to fix" + exit 1 + fi +fi \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 3cf2184..783910a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1576,9 +1576,9 @@ __metadata: languageName: node linkType: hard -"@tonomy/tonomy-id-sdk@npm:^0.15.0-development.2": - version: 0.15.0-development.2 - resolution: "@tonomy/tonomy-id-sdk@npm:0.15.0-development.2" +"@tonomy/tonomy-id-sdk@npm:0.15.0-development.3": + version: 0.15.0-development.3 + resolution: "@tonomy/tonomy-id-sdk@npm:0.15.0-development.3" dependencies: "@consento/sync-randombytes": ^1.0.5 "@tonomy/antelope-did": ^0.1.5 @@ -1593,7 +1593,7 @@ __metadata: elliptic: ^6.5.4 socket.io-client: ^4.5.4 universal-base64url: ^1.1.0 - checksum: 33d6031035c480da14ad603a7bb4e94ffcc6138677ae9fcf301f962a96328a449ee636c7fdec7825bda79853b93fc9781586da62eae341763c6686c3b58afcdc + checksum: 6ddbf3175f95f994fdba13d9d99d2ae9454b54a8bc264bb754c59fd3aa40460a6856fe4270710bfa4a6e735505753cb4a205c25fe0ff8dbd2b863387165158b4 languageName: node linkType: hard @@ -7713,7 +7713,7 @@ __metadata: "@nestjs/swagger": ^7.1.10 "@nestjs/testing": ^10.2.3 "@nestjs/websockets": ^10.2.3 - "@tonomy/tonomy-id-sdk": ^0.15.0-development.2 + "@tonomy/tonomy-id-sdk": 0.15.0-development.3 "@types/express": ^4.17.13 "@types/jest": 29.2.4 "@types/node": 18.11.18