# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
# This file was contributed by Carlos Parada and Yamel Senih from ERP Consultores y Asociados, C.A

name: Publish Project

on:
  release:
    types: [created]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 14
      - run: npm i
      - run: npm test
      - run: npm run build:prod --if-present

  publish-dist:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
          registry-url: https://registry.npmjs.org/
      - run: npm i
      - run: sed -i "s|releaseNoForDocumentation|${{ github.event.release.tag_name }}|g" config/default.json
      - run: npm run build:prod --if-present
      - uses: TheDoctor0/zip-release@0.4.1
        with:
          filename: 'Adempiere-Vue.zip'
          path: 'dist/'
      - uses: skx/github-action-publish-binaries@master
        env:
          GITHUB_TOKEN: ${{ secrets.TOKEN_ACCESS }}
        with:
          args: 'Adempiere-Vue.zip'
