feat: setup actions, create select action, create action command #330
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: napi | |
| env: | |
| DEBUG: napi:* | |
| APP_NAME: oxvg | |
| MACOSX_DEPLOYMENT_TARGET: '10.13' | |
| permissions: | |
| contents: write | |
| id-token: write | |
| 'on': | |
| push: | |
| branches: | |
| - main | |
| tags-ignore: | |
| - '**' | |
| paths-ignore: | |
| - '**/*.md' | |
| - LICENSE | |
| - '**/*.gitignore' | |
| - .editorconfig | |
| - docs/** | |
| pull_request: null | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| - host: macos-latest | |
| target: x86_64-apple-darwin | |
| build: pnpm --filter @oxvg/napi build --target x86_64-apple-darwin | |
| - host: windows-latest | |
| build: pnpm --filter @oxvg/napi build --target x86_64-pc-windows-msvc | |
| target: x86_64-pc-windows-msvc | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| build: pnpm --filter @oxvg/napi build --target x86_64-unknown-linux-gnu --use-napi-cross | |
| - host: macos-latest | |
| target: aarch64-apple-darwin | |
| build: pnpm --filter @oxvg/napi build --target aarch64-apple-darwin | |
| name: stable - ${{ matrix.settings.target }} - node@22 | |
| runs-on: ${{ matrix.settings.host }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: pnpm | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Run sccache-cache | |
| uses: mozilla-actions/sccache-action@v0.0.9 | |
| - name: Install | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| targets: ${{ matrix.settings.target }} | |
| - name: Cache cargo | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| .cargo-cache | |
| target/ | |
| key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} | |
| - uses: goto-bus-stop/setup-zig@v2 | |
| if: ${{ contains(matrix.settings.target, 'musl') }} | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| tool: cargo-zigbuild | |
| - name: Setup toolchain | |
| run: ${{ matrix.settings.setup }} | |
| if: ${{ matrix.settings.setup }} | |
| shell: bash | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Setup node x86 | |
| uses: actions/setup-node@v4 | |
| if: matrix.settings.target == 'i686-pc-windows-msvc' | |
| with: | |
| node-version: 24 | |
| cache: pnpm | |
| architecture: x86 | |
| - name: Build | |
| run: ${{ matrix.settings.build }} | |
| shell: bash | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bindings-${{ matrix.settings.target }} | |
| path: packages/napi/${{ env.APP_NAME }}.*.node | |
| if-no-files-found: error | |
| test-macOS-windows-binding: | |
| name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }} | |
| needs: | |
| - build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| - host: macos-latest | |
| target: x86_64-apple-darwin | |
| architecture: x64 | |
| - host: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| architecture: x64 | |
| - host: macos-latest | |
| target: aarch64-apple-darwin | |
| architecture: arm64 | |
| node: | |
| - '22' | |
| - '24' | |
| runs-on: ${{ matrix.settings.host }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| cache: pnpm | |
| architecture: ${{ matrix.settings.architecture }} | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: bindings-${{ matrix.settings.target }} | |
| path: packages/napi | |
| - name: List packages | |
| run: ls -R packages/napi | |
| shell: bash | |
| - name: Test bindings | |
| run: pnpm --filter @oxvg/napi test | |
| publish: | |
| name: Publish | |
| runs-on: ubuntu-latest | |
| needs: | |
| - test-macOS-windows-binding | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: packages/napi/artifacts | |
| - name: Move artifacts | |
| run: pnpm run -r artifacts | |
| - name: List packages | |
| run: ls -R packages/napi | |
| shell: bash | |
| - name: Publish | |
| working-directory: packages/napi | |
| run: | | |
| npm config set provenance true | |
| if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; | |
| then | |
| echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc | |
| npm publish --access public | |
| elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+"; | |
| then | |
| echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc | |
| npm publish --tag next --access public | |
| else | |
| echo "Not a release, skipping publish" | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |