name: KnowStreaming Build

on:
  push:
    branches: [ "*" ]
  pull_request:
    branches: [ "*" ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    
    - name: Set up JDK 11
      uses: actions/setup-java@v3
      with:
        java-version: '11'
        distribution: 'temurin'
        cache: maven

    - name: Setup Node
      uses: actions/setup-node@v1
      with:
        node-version: '12.22.12'

    - name: Build With Maven
      run: mvn -Prelease-package -Dmaven.test.skip=true clean install -U

    - name: Get KnowStreaming Version
      if: ${{ success() }}
      run: |
        version=`mvn -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec -q`
        echo "VERSION=${version}" >> $GITHUB_ENV

    - name: Upload Binary Package
      if: ${{ success() }}
      uses: actions/upload-artifact@v3
      with:
        name: KnowStreaming-${{ env.VERSION }}.tar.gz
        path: km-dist/target/KnowStreaming-${{ env.VERSION }}.tar.gz
