name: Bundle & Release

on:
  push:
    branches: [ main ]    
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout source files
      uses: actions/checkout@v2

    - name: Install nodejs
      run:  curl -fsSL https://deb.nodesource.com/setup_15.x | sudo -E bash -; sudo apt-get install -y nodejs

    - name: Install Build Deps
      run:  npm install

    - name: Build VaultUI
      run:  npx webpack

    - name: "Tar up the dist files"
      run: tar caf VaultUI.tar --transform="s/dist\///" $(find dist -type f) LICENSE.md

    - uses: "marvinpinto/action-automatic-releases@latest"
      with:
        repo_token: "${{ secrets.GITHUB_TOKEN }}"
        automatic_release_tag: "latest"
        prerelease: true
        title: "Latest Build"
        files: VaultUI.tar