|
| 1 | +name: publish |
| 2 | +env: |
| 3 | + DEBUG: napi:* |
| 4 | + NX_RUN_GROUP: ${{ github.run_id }}-${{ github.run_attempt }} |
| 5 | +on: |
| 6 | + release: |
| 7 | + types: [published] |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + if: "!contains(github.event.head_commit.message, 'skip ci')" |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + settings: |
| 15 | + - host: macos-latest |
| 16 | + target: x86_64-apple-darwin |
| 17 | + build: | |
| 18 | + yarn nx -- run-many --target=build-native -- --target=x86_64-apple-darwin |
| 19 | + - host: windows-latest |
| 20 | + build: yarn nx -- run-many --target=build-native -- --target=x86_64-pc-windows-msvc |
| 21 | + target: x86_64-pc-windows-msvc |
| 22 | + # Windows 32bit (not needed) |
| 23 | + # - host: windows-latest |
| 24 | + # build: | |
| 25 | + # yarn nx -- run-many --target=build-native -- --target=i686-pc-windows-msvc |
| 26 | + # target: i686-pc-windows-msvc |
| 27 | + - host: ubuntu-latest |
| 28 | + target: x86_64-unknown-linux-gnu |
| 29 | + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian |
| 30 | + build: |- |
| 31 | + set -e && |
| 32 | + yarn --version && |
| 33 | + yarn nx -- run-many --target=build-native -- --target=x86_64-unknown-linux-gnu |
| 34 | + - host: ubuntu-latest |
| 35 | + target: x86_64-unknown-linux-musl |
| 36 | + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine |
| 37 | + build: set -e && yarn nx -- run-many --target=build-native -- --target=x86_64-unknown-linux-musl |
| 38 | + - host: macos-latest |
| 39 | + target: aarch64-apple-darwin |
| 40 | + build: | |
| 41 | + sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*; |
| 42 | + export CC=$(xcrun -f clang); |
| 43 | + export CXX=$(xcrun -f clang++); |
| 44 | + SYSROOT=$(xcrun --sdk macosx --show-sdk-path); |
| 45 | + export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT"; |
| 46 | + yarn nx -- run-many --target=build-native -- --target=aarch64-apple-darwin |
| 47 | + - host: ubuntu-latest |
| 48 | + target: aarch64-unknown-linux-gnu |
| 49 | + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 |
| 50 | + build: |- |
| 51 | + set -e && |
| 52 | + yarn --version && |
| 53 | + yarn nx -- run-many --target=build-native -- --target=aarch64-unknown-linux-gnu |
| 54 | + - host: ubuntu-latest |
| 55 | + target: armv7-unknown-linux-gnueabihf |
| 56 | + setup: | |
| 57 | + sudo apt-get update |
| 58 | + sudo apt-get install gcc-arm-linux-gnueabihf -y |
| 59 | + build: | |
| 60 | + yarn nx -- run-many --target=build-native -- --target=armv7-unknown-linux-gnueabihf |
| 61 | + # Android (not needed) |
| 62 | + # - host: ubuntu-latest |
| 63 | + # target: aarch64-linux-android |
| 64 | + # build: | |
| 65 | + # yarn nx -- run-many --target=build-native -- --target=aarch64-linux-android |
| 66 | + # - host: ubuntu-latest |
| 67 | + # target: armv7-linux-androideabi |
| 68 | + # build: | |
| 69 | + # yarn nx -- run-many --target=build-native -- --target=armv7-linux-androideabi |
| 70 | + - host: ubuntu-latest |
| 71 | + target: aarch64-unknown-linux-musl |
| 72 | + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine |
| 73 | + build: |- |
| 74 | + set -e && |
| 75 | + rustup target add aarch64-unknown-linux-musl && |
| 76 | + yarn nx -- run-many --target=build-native -- --target=aarch64-unknown-linux-musl |
| 77 | + - host: windows-latest |
| 78 | + target: aarch64-pc-windows-msvc |
| 79 | + build: yarn nx -- run-many --target=build-native -- --target=aarch64-pc-windows-msvc |
| 80 | + name: stable - ${{ matrix.settings.target }} - node@18 |
| 81 | + runs-on: ${{ matrix.settings.host }} |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v3 |
| 84 | + - name: Setup node |
| 85 | + uses: actions/setup-node@v3 |
| 86 | + if: ${{ !matrix.settings.docker }} |
| 87 | + with: |
| 88 | + node-version: 18 |
| 89 | + check-latest: true |
| 90 | + cache: yarn |
| 91 | + - name: Install |
| 92 | + uses: dtolnay/rust-toolchain@stable |
| 93 | + if: ${{ !matrix.settings.docker }} |
| 94 | + with: |
| 95 | + targets: ${{ matrix.settings.target }} |
| 96 | + - name: Cache cargo |
| 97 | + uses: actions/cache@v3 |
| 98 | + with: |
| 99 | + path: | |
| 100 | + ~/.cargo/registry/index/ |
| 101 | + ~/.cargo/registry/cache/ |
| 102 | + ~/.cargo/git/db/ |
| 103 | + .cargo-cache |
| 104 | + target/ |
| 105 | + key: ${{ matrix.settings.target }}-cargo-registry |
| 106 | + - uses: goto-bus-stop/setup-zig@v2 |
| 107 | + if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }} |
| 108 | + with: |
| 109 | + version: 0.10.0 |
| 110 | + - name: Setup toolchain |
| 111 | + run: ${{ matrix.settings.setup }} |
| 112 | + if: ${{ matrix.settings.setup }} |
| 113 | + shell: bash |
| 114 | + - name: Setup node x86 |
| 115 | + if: matrix.settings.target == 'i686-pc-windows-msvc' |
| 116 | + run: yarn config set supportedArchitectures.cpu "ia32" |
| 117 | + shell: bash |
| 118 | + - name: Install dependencies |
| 119 | + run: yarn install |
| 120 | + timeout-minutes: 30 |
| 121 | + - name: Setup node x86 |
| 122 | + uses: actions/setup-node@v3 |
| 123 | + if: matrix.settings.target == 'i686-pc-windows-msvc' |
| 124 | + with: |
| 125 | + node-version: 18 |
| 126 | + check-latest: true |
| 127 | + cache: yarn |
| 128 | + architecture: x86 |
| 129 | + - name: Build in docker |
| 130 | + uses: addnab/docker-run-action@v3 |
| 131 | + if: ${{ matrix.settings.docker }} |
| 132 | + with: |
| 133 | + image: ${{ matrix.settings.docker }} |
| 134 | + 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 |
| 135 | + run: ${{ matrix.settings.build }} |
| 136 | + - name: Build |
| 137 | + run: ${{ matrix.settings.build }} |
| 138 | + if: ${{ !matrix.settings.docker }} |
| 139 | + shell: bash |
| 140 | + - name: Upload artifact |
| 141 | + uses: actions/upload-artifact@v3 |
| 142 | + with: |
| 143 | + name: bindings-${{ matrix.settings.target }} |
| 144 | + path: packages/**/*.node |
| 145 | + if-no-files-found: error |
| 146 | +# build-freebsd: |
| 147 | +# runs-on: macos-12 |
| 148 | +# name: Build FreeBSD |
| 149 | +# steps: |
| 150 | +# - uses: actions/checkout@v3 |
| 151 | +# - name: Build |
| 152 | +# id: build |
| 153 | +# uses: vmactions/freebsd-vm@v0 |
| 154 | +# env: |
| 155 | +# DEBUG: napi:* |
| 156 | +# RUSTUP_HOME: /usr/local/rustup |
| 157 | +# CARGO_HOME: /usr/local/cargo |
| 158 | +# RUSTUP_IO_THREADS: 1 |
| 159 | +# with: |
| 160 | +# envs: DEBUG RUSTUP_HOME CARGO_HOME RUSTUP_IO_THREADS |
| 161 | +# usesh: true |
| 162 | +# mem: 3000 |
| 163 | +# prepare: | |
| 164 | +# pkg install -y -f curl node libnghttp2 |
| 165 | +# curl -qL https://www.npmjs.com/install.sh | sh |
| 166 | +# npm install --location=global --ignore-scripts yarn |
| 167 | +# curl https://sh.rustup.rs -sSf --output rustup.sh |
| 168 | +# sh rustup.sh -y --profile minimal --default-toolchain stable |
| 169 | +# export PATH="/usr/local/cargo/bin:$PATH" |
| 170 | +# echo "~~~~ rustc --version ~~~~" |
| 171 | +# rustc --version |
| 172 | +# echo "~~~~ node -v ~~~~" |
| 173 | +# node -v |
| 174 | +# echo "~~~~ yarn --version ~~~~" |
| 175 | +# yarn --version |
| 176 | +# run: | |
| 177 | +# export PATH="/usr/local/cargo/bin:$PATH" |
| 178 | +# pwd |
| 179 | +# ls -lah |
| 180 | +# whoami |
| 181 | +# env |
| 182 | +# freebsd-version |
| 183 | +# yarn install |
| 184 | +# yarn nx -- run-many --target=build-native -- --target=x86_64-unknown-freebsd |
| 185 | +# strip -x packages/*/*.node |
| 186 | +# rm -rf node_modules |
| 187 | +# rm -rf target |
| 188 | +# rm -rf .yarn/cache |
| 189 | +# - name: Upload artifact |
| 190 | +# uses: actions/upload-artifact@v3 |
| 191 | +# with: |
| 192 | +# name: bindings-freebsd |
| 193 | +# path: packages/*/*.node |
| 194 | +# if-no-files-found: error |
| 195 | + publish: |
| 196 | + name: Publish |
| 197 | + runs-on: ubuntu-latest |
| 198 | + needs: |
| 199 | + # - build-freebsd |
| 200 | + - build |
| 201 | + steps: |
| 202 | + - uses: actions/checkout@v3 |
| 203 | + - name: Setup node |
| 204 | + uses: actions/setup-node@v3 |
| 205 | + with: |
| 206 | + node-version: 18 |
| 207 | + check-latest: true |
| 208 | + cache: yarn |
| 209 | + - name: Install dependencies |
| 210 | + run: yarn install |
| 211 | + - name: Download all artifacts |
| 212 | + uses: actions/download-artifact@v3 |
| 213 | + with: |
| 214 | + path: artifacts |
| 215 | + - name: List artifacts |
| 216 | + run: ls -R artifacts |
| 217 | + shell: bash |
| 218 | + - name: Publish |
| 219 | + run: | |
| 220 | + git checkout -b publish/$GITHUB_REF_NAME |
| 221 | + npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN |
| 222 | + yarn nx-release --local=false $GITHUB_REF_NAME |
| 223 | + env: |
| 224 | + GH_TOKEN: ${{ github.token }} |
| 225 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments