Publish Package to npmjs #41
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Package to npmjs | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| publish: | |
| description: "Publish to NPM" | |
| required: false | |
| type: boolean | |
| vulkan: | |
| description: "Build a Vulkan Binary" | |
| required: false | |
| type: boolean | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-22.04, windows-2022] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: "recursive" | |
| - if: ${{contains(matrix.os, 'windows')}} | |
| uses: ilammy/[email protected] | |
| with: | |
| arch: amd64 | |
| - uses: lukka/[email protected] | |
| - if: ${{contains(matrix.os, 'ubuntu')}} | |
| uses: awalsh128/[email protected] | |
| with: | |
| packages: libc6-dev | |
| - name: Install CUDA (Linux) | |
| env: | |
| cuda: "12.5.1" | |
| if: ${{contains(matrix.os, 'ubuntu') && !inputs.vulkan}} | |
| run: ./cuda-cmake-github-actions/scripts/actions/install_cuda_ubuntu.sh | |
| shell: bash | |
| - name: Install CUDA (Windows) | |
| env: | |
| cuda: "12.5.1" | |
| visual_studio: "Visual Studio 17 2022" | |
| if: ${{contains(matrix.os, 'windows') && !inputs.vulkan}} | |
| run: ./cuda-cmake-github-actions/scripts/actions/install_cuda_windows.ps1 | |
| shell: powershell | |
| - uses: humbletim/setup-vulkan-sdk@286ed76c72de45dbf50c515779cf4ca2f6aa3944 | |
| if: ${{ inputs.vulkan }} | |
| with: | |
| vulkan-query-version: 1.3.296.0 | |
| vulkan-components: Vulkan-Headers, Glslang, SPIRV-Tools, SPIRV-Headers, SPIRV-Reflect | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20.x" | |
| registry-url: "https://registry.npmjs.org" | |
| - run: npm ci | |
| - run: npm run pkg-prebuilds-copy | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: node-addon-binary-${{ matrix.os }} | |
| path: prebuilds/ | |
| retention-days: 1 | |
| publish: | |
| needs: | |
| - build | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: write | |
| id-token: write | |
| environment: "NPM Publish" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20.x" | |
| registry-url: "https://registry.npmjs.org" | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: node-addon-binary-* | |
| path: prebuilds | |
| merge-multiple: true | |
| - uses: geekyeggo/delete-artifact@v5 | |
| with: | |
| name: node-addon-binary-* | |
| - run: npm ci | |
| - run: npm publish --provenance --access public | |
| if: ${{ github.event_name != 'workflow_dispatch' || inputs.publish }} | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - run: npm pack | |
| - uses: actions/upload-artifact@v4 | |
| if: github.event_name != 'release' | |
| with: | |
| name: lmagder-node-stable-diffusion-cpp | |
| path: lmagder-node-stable-diffusion-cpp-*.tgz | |
| - run: gh release upload ${{github.event.release.tag_name}} lmagder-node-stable-diffusion-cpp-*.tgz | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| if: github.event_name == 'release' |