diff --git a/.github/actions/build_package/action.yml b/.github/actions/build_package/action.yml index 38fb190f..dc796dad 100644 --- a/.github/actions/build_package/action.yml +++ b/.github/actions/build_package/action.yml @@ -8,9 +8,9 @@ runs: using: "composite" steps: - name: Setup node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: '18.x' + node-version: '20.x' - name: Install dev dependencies if: inputs.mode != 'prod' shell: bash diff --git a/.github/actions/upload_minified_version/action.yml b/.github/actions/upload_minified_version/action.yml new file mode 100644 index 00000000..045e95b8 --- /dev/null +++ b/.github/actions/upload_minified_version/action.yml @@ -0,0 +1,70 @@ +name: minify + +inputs: + package: + description: Selected package to minify + required: true + tag: + description: Tag to checkout + required: true + +runs: + using: "composite" + steps: + - name: Checkout source code + uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag }} + fetch-tags: true + path: ./tmp + + - name: Copy packages + shell: bash + run: | + rm -rf ./packages/* + cp ./tmp/packages/* ./packages + + - name: Run build + uses: ./.github/actions/build_package + with: + mode: 'prod' + + - name: Set PACKAGE + shell: bash + run: | + echo "PACKAGE=$(echo ${{ inputs.package }} | sed 's/@inworld\///g')" >> $GITHUB_ENV + + - name: Extract version + shell: bash + run: | + echo "VERSION=$(node -e "console.log(require('./packages/${{ env.PACKAGE }}/package.json').version)")" >> $GITHUB_ENV + id: extract-version + + - name: Set OUTPUT + shell: bash + run: | + echo "OUTPUT=packages/${{ env.PACKAGE }}/dist/inworld-${{ env.PACKAGE }}-${{ env.VERSION }}.min.js" >> $GITHUB_ENV + + - name: Minify + shell: bash + run: | + npx yarn workspace ${{ inputs.package }} minify + + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@v2 + with: + workload_identity_provider: ${{ env.AUTH_IDENTITY_PROVIDER }} + service_account: ${{ env.AUTH_SERVICE_ACCOUNT }} + create_credentials_file: true + + - name: Rename minified file + shell: bash + run: | + mv packages/${{ env.PACKAGE }}/dist/inworld-${{ env.PACKAGE }}.min.js ${{ env.OUTPUT }} + + - name: Upload to GCS + uses: 'google-github-actions/upload-cloud-storage@v2' + with: + path: ${{ env.OUTPUT }} + destination: 'innequin-assets/packages' + process_gcloudignore: false diff --git a/.github/workflows/minify.yml b/.github/workflows/minify.yml index 1d4d3d96..fa92a68e 100644 --- a/.github/workflows/minify.yml +++ b/.github/workflows/minify.yml @@ -11,7 +11,7 @@ on: - '@inworld/web-threejs' version: type: string - description: "The version of package to minify. The version should be the same as version in package.json. For example, 1.0.0" + description: "The version of package to minify. The version should be the same as version in package.json. For example, 1.0.0. Otherwise, the latest version will be used." required: false env: @@ -28,51 +28,24 @@ jobs: id-token: 'write' steps: - - name: Set TAG - run: echo "TAG=refs/tags/${{ inputs.package }}@${{ inputs.version }}" >> $GITHUB_ENV - if: inputs.version != '' - - name: Checkout source code uses: actions/checkout@v4 with: - ref: ${{ env.TAG }} - fetch-tags: true - - - name: Run build - uses: ./.github/actions/build_package - with: - package: ${{ inputs.package }} - - - name: Set PACKAGE - run: | - echo "PACKAGE=$(echo ${{ inputs.package }} | sed 's/@inworld\///g')" >> $GITHUB_ENV + fetch-depth: 0 - - name: Extract version - run: | - echo "VERSION=$(node -e "console.log(require('./packages/${{ env.PACKAGE }}/package.json').version)")" >> $GITHUB_ENV - id: extract-version - - - name: Set OUTPUT - run: | - echo "OUTPUT=packages/${{ env.PACKAGE }}/dist/inworld-${{ env.PACKAGE }}-${{ env.VERSION }}.min.js" >> $GITHUB_ENV - - - name: Minify - run: | - npx yarn workspace ${{ inputs.package }} minify - - - name: Authenticate to Google Cloud - uses: google-github-actions/auth@v2 - with: - workload_identity_provider: ${{ env.AUTH_IDENTITY_PROVIDER }} - service_account: ${{ env.AUTH_SERVICE_ACCOUNT }} - create_credentials_file: true + - name: Set TAG from inputs + run: echo "TAG=refs/tags/${{ inputs.package }}@${{ inputs.version }}" >> $GITHUB_ENV + if: inputs.version != '' - - name: Rename minified file - run: | - mv packages/${{ env.PACKAGE }}/dist/inworld-${{ env.PACKAGE }}.min.js ${{ env.OUTPUT }} + - name: Set TAG as the latest one + run: echo "TAG=refs/tags/`echo $(git describe --tags --match="${{ inputs.package }}*" --abbrev=0)`" >> $GITHUB_ENV + if: inputs.version == '' - - name: Upload to GCS - uses: 'google-github-actions/upload-cloud-storage@v2' + - name: Minify and upload + uses: ./.github/actions/upload_minified_version with: - path: ${{ env.OUTPUT }} - destination: 'innequin-assets/packages' + package: ${{ inputs.package }} + tag: ${{ env.TAG }} + env: + AUTH_SERVICE_ACCOUNT: ${{ env.AUTH_SERVICE_ACCOUNT }} + AUTH_IDENTITY_PROVIDER: ${{ env.AUTH_IDENTITY_PROVIDER }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 645d1684..ab3becc6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,10 @@ on: - '@inworld/web-core' - '@inworld/web-threejs' +env: + AUTH_SERVICE_ACCOUNT: inworld-web-sdk@inworld-ai-github.iam.gserviceaccount.com + AUTH_IDENTITY_PROVIDER: projects/678423885598/locations/global/workloadIdentityPools/github-devops-pool/providers/github-prvdr + jobs: github-release: runs-on: ubuntu-latest @@ -55,6 +59,28 @@ jobs: - name: Publish to npm run: npx yarn workspace ${{ inputs.package }} release:publish + minify-and-upload: + runs-on: [self-hosted, linux, x64, kubernetes, ephemeral] + # needs: [npm-release] + permissions: + contents: 'read' + id-token: 'write' + steps: + - name: Checkout source code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set TAG as the latest one + run: echo "TAG=refs/tags/`echo $(git describe --tags --match="${{ inputs.package }}*" --abbrev=0)`" >> $GITHUB_ENV + - name: Minify and upload + uses: ./.github/actions/upload_minified_version + with: + package: ${{ inputs.package }} + tag: ${{ env.TAG }} + env: + AUTH_SERVICE_ACCOUNT: ${{ env.AUTH_SERVICE_ACCOUNT }} + AUTH_IDENTITY_PROVIDER: ${{ env.AUTH_IDENTITY_PROVIDER }} + release-notification: runs-on: [self-hosted, kubernetes, nodocker] needs: [github-release, npm-release] diff --git a/packages/web-core/tsconfig.json b/packages/web-core/tsconfig.json index 494f2632..a0da52e5 100644 --- a/packages/web-core/tsconfig.json +++ b/packages/web-core/tsconfig.json @@ -16,7 +16,7 @@ "outDir": "build", "resolveJsonModule": true, "skipLibCheck": true, - "target": "es2015", + "target": "es2017", "types": [ "jest", "node"