Skip to content

fix: reverse node export conditions #927

fix: reverse node export conditions

fix: reverse node export conditions #927

Workflow file for this run

name: CI & Release
# Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
run-name: >-
${{
inputs.release && 'Publish to NPM' ||
''
}}
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
inputs:
release:
description: 'Publish new release'
required: true
default: false
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read # for checkout
jobs:
build:
name: Build, lint and test coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: npm
node-version: lts/*
- run: npm ci
- run: npx ls-engines
- run: npm run prepublishOnly
- name: Register Problem Matcher for ESLint that handles --report-unused-disable-directives
run: echo "::add-matcher::.github/eslint-compact.json"
- run: npm run lint -- --report-unused-disable-directives -f compact
- run: npm run coverage
- uses: actions/upload-artifact@v3
name: Cache build output
with:
name: build-output
path: |
dist/
umd/
test:
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Run the testing suite on each major OS with the latest LTS release of Node.js
os: [macos-latest, ubuntu-latest, windows-latest]
node: [lts/*]
# It makes sense to also test the oldest, and latest, versions of Node.js, on ubuntu-only since it's the fastest CI runner
include:
- os: ubuntu-latest
# Also test the previous LTS release
node: lts/-1
- os: ubuntu-latest
# Test the actively developed version that will become the latest LTS release next October
node: current
# The `build` job already runs the testing suite in ubuntu and lts/*
exclude:
- os: ubuntu-latest
node: lts/*
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: npm
node-version: ${{ matrix.node }}
- run: npm install
- run: npx ls-engines
- run: npm run coverage
prod-deps:
name: Cache production dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: prod-deps
uses: actions/cache@v3
with:
path: ./node_modules
key: prod-deps-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- if: steps.prod-deps.outputs.cache-hit != 'true'
uses: actions/setup-node@v3
with:
node-version: lts/*
- if: steps.prod-deps.outputs.cache-hit != 'true'
run: npm install --omit=dev --ignore-scripts
edge-runtime:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: npm
node-version: lts/*
- run: npm install
- uses: actions/download-artifact@v3
name: Restore build output
with:
name: build-output
- run: npm run test:edge-runtime -- --coverage
browser-runtime:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: npm
node-version: lts/*
- run: npm install
- uses: actions/download-artifact@v3
name: Restore build output
with:
name: build-output
- run: npm run test:browser -- --coverage
deno-runtime:
runs-on: ubuntu-latest
needs: [build, prod-deps]
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
name: Install only production dependencies
with:
path: ./node_modules
key: prod-deps-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- uses: actions/download-artifact@v3
name: Restore build output
with:
name: build-output
- uses: denoland/setup-deno@v1
with:
deno-version: vx.x.x
- run: npm run test:deno
bun-runtime:
runs-on: ubuntu-latest
needs: [build, prod-deps]
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
name: Install only production dependencies
with:
path: ./node_modules
key: prod-deps-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- uses: actions/download-artifact@v3
name: Restore build output
with:
name: build-output
- uses: antongolub/action-setup-bun@cd8fde41d342e75098c67856ffc9c6cf6c1217e6 # v1
- run: npm run test:bun
node-runtimes:
runs-on: ubuntu-latest
needs: [build, prod-deps]
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
name: Install only production dependencies
with:
path: ./node_modules
key: prod-deps-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: actions/download-artifact@v3
name: Restore build output
with:
name: build-output
- run: npm run test:node-runtimes
release:
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
needs: [build, test, deno-runtime, bun-runtime, edge-runtime, browser-runtime, node-runtimes]
# only run if opt-in during workflow_dispatch
if: github.event.inputs.release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Need to fetch entire commit history to
# analyze every commit since last release
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: npm
- run: npm ci
# Branches that will release new versions are defined in .releaserc.json
- run: npx semantic-release
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
# e.g. git tags were pushed but it exited before `npm publish`
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}