name: Build and release library

on:
  push:
    tags:
      - 'v*'
  workflow_dispatch: {}

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: write

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Setup Node
        uses: actions/setup-node@v6
        with:
          node-version: '24'

      - name: Install deps
        run: npm ci

      - name: Build library
        run: npm run build:library

      - name: Pack library zip
        run: node ./scripts/pack-library.js

      - name: Create release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ github.ref_name }}
          name: Release ${{ github.ref_name }}
          files: ./dfg-3dviewer-library.zip
