mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-07-20 16:37:08 +00:00
187 lines
5.0 KiB
YAML
187 lines
5.0 KiB
YAML
name: CI
|
|
on: [push, pull_request]
|
|
permissions:
|
|
contents: read
|
|
env:
|
|
NODE_VERSION: 18
|
|
jobs:
|
|
setup:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
check-latest: true
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build project
|
|
run: npm run build
|
|
env:
|
|
NODE_ENV: ${{ startsWith(github.ref, 'refs/tags/v') && 'release' || '' }}
|
|
|
|
- name: Cache setup
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ./*
|
|
key: ${{ runner.os }}-${{ github.ref }}-${{ github.sha }}-setup
|
|
|
|
build-docs:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Ruby
|
|
uses: ruby/setup-ruby@v1
|
|
with:
|
|
bundler-cache: true
|
|
working-directory: ./docs
|
|
|
|
- name: Run jekyll build
|
|
working-directory: ./docs
|
|
run: bundle exec jekyll build --strict_front_matter
|
|
|
|
lint:
|
|
needs: setup
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Restore setup
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ./*
|
|
key: ${{ runner.os }}-${{ github.ref }}-${{ github.sha }}-setup
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
- name: Run lint task
|
|
run: npm run lint
|
|
|
|
bundlemon:
|
|
needs: setup
|
|
if: github.repository_owner == 'Leaflet'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Restore setup
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ./*
|
|
key: ${{ runner.os }}-${{ github.ref }}-${{ github.sha }}-setup
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
- name: Build project
|
|
run: npm run build
|
|
env:
|
|
NODE_ENV: release
|
|
|
|
- name: Run bundlemon task
|
|
run: npm run bundlemon
|
|
env:
|
|
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
|
|
|
|
test:
|
|
needs: setup
|
|
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- browser: Chrome
|
|
- browser: Firefox
|
|
- browser: FirefoxNoTouch
|
|
- browser: FirefoxRetina
|
|
- browser: Chrome
|
|
os: windows-latest
|
|
- browser: Chrome
|
|
os: macos-latest
|
|
- browser: SafariNative
|
|
os: macos-latest
|
|
steps:
|
|
- name: Restore setup
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ./*
|
|
key: ${{ runner.os }}-${{ github.ref }}-${{ github.sha }}-setup
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
- name: Set up Google Chrome
|
|
uses: browser-actions/setup-chrome@v1
|
|
if: contains(matrix.browser, 'Chrome')
|
|
|
|
- name: Set up Firefox
|
|
uses: browser-actions/setup-firefox@v1
|
|
if: contains(matrix.browser, 'Firefox')
|
|
|
|
- name: Run tests on ${{ matrix.browser }}
|
|
run: npm test -- --browsers ${{ matrix.browser }} --single-run
|
|
|
|
publish-artifacts:
|
|
needs: setup
|
|
if: github.repository_owner == 'Leaflet' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Restore setup
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ./*
|
|
key: ${{ runner.os }}-${{ github.ref }}-${{ github.sha }}-setup
|
|
|
|
- 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: setup
|
|
if: github.repository_owner == 'Leaflet' && startsWith(github.ref, 'refs/tags/v')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Restore setup
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ./*
|
|
key: ${{ runner.os }}-${{ github.ref }}-${{ github.sha }}-setup
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v4
|
|
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 }}
|