Skip to content

Commit 8924fe6

Browse files
agent skill for release automation (#592)
1 parent 442b8b1 commit 8924fe6

3 files changed

Lines changed: 441 additions & 0 deletions

File tree

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
---
2+
name: prepare-release
3+
description: "Prepare a release for the Feature Management .NET SDK. Use when user mentions release preparation, version bump, creating merge PRs, preview release, or stable release for this project."
4+
---
5+
6+
# Prepare Release
7+
8+
This skill automates the release preparation workflow for the [Feature Management .NET SDK](https://github.com/microsoft/FeatureManagement-Dotnet) project.
9+
10+
## When to Use This Skill
11+
12+
Use this skill when you need to:
13+
- Bump the package version for a new stable or preview release
14+
- Create merge PRs to sync branches (main → release, preview → release)
15+
- Prepare all the PRs needed before publishing a new release
16+
17+
## Background
18+
19+
### Repository Information
20+
- **GitHub Repo**: https://github.com/microsoft/FeatureManagement-Dotnet
21+
- **Packages** (all 3 are released together with the same version):
22+
1. `Microsoft.FeatureManagement` — Base package
23+
2. `Microsoft.FeatureManagement.AspNetCore` — ASP.NET Core package
24+
3. `Microsoft.FeatureManagement.Telemetry.ApplicationInsights` — Application Insights telemetry package
25+
26+
### Branch Structure
27+
- `main` – primary development branch for stable releases
28+
- `preview` – development branch for preview releases
29+
- `release/v{major}` – release branch (e.g., `release/v4`)
30+
31+
### Version Files
32+
The version is defined by `<MajorVersion>`, `<MinorVersion>`, `<PatchVersion>`, and optionally `<PreviewVersion>` properties in **all three** `.csproj` files simultaneously:
33+
1. `src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj`
34+
2. `src/Microsoft.FeatureManagement.AspNetCore/Microsoft.FeatureManagement.AspNetCore.csproj`
35+
3. `src/Microsoft.FeatureManagement.Telemetry.ApplicationInsights/Microsoft.FeatureManagement.Telemetry.ApplicationInsights.csproj`
36+
37+
Each file contains a version block like:
38+
```xml
39+
<!-- Official Version -->
40+
<PropertyGroup>
41+
<MajorVersion>4</MajorVersion>
42+
<MinorVersion>1</MinorVersion>
43+
<PatchVersion>0</PatchVersion>
44+
</PropertyGroup>
45+
```
46+
47+
For preview versions, a `<PreviewVersion>` line is also present:
48+
```xml
49+
<!-- Official Version -->
50+
<PropertyGroup>
51+
<MajorVersion>4</MajorVersion>
52+
<MinorVersion>0</MinorVersion>
53+
<PatchVersion>0</PatchVersion>
54+
<PreviewVersion>-preview5</PreviewVersion>
55+
</PropertyGroup>
56+
```
57+
58+
### Version Format
59+
- **Stable**: `{major}.{minor}.{patch}` (e.g., `4.1.0`)
60+
- **Preview**: `{major}.{minor}.{patch}-preview{N}` (e.g., `4.0.0-preview5`)
61+
62+
## Quick Start
63+
64+
Ask the user whether this is a **stable** or **preview** release, and what the **new version number** should be. Then follow the appropriate workflow below.
65+
66+
---
67+
68+
### Workflow A: Stable Release
69+
70+
#### Step 1: Version Bump PR
71+
72+
Create a version bump PR targeting `main` by running the version bump script:
73+
74+
```powershell
75+
.\scripts\version-bump.ps1 <new_version>
76+
```
77+
78+
For example: `.\scripts\version-bump.ps1 4.2.0`
79+
80+
The script will automatically:
81+
1. Read the current version from the first `.csproj` file.
82+
2. Create a new branch from `main` named `<username>/version-bump-<new_version>` (e.g., `linglingye/version-bump-4.2.0`).
83+
3. Update `<MajorVersion>`, `<MinorVersion>`, `<PatchVersion>` in all three `.csproj` files, and remove `<PreviewVersion>` if present.
84+
4. Commit, push, and create a PR to `main` with title: `Version bump <new_version>`.
85+
86+
When the script prompts `Proceed? [y/N]`, confirm by entering `y`.
87+
88+
**Sample PR**: https://github.com/microsoft/FeatureManagement-Dotnet/pull/540
89+
90+
#### Step 2: Merge Main to Release Branch
91+
92+
After the version bump PR is merged, create a PR to merge `main` into the release branch by running:
93+
94+
```powershell
95+
.\scripts\merge-to-release.ps1 <new_version>
96+
```
97+
98+
For example: `.\scripts\merge-to-release.ps1 4.2.0`
99+
100+
When the script prompts `Proceed? [y/N]`, confirm by entering `y`.
101+
102+
> **Important**: Use "Create a merge commit" (not "Squash and merge") when merging this PR to preserve commit history.
103+
104+
**Sample PR**: https://github.com/microsoft/FeatureManagement-Dotnet/pull/541
105+
106+
---
107+
108+
### Workflow B: Preview Release
109+
110+
#### Step 1: Version Bump PR
111+
112+
Create a version bump PR targeting `preview` by running the version bump script with the `-Preview` flag:
113+
114+
```powershell
115+
.\scripts\version-bump.ps1 <new_version> -Preview
116+
```
117+
118+
For example: `.\scripts\version-bump.ps1 4.0.0-preview4 -Preview`
119+
120+
When the script prompts `Proceed? [y/N]`, confirm by entering `y`.
121+
122+
**Sample PR**: https://github.com/microsoft/FeatureManagement-Dotnet/pull/476
123+
124+
#### Step 2: Merge Preview to Release Branch
125+
126+
After the version bump PR is merged, create a PR to merge `preview` into the release branch by running:
127+
128+
```powershell
129+
.\scripts\merge-to-release.ps1 <new_version> -Preview
130+
```
131+
132+
For example: `.\scripts\merge-to-release.ps1 4.0.0-preview4 -Preview`
133+
134+
When the script prompts `Proceed? [y/N]`, confirm by entering `y`.
135+
136+
> **Important**: Use "Create a merge commit" (not "Squash and merge") when merging this PR to preserve commit history.
137+
138+
**Sample PR**: https://github.com/microsoft/FeatureManagement-Dotnet/pull/477
139+
140+
---
141+
142+
## Review Checklist
143+
144+
Each PR should be reviewed with the following checks:
145+
- [ ] Version is updated consistently across all 3 `.csproj` files
146+
- [ ] No unintended file changes are included
147+
- [ ] Merge PRs use **merge commit** strategy (not squash)
148+
- [ ] Branch names follow the naming conventions
149+
- [ ] All CI checks pass

scripts/merge-to-release.ps1

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<#
2+
.SYNOPSIS
3+
Creates a PR to merge a development branch into its corresponding release branch.
4+
.DESCRIPTION
5+
Used after a version bump PR has been merged. Creates a PR from main (or preview)
6+
into the appropriate release branch via the GitHub CLI (gh).
7+
.PARAMETER Version
8+
The version that was just bumped (used to determine major version and PR title)
9+
.PARAMETER Preview
10+
Merge preview -> release/v{major} instead of main -> release/v{major}
11+
.EXAMPLE
12+
.\scripts\merge-to-release.ps1 4.2.0
13+
# main -> release/v4
14+
.EXAMPLE
15+
.\scripts\merge-to-release.ps1 4.0.0-preview5 -Preview
16+
# preview -> release/v4
17+
.NOTES
18+
Prerequisites: git and gh (GitHub CLI) must be installed and authenticated
19+
#>
20+
21+
param(
22+
[Parameter(Mandatory = $true, Position = 0)]
23+
[string]$Version,
24+
25+
[switch]$Preview
26+
)
27+
28+
$ErrorActionPreference = "Stop"
29+
30+
# ── Validate version format ──────────────────────────────────────────────────
31+
32+
if ($Version -notmatch '^\d+\.\d+\.\d+(-preview\d+)?$') {
33+
Write-Error "Invalid version format '$Version'. Expected: X.Y.Z or X.Y.Z-previewN"
34+
exit 1
35+
}
36+
37+
# ── Determine branches ───────────────────────────────────────────────────────
38+
39+
# Extract major version (e.g. "4" from "4.2.0" or "4.0.0-preview5")
40+
$MajorVersion = ($Version -split '\.')[0]
41+
42+
if ($Preview) {
43+
$SourceBranch = "preview"
44+
$TargetBranch = "release/v$MajorVersion"
45+
$PrTitle = "Merge preview to release/v$MajorVersion"
46+
}
47+
else {
48+
$SourceBranch = "main"
49+
$TargetBranch = "release/v$MajorVersion"
50+
$PrTitle = "Merge main to release/v$MajorVersion"
51+
}
52+
53+
Write-Host "-- Source branch : $SourceBranch"
54+
Write-Host "-- Target branch : $TargetBranch"
55+
Write-Host "-- PR title : $PrTitle"
56+
Write-Host ""
57+
58+
# ── Confirm with user ────────────────────────────────────────────────────────
59+
60+
$confirm = Read-Host "Proceed? [y/N]"
61+
if ($confirm -notmatch '^[Yy]$') {
62+
Write-Host "Aborted."
63+
exit 0
64+
}
65+
Write-Host ""
66+
67+
# ── Resolve project directory ────────────────────────────────────────────────
68+
69+
$ProjectDir = Split-Path $PSScriptRoot -Parent
70+
Push-Location $ProjectDir
71+
72+
try {
73+
# ── Fetch latest branches ────────────────────────────────────────────────
74+
75+
Write-Host "-- Fetching latest branches..."
76+
git fetch origin $SourceBranch
77+
git fetch origin $TargetBranch
78+
79+
# ── Create PR ────────────────────────────────────────────────────────────
80+
81+
Write-Host "-- Creating pull request..."
82+
$Body = @"
83+
Merge ``$SourceBranch`` into ``$TargetBranch`` after version bump ``$Version``.
84+
85+
> **Important**: Use **Create a merge commit** (not "Squash and merge") when merging this PR to preserve commit history.
86+
87+
---
88+
*This PR was created automatically by ``scripts/merge-to-release.ps1``.*
89+
"@
90+
91+
$PrUrl = gh pr create --base $TargetBranch --head $SourceBranch --title $PrTitle --body $Body
92+
93+
Write-Host ""
94+
Write-Host "-- Done! PR created: $PrUrl"
95+
Write-Host ""
96+
Write-Host "WARNING: Use 'Create a merge commit' (not 'Squash and merge') when merging this PR."
97+
}
98+
finally {
99+
Pop-Location
100+
}

0 commit comments

Comments
 (0)