CI.yml (8572B)
1 name: CI 2 env: 3 DEBUG: napi:* 4 APP_NAME: node-yara-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: | 31 brew install autoconf 32 brew install automake 33 brew install libtool 34 brew install pkg-config 35 brew install jansson 36 brew install llvm 37 make build 38 strip -x *.node 39 - host: windows-latest 40 build: yarn build 41 target: x86_64-pc-windows-msvc 42 - host: ubuntu-latest 43 target: x86_64-unknown-linux-gnu 44 build: |- 45 set -e && 46 sudo apt-get install -y automake libtool make gcc pkg-config libjansson-dev && 47 make debug_results && 48 make yara && 49 yarn build --target x86_64-unknown-linux-gnu && 50 strip *.node 51 - host: macos-latest 52 target: aarch64-apple-darwin 53 build: | 54 brew install autoconf 55 brew install automake 56 brew install libtool 57 brew install pkg-config 58 brew fetch --force --bottle-tag=arm64_monterey jansson 59 brew install $(brew --cache --bottle-tag=arm64_monterey jansson) 60 CFLAGS="-target arm64-apple-macos11" make yara 61 brew install llvm 62 yarn build --target aarch64-apple-darwin 63 strip -x *.node 64 # This is an nixos env so its all a little special 65 - host: arm64 66 target: aarch64-unknown-linux-gnu 67 build: |- 68 set -e && 69 NIX_PATH=nixpkgs=channel:nixos-23.05 nix-shell -p pkg-config jansson openssl gnumake autoconf automake libtool protobufc pcre clang lld gcc napi-rs-cli --keep LIBCLANG_PATH --keep BINDGEN_EXTRA_CLANG_ARGS --run "make yara && napi build --platform --release --target aarch64-unknown-linux-gnu" && 70 strip *.node 71 name: stable - ${{ matrix.settings.target }} - node@18 72 runs-on: ${{ matrix.settings.host }} 73 steps: 74 - uses: actions/checkout@v3 75 - name: Setup node 76 uses: actions/setup-node@v3 77 with: 78 node-version: 18 79 check-latest: true 80 cache: yarn 81 - name: Install 82 uses: dtolnay/rust-toolchain@stable 83 with: 84 toolchain: stable 85 targets: ${{ matrix.settings.target }} 86 - name: Cache cargo 87 if: ${{ matrix.settings.host != 'arm64' }} 88 uses: actions/cache@v3 89 with: 90 path: | 91 ~/.cargo/registry/index/ 92 ~/.cargo/registry/cache/ 93 ~/.cargo/git/db/ 94 .cargo-cache 95 target/ 96 key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} 97 - uses: goto-bus-stop/setup-zig@v2 98 if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }} 99 with: 100 version: 0.10.1 101 - name: Setup toolchain 102 run: ${{ matrix.settings.setup }} 103 if: ${{ matrix.settings.setup }} 104 - name: Setup node x86 105 if: matrix.settings.target == 'i686-pc-windows-msvc' 106 run: yarn config set supportedArchitectures.cpu "ia32" 107 shell: bash 108 - name: Install dependencies 109 run: yarn install 110 - name: Setup node x86 111 uses: actions/setup-node@v3 112 if: matrix.settings.target == 'i686-pc-windows-msvc' 113 with: 114 node-version: 18 115 check-latest: true 116 cache: yarn 117 architecture: x86 118 - name: Build 119 run: ${{ matrix.settings.build }} 120 shell: bash 121 - name: Upload artifact 122 uses: actions/upload-artifact@v3 123 with: 124 name: bindings-${{ matrix.settings.target }} 125 path: ${{ env.APP_NAME }}.*.node 126 if-no-files-found: error 127 test-macOS-windows-binding: 128 name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }} 129 needs: 130 - build 131 strategy: 132 fail-fast: false 133 matrix: 134 settings: 135 - host: macos-latest 136 target: x86_64-apple-darwin 137 - host: windows-latest 138 target: x86_64-pc-windows-msvc 139 node: 140 - '14' 141 - '16' 142 - '18' 143 - '20' 144 runs-on: ${{ matrix.settings.host }} 145 steps: 146 - uses: actions/checkout@v3 147 - name: Setup node 148 uses: actions/setup-node@v3 149 with: 150 node-version: ${{ matrix.node }} 151 check-latest: true 152 cache: yarn 153 - name: Install dependencies 154 run: | 155 yarn install 156 - name: Download artifacts 157 uses: actions/download-artifact@v3 158 with: 159 name: bindings-${{ matrix.settings.target }} 160 path: . 161 - name: List packages 162 run: ls -R . 163 shell: bash 164 - name: Cache cargo 165 if: ${{ matrix.settings.host == 'macos-latest' }} 166 run: brew install jansson 167 - name: Test bindings 168 run: yarn test 169 test-linux-x64-gnu-binding: 170 name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} 171 needs: 172 - build 173 strategy: 174 fail-fast: false 175 matrix: 176 node: 177 # 14 and 16 are broken apparently 178 #- '14' 179 #- '16' 180 - '18' 181 - '20' 182 runs-on: ubuntu-latest 183 steps: 184 - uses: actions/checkout@v3 185 - name: Setup node 186 uses: actions/setup-node@v3 187 with: 188 node-version: ${{ matrix.node }} 189 check-latest: true 190 cache: yarn 191 - name: Install dependencies 192 run: | 193 yarn install 194 - name: Download artifacts 195 uses: actions/download-artifact@v3 196 with: 197 name: bindings-x86_64-unknown-linux-gnu 198 path: . 199 - name: List packages 200 run: ls -R . 201 shell: bash 202 - name: Test bindings 203 run: yarn test 204 test-linux-aarch64-gnu-binding: 205 name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }} 206 needs: 207 - build 208 strategy: 209 fail-fast: false 210 matrix: 211 node: 212 - '14' 213 - '16' 214 - '18' 215 - '20' 216 runs-on: arm64 217 steps: 218 - uses: actions/checkout@v3 219 - name: Download artifacts 220 uses: actions/download-artifact@v3 221 with: 222 name: bindings-aarch64-unknown-linux-gnu 223 path: . 224 - name: List packages 225 run: ls -R . 226 shell: bash 227 - name: Install dependencies 228 run: | 229 yarn config set supportedArchitectures.cpu "arm64" 230 yarn config set supportedArchitectures.libc "glibc" 231 yarn install 232 - name: Run tests 233 run: | 234 set -e 235 yarn test 236 ls -la 237 publish: 238 name: Publish 239 runs-on: ubuntu-latest 240 needs: 241 - test-macOS-windows-binding 242 - test-linux-x64-gnu-binding 243 - test-linux-aarch64-gnu-binding 244 steps: 245 - uses: actions/checkout@v3 246 - name: Setup node 247 uses: actions/setup-node@v3 248 with: 249 node-version: 18 250 check-latest: true 251 cache: yarn 252 - name: Install dependencies 253 run: yarn install 254 - name: Download all artifacts 255 uses: actions/download-artifact@v3 256 with: 257 path: artifacts 258 - name: List packages 259 run: ls -laR ./ 260 shell: bash 261 - name: Move artifacts 262 run: yarn artifacts 263 - name: List packages 264 run: ls -laR ./npm 265 shell: bash 266 - name: Publish 267 run: | 268 npm config set provenance true 269 if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; 270 then 271 echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc 272 npm publish --access public 273 elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+"; 274 then 275 echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc 276 npm publish --tag next --access public 277 else 278 echo "Not a release, skipping publish" 279 fi 280 env: 281 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 282 NPM_TOKEN: ${{ secrets.NPM_TOKEN }}