name: Build Solution

on:
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: checkout Repository
        uses: actions/checkout@v4

      - name: use NodeJS v24.4.0
        uses: actions/setup-node@v4
        with:
          node-version: '24.4.0'

      - name: Install Dependencies
        run: npm install

      - name: run Build
        run: npm run buildProduction

      - name: get Version from package.json
        id: get_version
        run: |
          version=$(node -p "require('./package.json').version")
          echo "VERSION=$version" >> $GITHUB_ENV
          
      - name: rename dist-Folder
        run: mv dist "${{ env.VERSION }}"

      - name: compress Version-Folder
        run: zip -r "${{ env.VERSION }}-PROD.zip" "${{ env.VERSION }}"

      - name: Upload Build-Artefact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.VERSION }}
          path: ${{ env.VERSION }}
