chore: fix npm publish #59
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: Release | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - 09-17-chore_fix_npm_publish | |
| jobs: | |
| build-rust: | |
| runs-on: ubuntu-latest | |
| needs: check-publish | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - aarch64-apple-darwin | |
| - aarch64-unknown-linux-gnu | |
| - x86_64-unknown-linux-gnu | |
| # - x86_64-pc-windows-msvc | |
| # - aarch64-pc-windows-msvc | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0 | |
| with: | |
| save-cache: ${{ github.ref_name == 'main' }} | |
| cache-key: release | |
| - uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # v2.0.5 | |
| with: | |
| version: 0.15.1 | |
| - uses: taiki-e/install-action@ad95d4e02e061d4390c4b66ef5ed56c7fee3d2ce # v2.58.17 | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| tool: cargo-zigbuild | |
| - uses: taiki-e/install-action@ad95d4e02e061d4390c4b66ef5ed56c7fee3d2ce # v2.58.17 | |
| if: ${{ contains(matrix.target, 'windows') }} | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| tool: cargo-xwin | |
| - name: Install llvm | |
| if: ${{ contains(matrix.target, 'windows') }} | |
| run: brew install llvm | |
| - name: Rustup Adds Target | |
| run: rustup target add ${{ matrix.target }} | |
| - name: Add musl target (x86_64) | |
| if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} | |
| run: rustup target add x86_64-unknown-linux-musl | |
| - name: Add musl target (aarch64) | |
| if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }} | |
| run: rustup target add aarch64-unknown-linux-musl | |
| - uses: oxc-project/setup-node@f42e3bda950c7454575e78ee4eaac880a077700c # v1.0.0 | |
| - name: Build | |
| run: pnpm --filter=@voidzero-dev/vite-plus build --target ${{ matrix.target }} -x | |
| env: | |
| XWIN_CACHE_DIR: ${{ github.workspace }}/.xwin-cache | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: bindings-${{ matrix.target }} | |
| path: ./packages/cli/binding/*.node | |
| if-no-files-found: error | |
| Release: | |
| runs-on: ubuntu-latest | |
| needs: build-rust | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: oxc-project/setup-node@f42e3bda950c7454575e78ee4eaac880a077700c # v1.0.0 | |
| - name: Bootstrap | |
| run: pnpm bootstrap-cli:ci | |
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| path: packages/global/dist | |
| pattern: bindings-* | |
| merge-multiple: true | |
| - name: Build | |
| run: vite run @voidzero-dev/vite-plus#build @voidzero-dev/global#build | |
| # Download again because `@voidzero-dev/global#build` will cleanup the dist dir first | |
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| path: packages/global/dist | |
| pattern: bindings-* | |
| merge-multiple: true | |
| - name: Copy *.node to cli/dist | |
| run: | | |
| cp -r packages/global/dist/*.node packages/cli/dist | |
| ls -alh packages/cli/dist | |
| - name: Set version | |
| run: | | |
| sed -i 's/"version": "0.0.0"/"version": "0.0.0-${{ github.sha }}"/' packages/global/package.json | |
| sed -i 's/"version": "0.0.0"/"version": "0.0.0-${{ github.sha }}"/' packages/cli/package.json | |
| - name: Publish | |
| run: | | |
| echo "//npm.pkg.github.com/:_authToken=${NPM_TOKEN}" >> ${NPM_CONFIG_USERCONFIG} | |
| echo "@voidzero-dev:registry=https://npm.pkg.github.com/" >> ${NPM_CONFIG_USERCONFIG} | |
| pnpm whoami --registry https://npm.pkg.github.com | |
| pnpm publish --filter=./packages/global --registry https://npm.pkg.github.com --no-git-checks | |
| pnpm publish --filter=./packages/cli --registry https://npm.pkg.github.com --no-git-checks | |
| env: | |
| NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| check-publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: oxc-project/setup-node@f42e3bda950c7454575e78ee4eaac880a077700c # v1.0.0 | |
| - name: Check publish | |
| run: | | |
| echo "//npm.pkg.github.com/:_authToken=${NPM_TOKEN}" >> ${NPM_CONFIG_USERCONFIG} | |
| echo "@voidzero-dev:registry=https://npm.pkg.github.com/" >> ${NPM_CONFIG_USERCONFIG} | |
| pnpm config list | |
| pnpm whoami --registry https://npm.pkg.github.com --verbose | |
| env: | |
| NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |