name: Publish Draft Release

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

env:
  dotnet-version: 6.0.x # SDK Version for building Dafny

jobs:
  deep-integration-tests:
    if: github.repository_owner == 'dafny-lang'
    uses: ./.github/workflows/integration-tests-reusable.yml
    with:
      ref: ${{ github.ref }}
      all_platforms: true
      num_shards: 5

  get-version:
    runs-on: ubuntu-22.04
    steps:
      - id: get-version
        uses: battila7/get-version-action@v2
      - run: echo ${{ steps.get-version.outputs.version }}
      - run: echo ${{ steps.get-version.outputs.version-without-v }}
    outputs:
      version: ${{ steps.get-version.outputs.version-without-v }}

  publish-release:
    needs: [deep-integration-tests, get-version]
    uses: ./.github/workflows/publish-release-reusable.yml
    with:
      name: ${{ needs.get-version.outputs.version }}
      ref: ${{ github.sha }}
      tag_name: ${{ github.ref }}
      draft: true
      release_nuget: true
      # We can probably automate pulling this out of RELEASE_NOTES.md in the future
      release_notes: ""
    secrets:
      nuget_api_key: ${{ secrets.NUGET_API_KEY }}
