{{> ciRelease}}

  smoke-publish:
    # This cant be tested on Windows because our node_modules directory
    # checks in symlinks which are not supported there. This should be
    # fixed somehow, because this means some forms of local development
    # are likely broken on Windows as well.
    {{> jobMatrix
      jobName="Smoke Publish"
      jobCheck=(obj sha="inputs.check-sha")
      jobCheckout=(obj ref="${{ inputs.ref }}")
      windowsCI=false
    }}
      - name: Pack
        env:
          SMOKE_PUBLISH_NPM: 1
        run: |
          NPM_VERSION="$({{ rootNpmPath }} --version)-$GITHUB_SHA.0"
          {{ rootNpmPath }} version $NPM_VERSION --ignore-scripts
          node scripts/publish.js --pack-destination=$RUNNER_TEMP
          export SMOKE_PUBLISH_TARBALL="$RUNNER_TEMP/npm-$NPM_VERSION.tgz"
          {{ rootNpmPath }} install --global $SMOKE_PUBLISH_TARBALL
          {{ rootNpmPath }} install -w smoke-tests --ignore-scripts --no-audit --no-fund
          # call installed npm instead of local source since we are testing
          # the packed tarball that we just installed globally
          NPM_GLOBAL_VERSION="$(npm --version)"
          npm help
          if [ "$NPM_GLOBAL_VERSION" == "$NPM_VERSION" ]; then
            npm test -w smoke-tests --ignore-scripts
          else
            echo "global npm is not the correct version for smoke-publish"
            echo "found: $NPM_GLOBAL_VERSION, expected: $NPM_VERSION"
            exit 1
          fi
      {{> stepChecks jobCheck=true }}
