diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf28f18..5b074c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,66 +52,6 @@ jobs: uses: rspack-contrib/rspack-toolchain/.github/workflows/build.yml@main test: - runs-on: ${{ matrix.os }} - name: Node Test (${{ matrix.os }}) + name: Test + uses: ./.github/workflows/test.yml needs: build - - strategy: - fail-fast: false - matrix: - include: - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - - os: macos-latest - target: aarch64-apple-darwin - - os: windows-latest - target: x86_64-pc-windows-msvc - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Get NAPI info - id: napi-info - uses: rspack-contrib/rspack-toolchain/get-napi-info@main - - - name: Download rspack binding - uses: rspack-contrib/rspack-toolchain/download-rspack-binding@main - with: - target: ${{ matrix.target }} - path: ${{ steps.napi-info.outputs.binding-path }} - - - name: Show binding - shell: bash - run: | - echo "Contents of binding directory:" - ls -la ${{ steps.napi-info.outputs.binding-path }} - echo "" - echo "*.node files:" - find ${{ steps.napi-info.outputs.binding-path }} -name "*.node" -type f -exec ls -la {} \; || echo "No .node files found" - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '22' - - - name: Enable corepack - run: corepack enable - - - name: Setup pnpm - run: corepack prepare - - - name: Cache pnpm dependencies - uses: actions/cache@v3 - with: - path: ~/.pnpm-store - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm- - - - name: Install dependencies - run: pnpm install - - - name: Run example - plugin - run: node build.js - working-directory: examples/plugin diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5b5fcef --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,88 @@ +name: Release + +on: + workflow_dispatch: + inputs: + dry-run: + description: 'Run in dry-run mode (no actual publishing)' + required: false + default: true + type: boolean + npm-tag: + description: 'NPM tag for publishing' + required: false + default: 'latest' + type: choice + options: + - latest + - alpha + - beta + - canary + +jobs: + build: + name: Build + uses: rspack-contrib/rspack-toolchain/.github/workflows/build.yml@main + with: + napi-build-command: pnpm build --release + + test: + name: Test + uses: ./.github/workflows/test.yml + + release: + runs-on: ubuntu-latest + name: Release + permissions: + contents: write + needs: [build, test] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Display release mode + run: | + echo "🚀 Release Configuration:" + echo " - Dry-run mode: ${{ inputs.dry-run }}" + echo " - NPM tag: ${{ inputs.npm-tag || 'latest' }}" + if [ "${{ inputs.dry-run }}" == "true" ]; then + echo " - ⚠️ This is a DRY RUN - no packages will be published" + else + echo " - 📦 This will PUBLISH packages to npm" + fi + + - name: Get NAPI info + id: napi-info + uses: rspack-contrib/rspack-toolchain/get-napi-info@main + + - name: Download rspack binding + uses: rspack-contrib/rspack-toolchain/download-rspack-binding@main + with: + path: ${{ steps.napi-info.outputs.binding-path }}/artifacts + + - name: List artifacts + run: ls -R artifacts + working-directory: ${{ steps.napi-info.outputs.binding-path }} + + - name: Create npm dirs + run: pnpm napi create-npm-dirs + working-directory: ${{ steps.napi-info.outputs.binding-path }} + + - name: Move artifacts + run: pnpm napi artifacts + working-directory: ${{ steps.napi-info.outputs.binding-path }} + + - name: List npm dirs + run: ls -R npm + working-directory: ${{ steps.napi-info.outputs.binding-path }} + + - name: Link optionalDependencies in binding package.json + run: pnpm napi pre-publish -t npm + working-directory: ${{ steps.napi-info.outputs.binding-path }} + + - name: Release npm packages + run: | + pnpm publish -r --tag ${{ inputs.npm-tag }} --no-git-checks --provenance --access public ${{ inputs.dry-run && '--dry-run' || '' }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..fd8367e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,69 @@ +name: Test + +on: + workflow_call: + +jobs: + test: + runs-on: ${{ matrix.os }} + name: Node Test (${{ matrix.os }}) + + strategy: + fail-fast: false + matrix: + include: + # - os: ubuntu-latest + # target: x86_64-unknown-linux-gnu + - os: macos-latest + target: aarch64-apple-darwin + # - os: windows-latest + # target: x86_64-pc-windows-msvc + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Get NAPI info + id: napi-info + uses: rspack-contrib/rspack-toolchain/get-napi-info@main + + - name: Download rspack binding + uses: rspack-contrib/rspack-toolchain/download-rspack-binding@main + with: + target: ${{ matrix.target }} + path: ${{ steps.napi-info.outputs.binding-path }} + + - name: Show binding + shell: bash + run: | + echo "Contents of binding directory:" + ls -la ${{ steps.napi-info.outputs.binding-path }} + echo "" + echo "*.node files:" + find ${{ steps.napi-info.outputs.binding-path }} -name "*.node" -type f -exec ls -la {} \; || echo "No .node files found" + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Enable corepack + run: corepack enable + + - name: Setup pnpm + run: corepack prepare + + - name: Cache pnpm dependencies + uses: actions/cache@v3 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm- + + - name: Install dependencies + run: pnpm install + + - name: Run example - plugin + run: node build.js + working-directory: examples/plugin diff --git a/crates/binding/package.json b/crates/binding/package.json index 6840125..f47d8e7 100644 --- a/crates/binding/package.json +++ b/crates/binding/package.json @@ -1,5 +1,19 @@ { "name": "@rspack-template/binding", + "version": "0.0.0", + "homepage": "https://github.com/rspack-contrib/rspack-binding-template", + "bugs": { + "url": "https://github.com/rspack-contrib/rspack-binding-template/issues" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/rspack-contrib/rspack-binding-template.git", + "directory": "crates/binding" + }, + "files": [ + "index.js", + "index.d.ts" + ], "scripts": { "build": "napi build --platform" }, @@ -12,17 +26,7 @@ "binaryName": "binding", "targets": [ "x86_64-apple-darwin", - "x86_64-pc-windows-msvc", - "x86_64-unknown-linux-gnu", - "x86_64-unknown-linux-musl", - "i686-pc-windows-msvc", - "aarch64-unknown-linux-gnu", - "aarch64-apple-darwin", - "aarch64-unknown-linux-musl", - "aarch64-pc-windows-msvc", - "armv7-linux-androideabi", - "armv7-unknown-linux-gnueabihf", - "aarch64-linux-android" + "aarch64-apple-darwin" ] } } diff --git a/package.json b/package.json index c3c4a68..f9da872 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "@rspack-template/core", + "version": "0.0.0", "homepage": "https://github.com/rspack-contrib/rspack-binding-template", "bugs": { "url": "https://github.com/rspack-contrib/rspack-binding-template/issues" @@ -15,8 +16,7 @@ "./package.json": "./package.json" }, "files": [ - "lib", - "package.json" + "lib" ], "scripts": { "prepare": "husky", diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 57d6436..7c6e21e 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,4 +1,5 @@ packages: - 'crates/binding' + - 'crates/binding/npm/**' - 'examples/plugin' - '.'