Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .github/skills/approve-cca/SKILL.md

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we dump this in favor of just the one in microsoft/azcode-internal? Don't want to try to maintain it twice

Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
name: approve-cca
description: "Bulk approve PRs created by the Copilot Coding Agent. Use when: approve CCA PRs, bulk approve, merge agent PRs, review copilot PRs, approve copilot-swe-agent PRs, bulk merge."
argument-hint: "Optionally specify repos, e.g. 'microsoft/vscode-docker microsoft/vscode-containers'"
---

# Bulk Approve Copilot Coding Agent PRs

Reviews and approves pull requests created by the Copilot Coding Agent (`app/copilot-swe-agent`) across multiple repositories. PRs with no changed files are automatically closed. PRs with changes require explicit user approval before being approved, marked ready, and queued for merge.

## When to Use

- You dispatched tasks via `/dispatch-cca` and want to review and approve the resulting PRs
- You want to bulk-approve Copilot Coding Agent PRs assigned to you

## Procedure

### 1. Gather Target Repositories

Present the default repo checklist using the ask-questions tool with `multiSelect: true`. The user can select one or more repos, and also type a custom `owner/repo` if needed.

If the user already provided repositories in their message, skip this step.

#### Default Repositories

See [repos.md](../repos.md) for the default list of target repositories. When presenting options:
- Use the group heading (e.g., "Package", "Extension", "Extension pack", "Other") as the `description` for each option
- Sort options by group order (packages first, then extensions, then extension packs, then other), and alphabetically within each group

### 2. List Copilot Coding Agent PRs

For each selected repository, list open PRs authored by `app/copilot-swe-agent` and assigned to the current user:

```
gh pr list -R OWNER/REPO --app "copilot-swe-agent" --assignee "@me" --json number,title,url,changedFiles,headRefOid
```

Collect all results across repos. If no PRs are found, inform the user and stop.

### 3. Triage Each PR

For each PR found, check the `changedFiles` count:

#### If `changedFiles` is 0 — Auto-close

Close the PR without asking, since it has no changes:

```
gh pr close PR_NUMBER -R OWNER/REPO -c "Closing: no files were changed." -d
```

Report to the user that the PR was closed.

#### If `changedFiles` > 0 — Ask for Approval

First, print a summary of all PRs with clickable review links in a markdown message **before** asking the question. Format:

```
**PRs with changes to review:**
- **#PR_NUMBER** TITLE (OWNER/REPO) — N changed files — [Review changes](https://github.com/OWNER/REPO/pull/PR_NUMBER/files)
```

Then use the ask-questions tool to ask for explicit approval. The question options should list each PR by number and title (without the URL, since it was already printed above). Include a "Skip all" option.

### 4. Approve and Merge (for explicitly approved PRs only)

For each PR the user approved, run the following commands in sequence:

#### 4a. Approve the PR

```
gh pr review PR_NUMBER -R OWNER/REPO --approve
```

#### 4b. Mark as Ready

```
gh pr ready PR_NUMBER -R OWNER/REPO
```

#### 4c. Approve Pending Workflow Runs

Use the PR's `headRefOid` (head commit SHA, obtained in step 2) to find only the workflow runs that correspond to the latest commit on the approved PR:

```
gh run list -R OWNER/REPO --commit HEAD_REF_OID --status action_required --json databaseId,conclusion
```

This ensures we only target runs for the exact commit on the PR, not older runs on the same branch.

For each run where `conclusion` is `action_required`, re-run it to approve:

```
gh run rerun RUN_ID -R OWNER/REPO
```

If the re-run fails, ignore the error and continue.

#### 4d. Enable Auto-merge with Squash

```
gh pr merge PR_NUMBER -R OWNER/REPO --auto --squash
```

If auto-merge is not enabled on the repository, this will error — ignore the error and continue.

### 5. Report Results

Provide a summary table of all PRs processed:

| Repo | PR | Action | Result |
|------|----|--------|--------|
| `owner/repo` | #123 Title | Approved + auto-merge | Success |
| `owner/repo` | #456 Title | Closed (no changes) | Success |
| `owner/repo` | #789 Title | Skipped by user | — |

## Error Handling

| Error | Likely Cause | Fix |
|-------|-------------|-----|
| `gh: command not found` | GitHub CLI not installed | Install via `winget install GitHub.cli` or `brew install gh` |
| `not logged in` | Not authenticated | Run `gh auth login` |
| `Could not resolve to a PullRequest` | PR already merged or closed | Skip it |
| `auto-merge is not allowed` | Repo doesn't have auto-merge enabled | Ignore; the PR will need manual merge |
| `pull request is not mergeable` | Required checks haven't passed yet | Auto-merge will handle it once checks pass |
139 changes: 139 additions & 0 deletions .github/skills/azuretools-release-prep/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
---
name: azuretools-release-prep
description: "Automates release preparation for 'ms-azuretools' VS Code extensions (e.g. vscode-azurefunctions, vscode-azurecontainerapps, vscode-azureresourcegroups, vscode-azureappservice, vscode-azurestorage, etc.). Handles branch setup from latest main, intelligent version bump recommendations, constructs CHANGELOG.md entry with curated commit inclusion/exclusion, and surfaces NOTICE.html and telemetry TODOs. WHEN: azuretools release, release prep, prepare release, update changelog, prep for release, release extension."
license: MIT
metadata:
author: Microsoft
version: "0.0.1"
---

# Azure Tools for VS Code - Release Prep

> **AUTHORITATIVE GUIDANCE — MANDATORY COMPLIANCE**
>
> This skill drives the full release preparation workflow for VS Code extensions published by **ms-azuretools**. Execute phases in order. **Never apply changes without user confirmation.**

---

## Triggers

Activate this skill when the user wants to:
- Prepare a release candidate for any `ms-azuretools` VS Code extension
- Build or update the CHANGELOG for a new release

---

## Rules

1. Always pull the latest `main` and branch from it — never from a stale or feature branch unless told otherwise
2. Always identify the last **stable** release tag before analyzing commits
3. Always present a recommendation with reasoning **before** asking the user to choose a version
4. Always show the full changelog draft with omission reasoning **before** writing any files
5. Never commit directly to `main`
6. Never apply file changes without user confirmation

---

## Overview

> 1. **SETUP** — Pull latest main, create release branch
> 2. **ANALYZE** — Classify commits, recommend version bump, get user approval
> 3. **SELECT** — Interactive commit selection list → generate changelog → get user approval
> 4. **APPLY** — Write `package.json` and `CHANGELOG.md`
> 5. **PUBLISH** — Review generated assets, commit, push, create draft PR, create draft release notes
> 6. **NEXT STEPS** — Show remaining Next Steps as a markdown checklist

---

## Phase 1: Branch Setup

| # | Action | Reference |
|---|--------|-----------|
| 1 | Verify we are in the correct repository | [branch-setup.md](references/branch-setup.md) |
| 2 | Fetch origin, checkout `main`, pull latest | [branch-setup.md](references/branch-setup.md) |
| 3 | Create a timestamped release branch | [branch-setup.md](references/branch-setup.md) |

---

## Phase 2: Version Analysis

| # | Action | Reference |
|---|--------|-----------|
| 1 | Find last stable release tag; get current version from `package.json` | [version-analysis.md](references/version-analysis.md) |
| 2 | Collect all commits since last tag | [version-analysis.md](references/version-analysis.md) |
| 3 | Classify each commit and flag suggested skips | [commit-classification.md](references/commit-classification.md) |
| 4 | Determine recommended version bump | [version-analysis.md](references/version-analysis.md) |
| 5 | Present reasoning summary and ask user to choose version | [version-analysis.md](references/version-analysis.md) |

> ❌ **Do not proceed to Phase 3 until the user confirms the target version.**

---

## Phase 3: Changelog Construction

| # | Action | Reference |
|---|--------|-----------|
| 1 | Present interactive numbered list using classifications from Phase 2 — all pre-selected, ⚠️ on suggested skips | [changelog-construction.md](references/changelog-construction.md) |
| 2 | Accept deselections from user; re-render until confirmed | [changelog-construction.md](references/changelog-construction.md) |
| 3 | Generate changelog entry → save preview to session state file → display inline in chat with file path → get user approval | [changelog-construction.md](references/changelog-construction.md), [changelog-template.md](references/changelog-template.md) |

> ❌ **Do not proceed to Phase 4 until the user approves the generated entry.**

---

## Phase 4: Apply Changes

| # | Action | Reference |
|---|--------|-----------|
| 1 | Update `"version"` in `package.json` | [version-analysis.md](references/version-analysis.md) |
| 2 | Read approved entry from session preview file and prepend to `CHANGELOG.md` | [changelog-construction.md](references/changelog-construction.md) |

---

## Phase 5: Review and Publish

| # | Action | Reference |
|---|--------|-----------|
| 1 | Show `git diff` of `package.json` and `CHANGELOG.md` | — |
| 2 | Ask user if they want to commit, push, and open a draft PR + release | [pr-creation.md](references/pr-creation.md) |
| 3 | Stage, commit, and push the release branch | [pr-creation.md](references/pr-creation.md) |
| 4 | Create draft PR and print the URL | [pr-creation.md](references/pr-creation.md) |
| 5 | Create draft GitHub Release (body = changelog entry) and print the URL | [pr-creation.md](references/pr-creation.md) |
| 6 | Create draft alpha version bump branch, run `npm version prerelease --preid=alpha`, push, and open a second draft PR targeting the release branch | [pr-creation.md](references/pr-creation.md) |

---

## Phase 6: Surface Next Steps

| # | Action | Reference |
|---|--------|-----------|
| 1 | Create release checklist issue in `microsoft/azcode-internal` and capture URL | [release-checklist-issue.md](references/release-checklist-issue.md) |
| 2 | Generate session summary file with what was done and next steps | [next-steps-summary.md](references/next-steps-summary.md) |
| 3 | Print the file path to the chat | [next-steps-summary.md](references/next-steps-summary.md) |

---

## Outputs

| Artifact | Change |
|----------|--------|
| `package.json` | `version` field bumped to `NEW_VERSION` |
| `CHANGELOG.md` | New entry prepended at top |
| Git branch | Pushed to origin |
| Draft PR | Opened on GitHub |
| Draft Release | Created on GitHub (`v<NEW_VERSION>`), body matches changelog entry |
| Session summary | Written to `~/.copilot/session-state/<session-id>/release-prep-<REPO_NAME>-<NEW_VERSION>.md` |
| Release checklist issue | Created in `microsoft/azcode-internal` |

---

## References

- [Branch Setup](references/branch-setup.md)
- [Version Analysis](references/version-analysis.md)
- [Commit Classification](references/commit-classification.md)
- [Changelog Template](references/changelog-template.md)
- [Changelog Construction](references/changelog-construction.md)
- [PR Creation](references/pr-creation.md)
- [Release Checklist Issue](references/release-checklist-issue.md)
- [Next Steps Summary](references/next-steps-summary.md)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move these into microsoft/azcode-internal so they can be used more broadly?

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Branch Setup

## Preflight Checks

Before touching any files, verify the environment is ready:

```bash
# 1. Verify gh CLI is authenticated
gh auth status

# 2. Ensure the working tree is clean (no uncommitted changes)
git status --porcelain
```

If `gh auth status` shows an error, ask the user to run `gh auth login` before continuing.

If `git status --porcelain` produces any output, warn the user that uncommitted changes are present. Ask them to stash or commit first. **Do not proceed until the working tree is clean.**

---

## Step 1: Detect Repository

Confirm we are in an `ms-azuretools` extension repository and capture variables used by later phases:

```bash
# Verify publisher
python3 -c "import json; d=json.load(open('package.json')); print(d.get('publisher',''), d.get('name',''))"

# Capture remote URL (strip .git suffix)
git remote get-url origin
```

Expected: `publisher` = `ms-azuretools`. Known extensions include:
`vscode-azurefunctions`, `vscode-azurecontainerapps`, `vscode-azureresourcegroups`,
`vscode-azureappservice`, `vscode-azurestorage`, `vscode-cosmosdb`, `vscode-azurestaticwebapps`, `vscode-azurevirtualmachines`

If `publisher` is not `ms-azuretools`, warn the user and ask for confirmation before continuing.

Store for use in later phases:
- `REPO_NAME` — the `name` field from `package.json`
- `REPO_REMOTE_URL` — remote origin URL with `.git` stripped (e.g. `https://github.com/microsoft/vscode-azurecontainerapps`)

---

## Step 2: Pull Latest Main

```bash
git fetch origin
git checkout main
git pull origin main --ff-only
```

---

## Step 3: Create Release Branch

Branch name does not matter — use a timestamped name:

```bash
git checkout -b copilot-rel-prep/$(date +%Y-%m-%d-%H%M)
```

Confirm the branch was created and show the current HEAD commit SHA.
Loading
Loading