|
| 1 | +name: Release |
| 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: true |
| 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 | +jobs: |
| 23 | + build: |
| 24 | + name: Build |
| 25 | + uses: rspack-contrib/rspack-toolchain/.github/workflows/build.yml@main |
| 26 | + with: |
| 27 | + napi-build-command: pnpm build --release |
| 28 | + |
| 29 | + test: |
| 30 | + name: Test |
| 31 | + uses: ./.github/workflows/test.yml |
| 32 | + |
| 33 | + release: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + name: Release |
| 36 | + permissions: |
| 37 | + contents: write |
| 38 | + needs: [build, test] |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Checkout code |
| 42 | + uses: actions/checkout@v4 |
| 43 | + |
| 44 | + - name: Display release mode |
| 45 | + run: | |
| 46 | + echo "🚀 Release Configuration:" |
| 47 | + echo " - Dry-run mode: ${{ inputs.dry-run }}" |
| 48 | + echo " - NPM tag: ${{ inputs.npm-tag || 'latest' }}" |
| 49 | + if [ "${{ inputs.dry-run }}" == "true" ]; then |
| 50 | + echo " - ⚠️ This is a DRY RUN - no packages will be published" |
| 51 | + else |
| 52 | + echo " - 📦 This will PUBLISH packages to npm" |
| 53 | + fi |
| 54 | +
|
| 55 | + - name: Get NAPI info |
| 56 | + id: napi-info |
| 57 | + uses: rspack-contrib/rspack-toolchain/get-napi-info@main |
| 58 | + |
| 59 | + - name: Download rspack binding |
| 60 | + uses: rspack-contrib/rspack-toolchain/download-rspack-binding@main |
| 61 | + with: |
| 62 | + path: ${{ steps.napi-info.outputs.binding-path }}/artifacts |
| 63 | + |
| 64 | + - name: List artifacts |
| 65 | + run: ls -R artifacts |
| 66 | + working-directory: ${{ steps.napi-info.outputs.binding-path }} |
| 67 | + |
| 68 | + - name: Create npm dirs |
| 69 | + run: pnpm napi create-npm-dirs |
| 70 | + working-directory: ${{ steps.napi-info.outputs.binding-path }} |
| 71 | + |
| 72 | + - name: Move artifacts |
| 73 | + run: pnpm napi artifacts |
| 74 | + working-directory: ${{ steps.napi-info.outputs.binding-path }} |
| 75 | + |
| 76 | + - name: List npm dirs |
| 77 | + run: ls -R npm |
| 78 | + working-directory: ${{ steps.napi-info.outputs.binding-path }} |
| 79 | + |
| 80 | + - name: Link optionalDependencies in binding package.json |
| 81 | + run: pnpm napi pre-publish -t npm |
| 82 | + working-directory: ${{ steps.napi-info.outputs.binding-path }} |
| 83 | + |
| 84 | + - name: Release npm packages |
| 85 | + run: | |
| 86 | + pnpm publish -r --tag ${{ inputs.npm-tag }} --no-git-checks --provenance --access public ${{ inputs.dry-run && '--dry-run' || '' }} |
| 87 | + env: |
| 88 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments