diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b05043..ae2083f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,8 +34,8 @@ jobs: - name: Lint run: yarn lint - build-and-test: - name: 'Build and Test' + build: + name: 'Build' runs-on: ubuntu-latest steps: - name: Checkout @@ -59,37 +59,88 @@ jobs: - name: Install deps if: steps.cache-node_modules.outputs.cache-hit != 'true' run: yarn install --frozen-lockfile + - name: Build run: yarn build - - name: Test browsers - run: yarn test:browser + - name: Store lib + uses: actions/upload-artifact@v4 + with: + name: lib + path: lib/ - - name: Switch to Node 16 + test-browser: + name: 'Test - browser' + needs: [build] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup node uses: actions/setup-node@v4 with: - node-version: '16' - - name: Test Node 16 - run: yarn test:nodejs + node-version-file: '.nvmrc' + - name: Cache node_modules + id: cache-node_modules + uses: actions/cache@v3 + env: + cache-name: cache-node_modules + with: + path: node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }} + - name: Install deps + if: steps.cache-node_modules.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile - - name: Switch to Node 14 - uses: actions/setup-node@v4 + - name: Restore lib + uses: actions/download-artifact@v4 with: - node-version: '14' - - name: Test Node 14 - run: yarn test:nodejs + name: lib + path: lib/ - - name: Switch to Node 12 + - name: Test + run: yarn test:browser + + test-nodejs: + name: 'Test - Node.js' + needs: [build] + runs-on: ubuntu-latest + strategy: + matrix: + version: ["16", "18", "20", "node"] + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup node uses: actions/setup-node@v4 with: - node-version: '12' - - name: Test Node 12 - run: yarn test:nodejs + node-version: ${{ matrix.version }} + - name: Cache node_modules + id: cache-node_modules + uses: actions/cache@v3 + env: + cache-name: cache-node_modules + with: + path: node_modules + key: ${{ runner.os }}-${{ matrix.version }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }} + - name: Install deps + if: steps.cache-node_modules.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile + - name: Restore lib + uses: actions/download-artifact@v4 + with: + name: lib + path: lib/ + + - name: Test + run: yarn test:nodejs + release: name: Semantic release if: github.event_name == 'push' && github.ref == 'refs/heads/main' - needs: [lint, build-and-test] + needs: [lint, build, test-browser, test-nodejs] runs-on: ubuntu-latest steps: - name: Checkout @@ -115,6 +166,13 @@ jobs: - name: Install deps if: steps.cache-node_modules.outputs.cache-hit != 'true' run: yarn install --frozen-lockfile + + - name: Restore lib + uses: actions/download-artifact@v4 + with: + name: lib + path: lib/ + - name: Release run: yarn release env: diff --git a/.nvmrc b/.nvmrc index 112a2ea..209e3ef 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -lts/gallium \ No newline at end of file +20 diff --git a/package.json b/package.json index 2813e7a..930a9fb 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,6 @@ "LICENSE" ], "scripts": { - "prepublishOnly": "yarn build", "build": "yarn build:node && yarn build:browser", "build:node": "tsc", "build:browser": "browserify --standalone MatrixEncryptAttachment -d src/webcrypto.ts -p [ tsify -p ./tsconfig.json ] | exorcist lib/browser-encrypt-attachment.js.map > lib/browser-encrypt-attachment.js", @@ -60,6 +59,6 @@ "typescript": "^4.4.4" }, "engines": { - "node": ">=12.0" + "node": ">=16.0" } }