name: Develop Pre-Release

on:
  push:
    branches:
      - dev
  workflow_dispatch:

permissions:
  id-token: write
  contents: write

concurrency:
  group: dev-prerelease
  cancel-in-progress: true

jobs:
  prepare:
    runs-on: ubuntu-latest
    outputs:
      version_suffix: ${{ steps.vars.outputs.version_suffix }}
    steps:
      - name: Compute version suffix
        id: vars
        shell: bash
        run: |
          set -euo pipefail
          SHA8="${GITHUB_SHA::8}"
          DATE=$(date -u +%Y%m%d)
          echo "version_suffix=-dev-${DATE}-${SHA8}" >> "$GITHUB_OUTPUT"

  prerelease:
    needs: prepare
    uses: ./.github/workflows/reusable-release.yml
    with:
      version_suffix: ${{ needs.prepare.outputs.version_suffix }}
      npm_package_name: "@neuralnomads/codenomad-dev"
      dist_tag: latest
      prerelease: true
      release_ui: false
    secrets: inherit
