name: Publish

on:
  push:
    tags:
      - 'v*'

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Bun
        run: curl -fsSL https://bun.sh/install | bash

      - name: Install dependencies
        run: ~/.bun/bin/bun install --frozen-lockfile

      - name: Run tests
        run: ~/.bun/bin/bun test --recursive

      - name: Build dashboard
        run: |
          cd packages/shade-dashboard
          ~/.bun/bin/bun run build

      - name: Publish all packages to Gitea registry
        env:
          GITEA_TOKEN: ${{ secrets.GITEA_PUBLISH_TOKEN }}
          GITEA_USER: Stian
        run: ~/.bun/bin/bun run scripts/publish-all.ts
