name: Release
on:
  release:
    types: [released]
permissions:
  contents: read

jobs:
  publish:
    name: Build new Release
    runs-on: ubuntu-latest
    if: github.repository == 'fomantic/Fomantic-UI'
    steps:
    - uses: actions/checkout@v4
      with:
        ref: master
    - uses: actions/setup-node@v4
      with:
        node-version: 18
        registry-url: https://registry.npmjs.org/
    - name: pre-setup
      run: sh ./scripts/preinstall.sh
    - name: install dependencies
      run: yarn
    - name: fomantic install & build
      run: yarn gulp install
    - name: publish to npm
      env:
        CI: true
        NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTOMATION }}
      run: |
        npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
        yarn config set registry https://registry.npmjs.org
        yarn publish --non-interactive
