name: Build

on: 
  push: 
    tags:
      - '*'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: 12
          registry-url: https://registry.npmjs.org/          
      - run: npm install
      - run: npm install -g typescript@3.7.3 typedocs codecov
      - run: npm install -D istanbul remap-istanbul
      - run: tsc
      # - run: typedoc --mode modules --out ./docs  --tsconfig ./tsconfig.json src --excludeExternals --module umd --name web-atoms-core --excludePrivate --excludeNotExported --exclude "tests/**/*.ts"
      # - run: node ./node_modules/.bin/istanbul cover ./node_modules/@web-atoms/unit-test/index.js ./dist/test.js
      - run: npm run test
      - run: node ./node_modules/.bin/remap-istanbul -i ./coverage/coverage.json -t json -o ./coverage/coverage.json
      - run: codecov
        env:
          CODECOV_TOKEN: ${{secrets.codecov_token}}
      - run: npm publish --access public
        env:
          NODE_AUTH_TOKEN: ${{secrets.npm_token}}
      - run: node ./old/change-name.js
      - run: npm publish --access public
        env:
          NODE_AUTH_TOKEN: ${{secrets.npm_token}}
      - run: node ./old/undo.js
      - run: node ./typedoc.js  --mode modules --out ./docs  --tsconfig ./tsconfig.json src --excludeExternals --module umd --name @web-atoms/core --excludePrivate --excludeNotExported --exclude "**/tests/**/*"
      - run: node ./core-docs/change-name.js
      - run: npm publish --access public
        env:
          NODE_AUTH_TOKEN: ${{secrets.npm_token}}
      - run: node ./core-docs/undo.js
              
