# Generated from CircleCI.pkl. DO NOT EDIT.
version: '2.1'
orbs:
  pr-approval: apple/pr-approval@0.1.0
jobs:
  build:
    steps:
    - checkout
    - run:
        command: npm ci
    - run:
        command: npm test
    docker:
    - image: cimg/node:18.19.0
  do-release:
    steps:
    - checkout
    - run:
        command: npm ci
    - run:
        command: npm test
    - run:
        command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
        name: Authenticate with registry
    - run:
        command: npm publish
        name: Publish to NPM
    docker:
    - image: cimg/node:18.19.0
  github-release:
    steps:
    - run:
        command: |-
          gh release create "${CIRCLE_TAG}" \
            --title "${CIRCLE_TAG}" \
            --target "${CIRCLE_SHA1}" \
            --verify-tag \
            --notes "Release version ${VERSION}" \
            --repo "${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
        name: Creating GitHub release
    docker:
    - image: maniator/gh:v2.40.1
workflows:
  prb:
    jobs:
    - hold:
        type: approval
    - pr-approval/authenticate:
        context: pkl-pr-approval
    - build:
        requires:
        - hold
        - pr-approval/authenticate
    when:
      matches:
        value: << pipeline.git.branch >>
        pattern: ^pull/\d+(/head)?$
  main:
    jobs:
    - build
    when:
      equal:
      - main
      - << pipeline.git.branch >>
  release:
    jobs:
    - do-release:
        context:
        - pkl-npm-release
        filters:
          branches:
            ignore: /.*/
          tags:
            only: /^v?\d+\.\d+\.\d+$/
    - github-release:
        requires:
        - do-release
        context:
        - pkl-github-release
        filters:
          branches:
            ignore: /.*/
          tags:
            only: /^v?\d+\.\d+\.\d+$/
