|
| 1 | +name: node-bind-build |
| 2 | +env: |
| 3 | + DEBUG: napi:* |
| 4 | + APP_NAME: okam |
| 5 | + MACOSX_DEPLOYMENT_TARGET: '10.13' |
| 6 | +'on': |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + tags-ignore: |
| 11 | + - '**' |
| 12 | + paths-ignore: |
| 13 | + - '**/*.md' |
| 14 | + - LICENSE |
| 15 | + - '**/*.gitignore' |
| 16 | + - .editorconfig |
| 17 | + - docs/** |
| 18 | + pull_request: |
| 19 | + types: [opened, synchronize] |
| 20 | +jobs: |
| 21 | + pre-check: |
| 22 | + name: Check Is Release node-binding |
| 23 | + if: "contains(github.event.head_commit.message, 'Release')" |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v3 |
| 27 | + - name: is Release Commit |
| 28 | + run: | |
| 29 | + echo Start Release |
| 30 | + if git log -1 --pretty=%B | grep "^Release [0-9]\+\.[0-9]\+\.[0-9]\+"; then |
| 31 | + echo "start Release" |
| 32 | + else |
| 33 | + gh run cancel ${{ github.run_id }} |
| 34 | + gh run watch ${{ github.run_id }} |
| 35 | + fi |
| 36 | + env: |
| 37 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + build: |
| 39 | + needs: |
| 40 | + - pre-check |
| 41 | + strategy: |
| 42 | + fail-fast: false |
| 43 | + matrix: |
| 44 | + settings: |
| 45 | + - host: macos-latest |
| 46 | + target: x86_64-apple-darwin |
| 47 | + build: | |
| 48 | + pnpm --filter @okamjs/okam build |
| 49 | + strip -x ./crates/node/*.node |
| 50 | + - host: windows-latest |
| 51 | + build: pnpm --filter @okamjs/okam build |
| 52 | + target: x86_64-pc-windows-msvc |
| 53 | + - host: windows-latest |
| 54 | + build: | |
| 55 | + rustup target add i686-pc-windows-msvc |
| 56 | + pnpm --filter @okamjs/okam build --target i686-pc-windows-msvc |
| 57 | + target: i686-pc-windows-msvc |
| 58 | + - host: ubuntu-latest |
| 59 | + target: x86_64-unknown-linux-gnu |
| 60 | + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian |
| 61 | + build: |- |
| 62 | + set -e && |
| 63 | + pnpm --filter @okamjs/okam build --target x86_64-unknown-linux-gnu && |
| 64 | + strip ./crates/node/*.node |
| 65 | + - host: ubuntu-latest |
| 66 | + target: x86_64-unknown-linux-musl |
| 67 | + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine |
| 68 | + build: set -e && pnpm --filter @okamjs/okam build && strip ./crates/node/*.node |
| 69 | + - host: macos-latest |
| 70 | + target: aarch64-apple-darwin |
| 71 | + build: | |
| 72 | + rustup target add aarch64-apple-darwin |
| 73 | + pnpm --filter @okamjs/okam build --target aarch64-apple-darwin |
| 74 | + strip -x ./crates/node/*.node |
| 75 | + - host: ubuntu-latest |
| 76 | + target: aarch64-unknown-linux-gnu |
| 77 | + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 |
| 78 | + build: |- |
| 79 | + set -e && |
| 80 | + rustup target add aarch64-unknown-linux-gnu && |
| 81 | + pnpm --filter @okamjs/okam build --target aarch64-unknown-linux-gnu && |
| 82 | + aarch64-unknown-linux-gnu-strip ./crates/node/*.node |
| 83 | + - host: ubuntu-latest |
| 84 | + target: armv7-unknown-linux-gnueabihf |
| 85 | + setup: | |
| 86 | + sudo apt-get update |
| 87 | + sudo apt-get install gcc-arm-linux-gnueabihf -y |
| 88 | + build: | |
| 89 | + rustup target add armv7-unknown-linux-gnueabihf |
| 90 | + pnpm --filter @okamjs/okam build --target armv7-unknown-linux-gnueabihf |
| 91 | + arm-linux-gnueabihf-strip ./crates/node/*.node |
| 92 | + - host: ubuntu-latest |
| 93 | + target: aarch64-unknown-linux-musl |
| 94 | + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine |
| 95 | + build: |- |
| 96 | + set -e && |
| 97 | + rustup target add aarch64-unknown-linux-musl && |
| 98 | + pnpm --filter @okamjs/okam build --target aarch64-unknown-linux-musl && |
| 99 | + /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip ./crates/node/*.node |
| 100 | + - host: windows-latest |
| 101 | + target: aarch64-pc-windows-msvc |
| 102 | + build: | |
| 103 | + rustup target add aarch64-pc-windows-msvc |
| 104 | + pnpm --filter @okamjs/okam build --target aarch64-pc-windows-msvc |
| 105 | + name: stable - ${{ matrix.settings.target }} - node@18 |
| 106 | + runs-on: ${{ matrix.settings.host }} |
| 107 | + steps: |
| 108 | + - uses: actions/checkout@v3 |
| 109 | + - uses: pnpm/action-setup@v2 |
| 110 | + name: Install pnpm |
| 111 | + id: pnpm-install |
| 112 | + with: |
| 113 | + version: 8 |
| 114 | + - name: Setup node |
| 115 | + uses: actions/setup-node@v3 |
| 116 | + if: ${{ !matrix.settings.docker }} |
| 117 | + with: |
| 118 | + node-version: 18 |
| 119 | + check-latest: true |
| 120 | + cache: pnpm |
| 121 | + - name: Install |
| 122 | + uses: dtolnay/rust-toolchain@stable |
| 123 | + if: ${{ !matrix.settings.docker }} |
| 124 | + with: |
| 125 | + toolchain: stable |
| 126 | + targets: ${{ matrix.settings.target }} |
| 127 | + - name: Cache cargo |
| 128 | + uses: actions/cache@v3 |
| 129 | + with: |
| 130 | + path: | |
| 131 | + ~/.cargo/registry/index/ |
| 132 | + ~/.cargo/registry/cache/ |
| 133 | + ~/.cargo/git/db/ |
| 134 | + .cargo-cache |
| 135 | + target/ |
| 136 | + key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} |
| 137 | + - uses: goto-bus-stop/setup-zig@v2 |
| 138 | + if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }} |
| 139 | + with: |
| 140 | + version: 0.10.1 |
| 141 | + - name: Setup toolchain |
| 142 | + run: ${{ matrix.settings.setup }} |
| 143 | + if: ${{ matrix.settings.setup }} |
| 144 | + shell: bash |
| 145 | + - name: Setup node x86 |
| 146 | + if: matrix.settings.target == 'i686-pc-windows-msvc' |
| 147 | + run: yarn config set supportedArchitectures.cpu "ia32" |
| 148 | + shell: bash |
| 149 | + - name: Install dependencies |
| 150 | + run: pnpm install |
| 151 | + - name: Setup node x86 |
| 152 | + uses: actions/setup-node@v3 |
| 153 | + if: matrix.settings.target == 'i686-pc-windows-msvc' |
| 154 | + with: |
| 155 | + node-version: 18 |
| 156 | + check-latest: true |
| 157 | + cache: pnpm |
| 158 | + architecture: x86 |
| 159 | + - name: Build in docker |
| 160 | + uses: addnab/docker-run-action@v3 |
| 161 | + if: ${{ matrix.settings.docker }} |
| 162 | + with: |
| 163 | + image: ${{ matrix.settings.docker }} |
| 164 | + options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build' |
| 165 | + run: ${{ matrix.settings.build }} |
| 166 | + - name: Build |
| 167 | + run: ${{ matrix.settings.build }} |
| 168 | + if: ${{ !matrix.settings.docker }} |
| 169 | + shell: bash |
| 170 | + - name: Upload artifact |
| 171 | + uses: actions/upload-artifact@v3 |
| 172 | + with: |
| 173 | + name: bindings-${{ matrix.settings.target }} |
| 174 | + path: ./crates/node/${{ env.APP_NAME }}.*.node |
| 175 | + if-no-files-found: error |
| 176 | + publish: |
| 177 | + name: Publish |
| 178 | + runs-on: ubuntu-latest |
| 179 | + needs: |
| 180 | + - build |
| 181 | + steps: |
| 182 | + - uses: actions/checkout@v3 |
| 183 | + - uses: pnpm/action-setup@v2 |
| 184 | + name: Install pnpm |
| 185 | + id: pnpm-install |
| 186 | + with: |
| 187 | + version: 8 |
| 188 | + - name: Setup node |
| 189 | + uses: actions/setup-node@v3 |
| 190 | + with: |
| 191 | + node-version: 18 |
| 192 | + check-latest: true |
| 193 | + cache: pnpm |
| 194 | + - name: Install dependencies |
| 195 | + run: pnpm install |
| 196 | + - name: Download all artifacts |
| 197 | + uses: actions/download-artifact@v3 |
| 198 | + with: |
| 199 | + path: crates/node/artifacts |
| 200 | + - name: Move artifacts |
| 201 | + run: pnpm --filter @okamjs/okam artifacts |
| 202 | + - name: List packages |
| 203 | + run: ls -R ./crates/node/npm |
| 204 | + shell: bash |
| 205 | + |
| 206 | + - name: Publish |
| 207 | + run: | |
| 208 | + if git log -1 --pretty=%B | grep "^Release [0-9]\+\.[0-9]\+\.[0-9]\+"; then |
| 209 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc |
| 210 | + pnpm --filter @okamjs/okam publish --access public |
| 211 | + else |
| 212 | + echo "Not a release, skipping publish" |
| 213 | + fi |
| 214 | + env: |
| 215 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 216 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments