---
description: |
  Daily TCGC version watcher for the http-client-csharp emitter. Checks the npm
  registry for new non-dev releases of @azure-tools/typespec-client-generator-core
  and, when a newer stable version is available and no equivalent issue already
  exists, files a tracking issue assigned to GitHub Copilot to perform the upgrade.

on:
  schedule: "13 3 * * *"
  workflow_dispatch:

permissions: read-all

network: defaults

safe-outputs:
  messages:
    footer: ">  Generated by [{workflow_name}]({run_url})"
    footer-install: "<!-- -->" # Need this as empty string will still include it
  noop:
    report-as-issue: false
  create-issue:
    title-prefix: "Bump TCGC to "
    labels: [emitter:client:csharp]
    assignees: [copilot]
  assign-to-agent:
    name: "copilot"
    model: "claude-opus-4.6"

tools:
  web-fetch:
  github:
    toolsets: [issues, repos]
    # If in a public repo, setting `lockdown: false` allows
    # reading issues, pull requests and comments from 3rd-parties
    # If in a private repo this has no particular effect.
    lockdown: false

timeout-minutes: 15
engine: copilot
---

# Agentic TCGC Bump for http-client-csharp

You're an automation assistant for the TypeSpec GitHub repository. Your task is to check whether a newer stable release of the `@azure-tools/typespec-client-generator-core` (TCGC) npm package is available and, if so, file a tracking issue assigned to GitHub Copilot so the http-client-csharp emitter can be upgraded. The Copilot coding agent will perform the actual upgrade by following the migration steps in `.github/prompts/upgrade-tcgc.instructions.md`.

## Instructions

1. **Detect the latest stable TCGC version.** Use the `web-fetch` tool to read the npm registry metadata at `https://registry.npmjs.org/@azure-tools/typespec-client-generator-core`. Pick the latest version that does **not** contain a pre-release tag — i.e. the version string contains no `-` character (no `-dev`, `-alpha`, `-beta`, `-rc`). Save it as `LATEST_STABLE`. If no stable version is found, call `noop` and exit.

2. **Read the current version from `package.json`.** Use the `get_file_contents` tool (owner: `microsoft`, repo: `typespec`, path: `packages/http-client-csharp/package.json`) and extract the version listed under `devDependencies["@azure-tools/typespec-client-generator-core"]`. Save it as `CURRENT_VERSION`.

3. **Compare versions.** If `LATEST_STABLE` equals `CURRENT_VERSION` or `LATEST_STABLE` is not newer than `CURRENT_VERSION`, call `noop` and exit — there is nothing to do and **no issue should be created**.

4. **Duplicate detection.** Before creating a new issue, search for existing issues that already track an upgrade to `LATEST_STABLE` for the http-client-csharp emitter. Use `search_issues` with a query like:

   ```
   repo:${{ github.repository }} is:issue label:"emitter:client:csharp" "Bump TCGC to LATEST_STABLE" in:title,body
   ```

   (substitute the actual `LATEST_STABLE` version). Include both **open and closed** issues — do not filter by state. Treat an issue as a duplicate when **all** of the following are true:
   - It carries the `emitter:client:csharp` label.
   - Its title or body references upgrading TCGC to the same `LATEST_STABLE` version (e.g. `Bump TCGC to <LATEST_STABLE>`).

   If any duplicate exists in any state, call `noop` and exit — **no new issue should be created**.

5. **Create the tracking issue.** Use the `create-issue` safe output to file exactly one new issue, modeled after [#10367](https://github.com/microsoft/typespec/issues/10367):
   - **Title** (after the configured `Bump TCGC to ` prefix): `<LATEST_STABLE>` — the final title is `Bump TCGC to <LATEST_STABLE>`.
   - **Body** (markdown):

     ```
     Bump TCGC to [<LATEST_STABLE>](https://github.com/Azure/typespec-azure/blob/main/packages/typespec-client-generator-core/CHANGELOG.md#<anchor>) and it's related dependencies for the http-client-csharp package. Rerun Generate.ps1 and ensure all existing tests pass.
     ```

     Replace `<LATEST_STABLE>` with the actual version (e.g. `0.67.2`) and `<anchor>` with the GitHub-style heading anchor for that version on the CHANGELOG page (lowercased, dots removed — e.g. `0.67.2` → `0672`).

   - **Labels**: `emitter:client:csharp` is applied automatically via the workflow's `safe-outputs.create-issue.labels` configuration.
   - **Assignees**: `copilot` is assigned automatically via the `assignees: [copilot]` setting in the workflow's `create-issue` configuration. The `assign-to-agent` block sets `claude-opus-4.6` as the default model for the Copilot coding agent.

   Do not perform the upgrade in this workflow — the Copilot coding agent picks up the issue once assigned and follows `.github/prompts/upgrade-tcgc.instructions.md`.

## Important

You MUST call at least one safe output tool (`create-issue` or `noop`) before finishing. If you encounter errors with any tool or cannot complete the check, call `noop` with a message describing what went wrong.
