|
| 1 | +name: CI |
| 2 | +env: |
| 3 | + DEBUG: napi:* |
| 4 | + APP_NAME: node-segfault-handler-rs |
| 5 | + MACOSX_DEPLOYMENT_TARGET: '10.13' |
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + id-token: write |
| 9 | +'on': |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + tags-ignore: |
| 14 | + - '**' |
| 15 | + paths-ignore: |
| 16 | + - '**/*.md' |
| 17 | + - LICENSE |
| 18 | + - '**/*.gitignore' |
| 19 | + - .editorconfig |
| 20 | + - docs/** |
| 21 | + pull_request: null |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + settings: |
| 28 | + - host: macos-latest |
| 29 | + target: x86_64-apple-darwin |
| 30 | + build: npm run build:debug -- --target x86_64-apple-darwin |
| 31 | + - host: ubuntu-latest |
| 32 | + target: x86_64-unknown-linux-gnu |
| 33 | + build: npm run build:debug -- --target x86_64-unknown-linux-gnu |
| 34 | + - host: macos-latest |
| 35 | + target: aarch64-apple-darwin |
| 36 | + build: npm run build:debug -- --target aarch64-apple-darwin |
| 37 | + name: stable - ${{ matrix.settings.target }} - node@20 |
| 38 | + runs-on: ${{ matrix.settings.host }} |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + - name: Setup node |
| 42 | + uses: actions/setup-node@v4 |
| 43 | + with: |
| 44 | + node-version: 20 |
| 45 | + cache: npm |
| 46 | + - name: Install |
| 47 | + uses: dtolnay/rust-toolchain@stable |
| 48 | + with: |
| 49 | + toolchain: stable |
| 50 | + targets: ${{ matrix.settings.target }} |
| 51 | + - name: Cache cargo |
| 52 | + uses: actions/cache@v4 |
| 53 | + with: |
| 54 | + path: | |
| 55 | + ~/.cargo/registry/index/ |
| 56 | + ~/.cargo/registry/cache/ |
| 57 | + ~/.cargo/git/db/ |
| 58 | + .cargo-cache |
| 59 | + target/ |
| 60 | + key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} |
| 61 | + - name: Install dependencies |
| 62 | + run: npm install |
| 63 | + - name: Build |
| 64 | + run: ${{ matrix.settings.build }} |
| 65 | + shell: bash |
| 66 | + - name: Upload artifact |
| 67 | + uses: actions/upload-artifact@v4 |
| 68 | + with: |
| 69 | + name: bindings-${{ matrix.settings.target }} |
| 70 | + path: ${{ env.APP_NAME }}.*.node |
| 71 | + if-no-files-found: error |
| 72 | + universal-macOS: |
| 73 | + name: Build universal macOS binary |
| 74 | + needs: |
| 75 | + - build |
| 76 | + runs-on: macos-latest |
| 77 | + steps: |
| 78 | + - uses: actions/checkout@v4 |
| 79 | + - name: Setup node |
| 80 | + uses: actions/setup-node@v4 |
| 81 | + with: |
| 82 | + node-version: 20 |
| 83 | + cache: npm |
| 84 | + - name: Install dependencies |
| 85 | + run: npm install |
| 86 | + - name: Download macOS x64 artifact |
| 87 | + uses: actions/download-artifact@v4 |
| 88 | + with: |
| 89 | + name: bindings-x86_64-apple-darwin |
| 90 | + path: artifacts |
| 91 | + - name: Download macOS arm64 artifact |
| 92 | + uses: actions/download-artifact@v4 |
| 93 | + with: |
| 94 | + name: bindings-aarch64-apple-darwin |
| 95 | + path: artifacts |
| 96 | + - name: Combine binaries |
| 97 | + run: npm run universal |
| 98 | + - name: Upload artifact |
| 99 | + uses: actions/upload-artifact@v4 |
| 100 | + with: |
| 101 | + name: bindings-universal-apple-darwin |
| 102 | + path: ${{ env.APP_NAME }}.*.node |
| 103 | + if-no-files-found: error |
| 104 | + test-linux-x64-gnu-binding: |
| 105 | + name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} |
| 106 | + needs: |
| 107 | + - build |
| 108 | + strategy: |
| 109 | + fail-fast: false |
| 110 | + matrix: |
| 111 | + node: |
| 112 | + - '20' |
| 113 | + - '22' |
| 114 | + runs-on: ubuntu-latest |
| 115 | + steps: |
| 116 | + - uses: actions/checkout@v4 |
| 117 | + - name: Setup node |
| 118 | + uses: actions/setup-node@v4 |
| 119 | + with: |
| 120 | + node-version: ${{ matrix.node }} |
| 121 | + cache: npm |
| 122 | + - name: Install dependencies |
| 123 | + run: npm install |
| 124 | + - name: Download artifacts |
| 125 | + uses: actions/download-artifact@v4 |
| 126 | + with: |
| 127 | + name: bindings-x86_64-unknown-linux-gnu |
| 128 | + path: . |
| 129 | + - name: List packages |
| 130 | + run: ls -R . |
| 131 | + shell: bash |
| 132 | + - name: Test bindings |
| 133 | + run: npm run test |
| 134 | + test-universal-macos-binding: |
| 135 | + name: Test bindings on macos - node@${{ matrix.node }} |
| 136 | + needs: |
| 137 | + - universal-macOS |
| 138 | + strategy: |
| 139 | + fail-fast: false |
| 140 | + matrix: |
| 141 | + node: |
| 142 | + - '20' |
| 143 | + - '22' |
| 144 | + runs-on: macos-latest |
| 145 | + steps: |
| 146 | + - uses: actions/checkout@v4 |
| 147 | + - name: Setup node |
| 148 | + uses: actions/setup-node@v4 |
| 149 | + with: |
| 150 | + node-version: ${{ matrix.node }} |
| 151 | + cache: npm |
| 152 | + - name: Install dependencies |
| 153 | + run: npm install |
| 154 | + - name: Download artifacts |
| 155 | + uses: actions/download-artifact@v4 |
| 156 | + with: |
| 157 | + name: bindings-universal-apple-darwin |
| 158 | + path: . |
| 159 | + - name: List packages |
| 160 | + run: ls -R . |
| 161 | + shell: bash |
| 162 | + - name: Test bindings |
| 163 | + run: npm run test |
| 164 | + publish: |
| 165 | + name: Publish |
| 166 | + runs-on: ubuntu-latest |
| 167 | + needs: |
| 168 | + - test-linux-x64-gnu-binding |
| 169 | + - test-universal-macos-binding |
| 170 | + steps: |
| 171 | + - uses: actions/checkout@v4 |
| 172 | + - name: Setup node |
| 173 | + uses: actions/setup-node@v4 |
| 174 | + with: |
| 175 | + node-version: 20 |
| 176 | + cache: npm |
| 177 | + - name: Install dependencies |
| 178 | + run: npm install |
| 179 | + - name: Download all artifacts |
| 180 | + uses: actions/download-artifact@v4 |
| 181 | + with: |
| 182 | + path: artifacts |
| 183 | + - name: Move artifacts |
| 184 | + run: npm run artifacts |
| 185 | + - name: List packages |
| 186 | + run: ls -R ./npm |
| 187 | + shell: bash |
| 188 | + - name: Publish |
| 189 | + run: | |
| 190 | + npm config set provenance true |
| 191 | + if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; |
| 192 | + then |
| 193 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc |
| 194 | + npm publish --access public |
| 195 | + elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+"; |
| 196 | + then |
| 197 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc |
| 198 | + npm publish --tag next --access public |
| 199 | + else |
| 200 | + echo "Not a release, skipping publish" |
| 201 | + fi |
| 202 | + env: |
| 203 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 204 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments