Add "module" key to package.json #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: [push, pull_request] | |
permissions: | |
contents: read | |
env: | |
NODE_VERSION: 16 | |
jobs: | |
setup: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, windows-2019] | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
check-latest: true | |
cache: npm | |
- name: Cache dependencies | |
id: cache-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} | |
- name: Install dependencies | |
if: steps.cache-dependencies.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Cache setup | |
uses: actions/cache@v3 | |
with: | |
path: ./* | |
key: ${{ runner.os }}-${{ github.sha }}-setup | |
build: | |
needs: setup | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, windows-2019] | |
steps: | |
- name: Restore setup | |
uses: actions/cache@v3 | |
with: | |
path: ./* | |
key: ${{ runner.os }}-${{ github.sha }}-setup | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Build project | |
run: npm run build | |
env: | |
NODE_ENV: ${{ startsWith(github.ref, 'refs/tags/v') && 'release' || '' }} | |
- name: Cache build | |
uses: actions/cache@v3 | |
with: | |
path: ./* | |
key: ${{ runner.os }}-${{ github.sha }}-build | |
build-release: | |
needs: setup | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Restore setup | |
uses: actions/cache@v3 | |
with: | |
path: ./* | |
key: ${{ runner.os }}-${{ github.sha }}-setup | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Build project | |
run: npm run build | |
env: | |
NODE_ENV: release | |
- name: Cache release build | |
uses: actions/cache@v3 | |
with: | |
path: ./* | |
key: ${{ runner.os }}-${{ github.sha }}-build-release | |
lint: | |
needs: setup | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Restore setup | |
uses: actions/cache@v3 | |
with: | |
path: ./* | |
key: ${{ runner.os }}-${{ github.sha }}-setup | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Run lint task | |
run: npm run lint | |
bundlemon: | |
needs: build-release | |
if: github.repository_owner == 'Leaflet' | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Restore release build | |
uses: actions/cache@v3 | |
with: | |
path: ./* | |
key: ${{ runner.os }}-${{ github.sha }}-build-release | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Run bundlemon task | |
run: npm run bundlemon | |
env: | |
BUNDLEMON_PROJECT_ID: 61e0545915f6c3000980d0ed | |
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} | |
test: | |
needs: build | |
runs-on: ${{ matrix.os || 'ubuntu-20.04' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- browser: Chrome1280x1024 | |
- browser: FirefoxTouch | |
- browser: FirefoxNoTouch | |
- browser: IE | |
os: windows-2019 | |
- browser: IE10 | |
os: windows-2019 | |
steps: | |
- name: Restore build | |
uses: actions/cache@v3 | |
with: | |
path: ./* | |
key: ${{ runner.os }}-${{ github.sha }}-build | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Run tests on ${{ matrix.browser }} | |
run: npm test -- --browsers ${{ matrix.browser }} | |
publish-artifacts: | |
needs: build | |
if: github.repository_owner == 'Leaflet' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Restore build | |
uses: actions/cache@v3 | |
with: | |
path: ./* | |
key: ${{ runner.os }}-${{ github.sha }}-build | |
- name: Compress artifacts | |
working-directory: dist | |
run: zip -r leaflet.zip . | |
- name: Publish artifacts | |
uses: jakejarvis/s3-sync-action@v0.5.1 | |
with: | |
args: --acl public-read --delete --exact-timestamps | |
env: | |
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
SOURCE_DIR: dist | |
DEST_DIR: content/leaflet/${{ github.ref_name }} | |
publish-npm: | |
needs: build | |
if: github.repository_owner == 'Leaflet' && startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Restore build | |
uses: actions/cache@v3 | |
with: | |
path: ./* | |
key: ${{ runner.os }}-${{ github.sha }}-build | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
registry-url: https://registry.npmjs.org | |
- name: Publish to NPM | |
run: | | |
TAG=$(echo $GITHUB_REF_NAME | grep -oP '^v\d+\.\d+\.\d+-?\K(\w+)?') | |
npm publish --tag ${TAG:-latest} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |