# yaml-language-server: $schema=https://bitbucket.org/product/features/pipelines/schema.json
image: node:20

definitions:
  steps:
    - step: &publish
        name: Publish Package
        deployment: Production
        script:
          - export NPM_TOKEN=$NPM_TOKEN
          - export VERSION="5.0.$BITBUCKET_BUILD_NUMBER"
          - npm --no-git-tag-version version "$VERSION" -m "Upgrade to new version"
          - npm install
          - npm run build
          - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
          - npm publish --access public
          - git tag -a "$VERSION" -m "Version $VERSION"
          - git push origin "$VERSION"

pipelines:
  branches:
    main:
      - step: *publish
