test:
  image: node:20
  script:
    - npm i
    - npm test
pages:
  image: node:20
  script:
    - apt update && apt install -y mkdocs-material
    - npm i
    # Update version
    - npm version $(git describe --tags --dirty|sed -e 's/^v//') --no-git-tag-version
    - mv pages-config.mjs config.mjs
    - npm run build
    - npm run build:examples-docs
    - npm run build:maplibre-examples-docs
    - npm run build:docs
    - npm run build:pages
    - find public -type f -regex '.*\.\(htm\|html\|xml\|txt\|text\|js\|css\|svg\)$' -exec gzip -f -k {} \;
  artifacts:
    paths:
    - public
  only:
  - develop
npm:
  environment: production
  image: node:24
  id_tokens:
    NPM_ID_TOKEN:
      aud: "npm:registry.npmjs.org"
    SIGSTORE_ID_TOKEN:
      aud: sigstore
  script:
    - npm version from-git --no-git-tag-version
    - npm publish --access public
    - "curl -X POST --fail -F token=$OVERPASS_ULTRA_CI_TOKEN -F ref=main https://gitlab.com/api/v4/projects/41964217/trigger/pipeline"
    - "curl -X POST --fail -F token=$OHM_ULTRA_CI_TOKEN -F ref=main https://gitlab.com/api/v4/projects/61980708/trigger/pipeline"
    - "curl -L -X POST -H 'Accept: application/vnd.github+json' -H \"Authorization: Bearer $MAPRVA_ULTRA_WORKFLOW_PAT\" -H 'X-GitHub-Api-Version: 2022-11-28' 'https://api.github.com/repos/maprva/ultra/actions/workflows/deploy.yml/dispatches' -d {\"ref\":\"main\"}"

  only:
  - tags

npm-gitlab:
  image: node:24
  script:
    - echo "@trailstash:registry=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/" > .npmrc
    - echo "${CI_API_V4_URL#http*:}/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc
    - npm version $(git describe --tags --dirty|sed -e 's/^v//') --no-git-tag-version
    - npm publish --access public
  only:
  - develop
