From 6425d8276596d87bba38dd5d0b40d51bef0002f8 Mon Sep 17 00:00:00 2001 From: juanelas Date: Mon, 17 Apr 2023 08:48:15 +0200 Subject: [PATCH] updated flow --- .github/workflows/build-and-test.yml | 77 ++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/build-and-test.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..e9fab89 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,77 @@ +name: build, test (node and browser), publish to NPM + +on: + push: + tags: + - "v*.*.*" + workflow_dispatch: + +jobs: + node: + name: Tests in node.js + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + node-version: [16.x, 18.x] + # When set to true, GitHub cancels all in-progress jobs if any matrix job fails. + fail-fast: true + # The maximum number of jobs that can run simultaneously + max-parallel: 1 + steps: + - name: Git checkout + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: install + run: npm ci + + - name: node tests + run: npm run test:node + env: + RPC_PROVIDER_URL: ${{ secrets.RPC_PROVIDER_URL }} + PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} + + browser: + name: test in browser + needs: [node] + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v3 + + - name: Use Node.js 18 + uses: actions/setup-node@v3 + with: + node-version: 18.x + + - name: install + run: npm ci + + - name: browser tests + run: npm run test:browser-headless + env: + RPC_PROVIDER_URL: ${{ secrets.RPC_PROVIDER_URL }} + PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} + + npm-publish: + needs: [node, browser] + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v3 + + - name: Install Node.js, NPM and Yarn + uses: actions/setup-node@v3 + with: + node-version: "18.x" + registry-url: "https://registry.npmjs.org" + + - name: NPM publish + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}