|
| 1 | +name: Release next-rspack bindings |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + dry-run: |
| 7 | + description: 'Run in dry-run mode (no actual publishing)' |
| 8 | + required: false |
| 9 | + default: false |
| 10 | + type: boolean |
| 11 | + npm-tag: |
| 12 | + description: 'NPM tag for publishing' |
| 13 | + required: false |
| 14 | + default: 'latest' |
| 15 | + type: choice |
| 16 | + options: |
| 17 | + - latest |
| 18 | + - alpha |
| 19 | + - beta |
| 20 | + - canary |
| 21 | + |
| 22 | +env: |
| 23 | + DEBUG: napi:* |
| 24 | + |
| 25 | +jobs: |
| 26 | + build: |
| 27 | + name: Build |
| 28 | + uses: rspack-contrib/rspack-toolchain/.github/workflows/build.yml@f69dc04fcae6b38d97b87acef448ed7a285b01cc |
| 29 | + with: |
| 30 | + package-json-path: rspack/crates/binding/package.json |
| 31 | + napi-build-command: pnpm build --release |
| 32 | + working-directory: rspack |
| 33 | + |
| 34 | + release: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + environment: npm |
| 37 | + name: Release |
| 38 | + permissions: |
| 39 | + contents: write |
| 40 | + id-token: write |
| 41 | + needs: [build] |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Checkout code |
| 45 | + uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Display release mode |
| 48 | + run: | |
| 49 | + echo "🚀 Release Configuration:" |
| 50 | + echo " - Dry-run mode: ${{ inputs.dry-run }}" |
| 51 | + echo " - NPM tag: ${{ inputs.npm-tag || 'latest' }}" |
| 52 | + if [ "${{ inputs.dry-run }}" == "true" ]; then |
| 53 | + echo " - ⚠️ This is a DRY RUN - no packages will be published" |
| 54 | + else |
| 55 | + echo " - 📦 This will PUBLISH packages to npm" |
| 56 | + fi |
| 57 | +
|
| 58 | + - name: Setup Node.js |
| 59 | + uses: actions/setup-node@v4 |
| 60 | + with: |
| 61 | + node-version: '22' |
| 62 | + |
| 63 | + - name: Enable corepack |
| 64 | + run: corepack enable |
| 65 | + |
| 66 | + - name: Setup pnpm |
| 67 | + run: corepack prepare |
| 68 | + |
| 69 | + - name: Cache pnpm dependencies |
| 70 | + uses: actions/cache@v3 |
| 71 | + with: |
| 72 | + path: ~/.pnpm-store |
| 73 | + key: ${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 74 | + restore-keys: | |
| 75 | + ${{ runner.os }}-${{ runner.arch }}-pnpm- |
| 76 | +
|
| 77 | + - name: Install dependencies |
| 78 | + run: pnpm install |
| 79 | + working-directory: ./rspack |
| 80 | + |
| 81 | + - name: Get NAPI info |
| 82 | + id: napi-info |
| 83 | + uses: rspack-contrib/rspack-toolchain/get-napi-info@f69dc04fcae6b38d97b87acef448ed7a285b01cc |
| 84 | + with: |
| 85 | + package-json-path: rspack/crates/binding/package.json |
| 86 | + |
| 87 | + - name: Download rspack binding |
| 88 | + uses: rspack-contrib/rspack-toolchain/download-rspack-binding@f69dc04fcae6b38d97b87acef448ed7a285b01cc |
| 89 | + with: |
| 90 | + path: ${{ steps.napi-info.outputs.binding-directory }}/artifacts |
| 91 | + |
| 92 | + - name: List artifacts |
| 93 | + run: ls -R artifacts |
| 94 | + working-directory: ${{ steps.napi-info.outputs.binding-directory }} |
| 95 | + |
| 96 | + - name: Create npm dirs |
| 97 | + run: pnpm napi create-npm-dirs |
| 98 | + working-directory: ${{ steps.napi-info.outputs.binding-directory }} |
| 99 | + |
| 100 | + - name: Move artifacts |
| 101 | + run: pnpm napi artifacts |
| 102 | + working-directory: ${{ steps.napi-info.outputs.binding-directory }} |
| 103 | + |
| 104 | + - name: List npm dirs |
| 105 | + run: ls -R npm |
| 106 | + working-directory: ${{ steps.napi-info.outputs.binding-directory }} |
| 107 | + |
| 108 | + - name: Create npm token |
| 109 | + run: | |
| 110 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc |
| 111 | + env: |
| 112 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 113 | + |
| 114 | + - name: Release npm binding packages |
| 115 | + run: | |
| 116 | + npm config set access public |
| 117 | + npm config set provenance true |
| 118 | + pnpm napi pre-publish --no-gh-release -t npm ${{ inputs.dry-run && '--dry-run' || '' }} |
| 119 | + working-directory: ${{ steps.napi-info.outputs.binding-directory }} |
| 120 | + |
| 121 | + - name: Release npm packages |
| 122 | + run: | |
| 123 | + pnpm publish -r --tag ${{ inputs.npm-tag }} --no-git-checks --provenance --access public ${{ inputs.dry-run && '--dry-run' || '' }} |
| 124 | + working-directory: ./rspack |
0 commit comments