name: publish
on:
 release:
   types: [published]
jobs:
  publish:
    runs-on: ubuntu-latest
    name: Publish latest release
    steps:
      - uses: actions/checkout@v2
      - name: Setup node
        uses: actions/setup-node@v2
        with:
          node-version: '16.x'
          cache: 'npm'
          registry-url: 'https://registry.npmjs.org'
      - name: Install dependencies
        run: npm ci
      - name: Build package
        run: grunt build
      - name: Publish npm package
        run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
      - name: Publish NuGet package
        id: publish_nuget
        uses: laget-se/publish-nuget@v2
        with:
          NUGET_KEY: ${{ secrets.NUGET_API_KEY }}
          NUSPEC_FILE: nuget/bootstrap-select.nuspec
          PACKAGE_NAME: bootstrap-select
          VERSION_FILE_PATH: nuget/bootstrap-select.nuspec
          VERSION_REGEX: ^\s*<version>(.*)<\/version>\s*$
