123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583 |
- name: CI
- env:
- DEBUG: 'napi:*'
- APP_NAME: 'package-template'
- on:
- push:
- branches:
- - main
- tags-ignore:
- - '**'
- pull_request:
- jobs:
- build:
- if: "!contains(github.event.head_commit.message, 'skip ci')"
- strategy:
- fail-fast: false
- matrix:
- os: [ubuntu-latest, macos-latest, windows-latest]
- name: stable - ${{ matrix.os }} - node@14
- runs-on: ${{ matrix.os }}
- steps:
- - uses: actions/checkout@v2
- - name: Setup node
- uses: actions/setup-node@v2-beta
- with:
- node-version: 14
- check-latest: true
- - name: Install
- uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- profile: minimal
- override: true
- - name: Generate Cargo.lock
- uses: actions-rs/cargo@v1
- with:
- command: generate-lockfile
- - name: Cache cargo registry
- uses: actions/cache@v1
- with:
- path: ~/.cargo/registry
- key: stable-${{ matrix.os }}-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache cargo index
- uses: actions/cache@v1
- with:
- path: ~/.cargo/git
- key: stable-${{ matrix.os }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache NPM dependencies
- uses: actions/cache@v1
- with:
- path: node_modules
- key: npm-cache-${{ matrix.os }}-node@14-${{ hashFiles('yarn.lock') }}
- - name: 'Install dependencies'
- run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- - name: 'Build'
- if: matrix.os != 'macos-latest'
- run: yarn build
- - name: 'Build'
- if: matrix.os == 'macos-latest'
- run: yarn build
- env:
- MACOSX_DEPLOYMENT_TARGET: '10.13'
- - name: Upload artifact
- uses: actions/upload-artifact@v2
- with:
- name: bindings-${{ matrix.os }}
- path: ${{ env.APP_NAME }}.*.node
- - name: Clear the cargo caches
- run: |
- cargo install cargo-cache --no-default-features --features ci-autoclean
- cargo-cache
- build-linux-musl:
- if: "!contains(github.event.head_commit.message, 'skip ci')"
- name: stable - linux-musl - node@10
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Login to registry
- run: |
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
- env:
- DOCKER_REGISTRY_URL: docker.pkg.github.com
- DOCKER_USERNAME: ${{ github.actor }}
- DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- - name: Pull docker image
- run: |
- docker pull docker.pkg.github.com/napi-rs/napi-rs/rust-nodejs-alpine:lts
- docker tag docker.pkg.github.com/napi-rs/napi-rs/rust-nodejs-alpine:lts builder
- - name: Generate Cargo.lock
- uses: actions-rs/cargo@v1
- with:
- command: generate-lockfile
- - name: Cache cargo registry
- uses: actions/cache@v1
- with:
- path: ~/.cargo/registry
- key: stable-node-alpine-@10-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache cargo index
- uses: actions/cache@v1
- with:
- path: ~/.cargo/git
- key: stable-node-alpine-@10-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache NPM dependencies
- uses: actions/cache@v1
- with:
- path: node_modules
- key: npm-cache-alpine-node@10-${{ hashFiles('yarn.lock') }}
- - name: 'Install dependencies'
- run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- - name: 'Build'
- run: |
- docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/${{ env.APP_NAME }} -e DEBUG="napi:*" -w /${{ env.APP_NAME }} builder sh -c "yarn build"
- - name: Upload artifact
- uses: actions/upload-artifact@v2
- with:
- name: bindings-linux-musl
- path: ${{ env.APP_NAME }}.*.node
- build-linux-arm7:
- name: stable - arm7-unknown-linux-gnu - node@14
- runs-on: ubuntu-latest
- steps:
- - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
- - uses: actions/checkout@v2
- - name: Setup node
- uses: actions/setup-node@v1
- with:
- node-version: 14
- - name: Install
- uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- profile: minimal
- override: true
- - name: Generate Cargo.lock
- uses: actions-rs/cargo@v1
- with:
- command: generate-lockfile
- - name: Cache cargo registry
- uses: actions/cache@v1
- with:
- path: ~/.cargo/registry
- key: stable-linux-arm7-gnu-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache cargo index
- uses: actions/cache@v1
- with:
- path: ~/.cargo/git
- key: stable-linux-arm7-gnu-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache NPM dependencies
- uses: actions/cache@v1
- with:
- path: node_modules
- key: npm-cache-linux-arm7-gnu-node@14-${{ hashFiles('yarn.lock') }}
- - name: Install aarch64 toolchain
- run: rustup target add armv7-unknown-linux-gnueabihf
- - name: Install cross compile toolchain
- run: |
- sudo apt-get update
- sudo apt-get install gcc-arm-linux-gnueabihf -y
- - name: Install dependencies
- run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- - name: Cross build arm7
- run: yarn build --target armv7-unknown-linux-gnueabihf
- - name: Upload artifact
- uses: actions/upload-artifact@v2
- with:
- name: bindings-linux-arm7
- path: ${{ env.APP_NAME }}.*.node
- build-linux-aarch64:
- name: stable - aarch64-unknown-linux-gnu - node@14
- runs-on: ubuntu-latest
- steps:
- - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
- - uses: actions/checkout@v2
- - name: Setup node
- uses: actions/setup-node@v2-beta
- with:
- node-version: 14
- check-latest: true
- - name: Install
- uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- profile: minimal
- override: true
- - name: Install aarch64 toolchain
- run: rustup target add aarch64-unknown-linux-gnu
- - name: Generate Cargo.lock
- uses: actions-rs/cargo@v1
- with:
- command: generate-lockfile
- - name: Cache cargo registry
- uses: actions/cache@v1
- with:
- path: ~/.cargo/registry
- key: stable-linux-aarch64-gnu-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache cargo index
- uses: actions/cache@v1
- with:
- path: ~/.cargo/git
- key: stable-linux-aarch64-gnu-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache NPM dependencies
- uses: actions/cache@v1
- with:
- path: node_modules
- key: npm-cache-linux-aarch64-gnu-node@14-${{ hashFiles('yarn.lock') }}
- - name: Install cross compile toolchain
- run: |
- sudo apt-get update
- sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y
- - name: Install dependencies
- run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- - name: Cross build aarch64
- run: yarn build --target aarch64-unknown-linux-gnu
- - name: Upload artifact
- uses: actions/upload-artifact@v2
- with:
- name: bindings-linux-aarch64
- path: ${{ env.APP_NAME }}.*.node
- build-apple-silicon:
- name: nightly - aarch64-apple-darwin - node@14
- runs-on: macos-latest
- steps:
- - uses: actions/checkout@v2
- - name: Setup node
- uses: actions/setup-node@v2-beta
- with:
- node-version: 14
- check-latest: true
- - name: Install
- uses: actions-rs/toolchain@v1
- with:
- toolchain: nightly
- profile: minimal
- override: true
- - name: Install aarch64 toolchain
- run: rustup target add aarch64-apple-darwin
- - name: Generate Cargo.lock
- uses: actions-rs/cargo@v1
- with:
- command: generate-lockfile
- - name: Cache cargo registry
- uses: actions/cache@v1
- with:
- path: ~/.cargo/registry
- key: nightly-apple-aarch64-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache cargo index
- uses: actions/cache@v1
- with:
- path: ~/.cargo/git
- key: nightly-apple-aarch64-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache NPM dependencies
- uses: actions/cache@v1
- with:
- path: node_modules
- key: npm-cache-apple-aarch64-node@14-${{ hashFiles('yarn.lock') }}
- - name: Install dependencies
- run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- - name: Cross build aarch64
- run: yarn build --target aarch64-apple-darwin
- - name: Upload artifact
- uses: actions/upload-artifact@v2
- with:
- name: bindings-apple-aarch64
- path: ${{ env.APP_NAME }}.*.node
- build-android-aarch64:
- name: Build - Android - aarch64
- runs-on: macos-latest
- steps:
- - uses: actions/checkout@v2
- - name: Setup node
- uses: actions/setup-node@v1
- with:
- node-version: 14
- - name: Install aarch64 toolchain
- run: rustup target add aarch64-linux-android
- - name: Generate Cargo.lock
- uses: actions-rs/cargo@v1
- with:
- command: generate-lockfile
- - name: Cache cargo registry
- uses: actions/cache@v1
- with:
- path: ~/.cargo/registry
- key: nightly-apple-aarch64-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache cargo index
- uses: actions/cache@v1
- with:
- path: ~/.cargo/git
- key: nightly-apple-aarch64-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache NPM dependencies
- uses: actions/cache@v1
- with:
- path: node_modules
- key: npm-cache-apple-aarch64-node@14-${{ hashFiles('yarn.lock') }}
- - name: Install dependencies
- run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- - name: Build
- shell: bash
- run: |
- export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android24-clang"
- yarn build --target aarch64-linux-android
- - name: Upload artifact
- uses: actions/upload-artifact@v2
- with:
- name: bindings-android-aarch64
- path: ${{ env.APP_NAME }}.*.node
- test:
- name: Test bindings on ${{ matrix.os }} - node@${{ matrix.node }}
- needs:
- - build
- strategy:
- fail-fast: false
- matrix:
- os: [ubuntu-latest, macos-latest, windows-latest]
- node: ['10', '12', '14', '15']
- runs-on: ${{ matrix.os }}
- steps:
- - uses: actions/checkout@v2
- - name: Setup node
- uses: actions/setup-node@v2-beta
- with:
- node-version: ${{ matrix.node }}
- check-latest: true
- - name: Cache NPM dependencies
- uses: actions/cache@v1
- with:
- path: node_modules
- key: npm-cache-test-${{ matrix.os }}-node@${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
- - name: 'Install dependencies'
- run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- - name: Download artifacts
- uses: actions/download-artifact@v2
- with:
- name: bindings-${{ matrix.os }}
- path: .
- - name: List packages
- run: ls -R .
- shell: bash
- - name: Test bindings
- run: yarn test
- test-musl:
- name: Test bindings on alpine - node@${{ matrix.node }}
- needs:
- - build-linux-musl
- strategy:
- fail-fast: false
- matrix:
- node: ['10', '12', '14', '15']
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Cache NPM dependencies
- uses: actions/cache@v1
- with:
- path: node_modules
- key: npm-cache-alpine-node@${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
- - name: 'Install dependencies'
- run: yarn install --frozen-lockfile --ignore-scripts --registry https://registry.npmjs.org
- - name: Download artifacts
- uses: actions/download-artifact@v2
- with:
- name: bindings-linux-musl
- path: .
- - name: List files
- run: ls -R .
- shell: bash
- - name: Run tests
- run: docker run --rm -v $(pwd):/${{ env.APP_NAME }} -w /${{ env.APP_NAME }} node:${{ matrix.node }}-alpine sh -c "yarn test"
- test-aarch64:
- name: stable - aarch64-unknown-linux-gnu - node@${{ matrix.node }}
- runs-on: ubuntu-latest
- needs:
- - build-linux-aarch64
- strategy:
- fail-fast: false
- matrix:
- node: ['10', '12', '14', '15']
- steps:
- - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
- - uses: actions/checkout@v2
- - name: Setup node
- uses: actions/setup-node@v2-beta
- with:
- node-version: ${{ matrix.node }}
- check-latest: true
- - name: Cache NPM dependencies
- uses: actions/cache@v1
- with:
- path: node_modules
- key: npm-cache-test-linux-aarch64-gnu-node@${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
- - name: 'Install dependencies'
- run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- - name: Download artifacts
- uses: actions/download-artifact@v2
- with:
- name: bindings-linux-aarch64
- path: .
- - name: List
- run: ls -a
- - name: Run tests
- uses: docker://multiarch/ubuntu-core:arm64-focal
- with:
- args: >
- sh -c "
- apt-get update && \
- apt-get install -y ca-certificates gnupg2 curl && \
- curl -sL https://deb.nodesource.com/setup_${{ matrix.node }}.x | bash - && \
- apt-get install -y nodejs && \
- node ./simple-test.js
- "
- dependabot:
- needs:
- - test
- - test-musl
- - test-aarch64
- - build-apple-silicon
- - build-linux-arm7
- - build-android-aarch64
- runs-on: ubuntu-latest
- steps:
- - name: auto-merge
- uses: ridedott/dependabot-auto-merge-action@master
- with:
- GITHUB_LOGIN: dependabot[bot]
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- publish:
- name: Publish
- runs-on: ubuntu-latest
- needs:
- - test
- - test-musl
- - test-aarch64
- - build-apple-silicon
- - build-linux-arm7
- - build-android-aarch64
- steps:
- - uses: actions/checkout@v2
- - name: Setup node
- uses: actions/setup-node@v2-beta
- with:
- node-version: 14
- check-latest: true
- - name: Cache NPM dependencies
- uses: actions/cache@v1
- with:
- path: node_modules
- key: npm-cache-publish-ubuntu-latest-${{ hashFiles('yarn.lock') }}
- - name: 'Install dependencies'
- run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- - name: Download all artifacts
- uses: actions/download-artifact@v2
- with:
- path: artifacts
- - name: Move artifacts
- run: yarn artifacts
- - name: List packages
- run: ls -R npm
- shell: bash
- - name: Publish
- run: |
- if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
- then
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- npm publish
- else
- echo "Not a release, skipping publish"
- fi
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|