From 62f2b17f436ed18157955448cbb63fe44ef8d3af Mon Sep 17 00:00:00 2001 From: Cedric Guillemet <1312968+CedricGuillemet@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:20:46 +0100 Subject: [PATCH 1/4] github workflow, npm description --- .github/workflows/wasmPublish.yml | 51 +++++++++++++++++++++++++++++++ web/npm/package.json | 14 +++++++++ web/npm/readme.md | 1 + 3 files changed, 66 insertions(+) create mode 100644 .github/workflows/wasmPublish.yml create mode 100644 web/npm/package.json create mode 100644 web/npm/readme.md diff --git a/.github/workflows/wasmPublish.yml b/.github/workflows/wasmPublish.yml new file mode 100644 index 00000000..70be8251 --- /dev/null +++ b/.github/workflows/wasmPublish.yml @@ -0,0 +1,51 @@ +# Simple workflow that builds wasm and publish to npm registry +name: Build and publish wasm + +on: + # Runs on pushes targeting the default branch + push: + branches: ["dev"] + +jobs: + tinyusdz-wasm: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + - name: Setup Emscripten SDK + run: | + git clone https://github.com/emscripten-core/emsdk.git + cd emsdk + # from https://github.com/Twinklebear/webgpu-cpp-usdz/blob/main/.github/workflows/deploy-page.yml + # TODO: 3.1.52 has a change to WebGPU API that is incompatible + # with the C++ bindings I have in the repo? + ./emsdk install 3.1.51 + ./emsdk activate 3.1.51 + - name: Configure + run: | + source ./emsdk/emsdk_env.sh + cd web + mkdir cmake-build + cd cmake-build + emcmake cmake .. -DCMAKE_BUILD_TYPE=MinSizeRel + - name: Build WASM + working-directory: ${{ github.workspace }}/web/cmake-build + run: | + source ../../emsdk/emsdk_env.sh + make + + - name: Prepare npm + working-directory: ${{ github.workspace }}/web/npm + run: | + cp ../web/main.js . + + - name: Upload artifact + uses: actions/upload-pages-artifact@v4 + with: + # Upload web/npm folder + path: ${{ github.workspace }}/web/npm + - name: Deploy to NPM + uses: actions/deploy-pages@v4 diff --git a/web/npm/package.json b/web/npm/package.json new file mode 100644 index 00000000..a4021e7a --- /dev/null +++ b/web/npm/package.json @@ -0,0 +1,14 @@ +{ + "name": "tinyusdz", + "version": "0.0.1", + "description": "Tinyusdz wasm", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "usdz" + ], + "author": "", + "license": "ISC" +} diff --git a/web/npm/readme.md b/web/npm/readme.md new file mode 100644 index 00000000..f013f3f7 --- /dev/null +++ b/web/npm/readme.md @@ -0,0 +1 @@ +# Tinyusdz \ No newline at end of file From 0d81439ff3bb3dbb5344fdbc1ffedcd9387d6564 Mon Sep 17 00:00:00 2001 From: Cedric Guillemet <1312968+CedricGuillemet@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:27:13 +0100 Subject: [PATCH 2/4] upload artifact --- .github/workflows/wasmPublish.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasmPublish.yml b/.github/workflows/wasmPublish.yml index 70be8251..15b45233 100644 --- a/.github/workflows/wasmPublish.yml +++ b/.github/workflows/wasmPublish.yml @@ -43,9 +43,10 @@ jobs: cp ../web/main.js . - name: Upload artifact - uses: actions/upload-pages-artifact@v4 + uses: actions/upload-artifact@v4 with: - # Upload web/npm folder + name: 'tinyusdz' path: ${{ github.workspace }}/web/npm + - name: Deploy to NPM uses: actions/deploy-pages@v4 From 746dcc2dec7dded06c8549c918d709ede5e28d90 Mon Sep 17 00:00:00 2001 From: Cedric Guillemet <1312968+CedricGuillemet@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:37:57 +0100 Subject: [PATCH 3/4] dist folder --- .github/workflows/wasmPublish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wasmPublish.yml b/.github/workflows/wasmPublish.yml index 15b45233..e9133488 100644 --- a/.github/workflows/wasmPublish.yml +++ b/.github/workflows/wasmPublish.yml @@ -40,7 +40,7 @@ jobs: - name: Prepare npm working-directory: ${{ github.workspace }}/web/npm run: | - cp ../web/main.js . + cp ../dist/* . - name: Upload artifact uses: actions/upload-artifact@v4 From 9f7e8ec44b2433202fc11c4f87cfb80132576186 Mon Sep 17 00:00:00 2001 From: Cedric Guillemet <1312968+CedricGuillemet@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:51:36 +0100 Subject: [PATCH 4/4] workflow update --- .github/workflows/wasmPublish.yml | 31 +++++++++++++++++++++++++------ web/npm/package.json | 2 +- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.github/workflows/wasmPublish.yml b/.github/workflows/wasmPublish.yml index e9133488..d695a5d6 100644 --- a/.github/workflows/wasmPublish.yml +++ b/.github/workflows/wasmPublish.yml @@ -2,9 +2,23 @@ name: Build and publish wasm on: - # Runs on pushes targeting the default branch - push: - branches: ["dev"] + workflow_dispatch: + inputs: + release_version: + description: 'NPM Release Version' + required: true + type: string + default: 1.0.0 + NPM_tag: + description: 'NPM Tag' + required: true + type: string + default: preview + NPM_publish_arg: + description: 'NPM Publish arg' + required: false + type: string + default: --dry-run jobs: tinyusdz-wasm: @@ -47,6 +61,11 @@ jobs: with: name: 'tinyusdz' path: ${{ github.workspace }}/web/npm - - - name: Deploy to NPM - uses: actions/deploy-pages@v4 + + - name: Version & Publish Package + run: | + npm version --no-git-tag-version ${{ github.event.inputs.release_version }} + npm publish --access public --tag ${{ github.event.inputs.NPM_tag }} ${{ github.event.inputs.NPM_publish_arg }} + working-directory: ${{ github.workspace }}/web/npm + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/web/npm/package.json b/web/npm/package.json index a4021e7a..411d6ac7 100644 --- a/web/npm/package.json +++ b/web/npm/package.json @@ -2,7 +2,7 @@ "name": "tinyusdz", "version": "0.0.1", "description": "Tinyusdz wasm", - "main": "index.js", + "main": "tinyusdz.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" },