Skip to content

Commit 6326a9e

Browse files
Agent skill for js provider release (#294)
* prepare release skill * use scripts to update version * update * update * update * update * update scritps
1 parent ee83f42 commit 6326a9e

File tree

3 files changed

+487
-0
lines changed

3 files changed

+487
-0
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
name: prepare-release
3+
description: Prepare a release for the Azure App Configuration JavaScript Provider. 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 [Azure App Configuration JavaScript Provider](https://github.com/Azure/AppConfiguration-JavaScriptProvider) 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 → preview, main → release/stable, preview → release)
15+
- Prepare all the PRs needed before publishing a new release
16+
- Resolve merge conflicts between main and preview branches
17+
18+
## Background
19+
20+
### Repository Information
21+
- **GitHub Repo**: https://github.com/Azure/AppConfiguration-JavaScriptProvider
22+
- **Package Name**: `@azure/app-configuration-provider`
23+
24+
### Branch Structure
25+
- `main` – primary development branch for stable releases
26+
- `preview` – development branch for preview releases
27+
- `release/stable/v{major}` – release branch for stable versions (e.g., `release/stable/v2`)
28+
- `release/v{major}` – release branch for preview versions (e.g., `release/v2`)
29+
30+
### Version Files
31+
The version must be updated in **all four locations** simultaneously:
32+
1. `src/version.ts` – line 4: `export const VERSION = "<version>";`
33+
2. `package.json` – line 3: `"version": "<version>",`
34+
3. `package-lock.json` – line 3: `"version": "<version>",`
35+
4. `package-lock.json` – line 9: `"version": "<version>",`
36+
37+
### Version Format
38+
- **Stable**: `{major}.{minor}.{patch}` (e.g., `2.4.0`)
39+
- **Preview**: `{major}.{minor}.{patch}-preview` (e.g., `2.4.1-preview`)
40+
41+
## Quick Start
42+
43+
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.
44+
45+
---
46+
47+
### Workflow A: Stable Release
48+
49+
#### Step 1: Version Bump PR
50+
51+
Create a version bump PR targeting `main` by running the version bump script:
52+
53+
```bash
54+
./scripts/version-bump.sh <new_version>
55+
```
56+
57+
For example: `./scripts/version-bump.sh 2.5.0`
58+
59+
The script will automatically:
60+
1. Read the current version from `src/version.ts`.
61+
2. Create a new branch from `main` named `<username>/version-<new_version>` (e.g., `linglingye/version-2.5.0`).
62+
3. Update the version in all four files (`src/version.ts`, `package.json`, `package-lock.json` lines 3 and 9).
63+
4. Commit, push, and create a PR to `main` with title: `Version bump <new_version>`.
64+
65+
When the script prompts `Proceed? [y/N]`, confirm by entering `y`.
66+
67+
#### Step 2: Merge Main to Release Branch
68+
69+
After the version bump PR is merged, create a PR to merge `main` into the stable release branch by running:
70+
71+
```bash
72+
./scripts/merge-to-release.sh <new_version>
73+
```
74+
75+
For example: `./scripts/merge-to-release.sh 2.5.0`
76+
77+
When the script prompts `Proceed? [y/N]`, confirm by entering `y`.
78+
79+
> **Important**: Use "Merge commit" (not squash) when merging this PR to preserve commit history.
80+
81+
---
82+
83+
### Workflow B: Preview Release
84+
85+
#### Step 1: Merge Main to Preview (Conflict Resolution)
86+
87+
Create a PR to merge `main` into `preview`. This will likely have conflicts.
88+
89+
1. Fetch the latest `main` and `preview` branches.
90+
2. Create a new branch from `preview` named `<username>/resolve-conflict` (or similar).
91+
3. Merge `main` into this branch. If there are conflicts, inform the user and let them resolve manually.
92+
4. Push the branch and create a PR targeting `preview` with title: `Merge main to preview`.
93+
94+
> **Important**: Use "Merge commit" (not squash) when merging this PR.
95+
96+
**Sample PR**: https://github.com/Azure/AppConfiguration-JavaScriptProvider/pull/272
97+
98+
#### Step 2: Version Bump PR
99+
100+
After the merge-to-preview PR is merged, create a version bump PR targeting `preview` by running the version bump script with the `--preview` flag:
101+
102+
```bash
103+
./scripts/version-bump.sh <new_version> --preview
104+
```
105+
106+
For example: `./scripts/version-bump.sh 2.5.1-preview --preview`
107+
108+
When the script prompts `Proceed? [y/N]`, confirm by entering `y`.
109+
110+
#### Step 3: Merge Preview to Release Branch
111+
112+
After the version bump PR is merged, create a PR to merge `preview` into the preview release branch by running:
113+
114+
```bash
115+
./scripts/merge-to-release.sh <new_version> --preview
116+
```
117+
118+
For example: `./scripts/merge-to-release.sh 2.5.1-preview --preview`
119+
120+
When the script prompts `Proceed? [y/N]`, confirm by entering `y`.
121+
122+
> **Important**: Use "Merge commit" (not squash) when merging this PR.
123+
124+
---
125+
126+
## Review Checklist
127+
128+
Each PR should be reviewed with the following checks:
129+
- [ ] Version is updated consistently across all 3 files
130+
- [ ] No unintended file changes are included
131+
- [ ] Merge PRs use **merge commit** strategy (not squash)
132+
- [ ] Branch names follow the naming conventions
133+
- [ ] All CI checks pass

scripts/merge-to-release.sh

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/bin/bash
2+
3+
# ============================================================================
4+
# merge-to-release.sh
5+
#
6+
# Creates a PR to merge a development branch into its corresponding release
7+
# branch. Used after a version bump PR has been merged.
8+
#
9+
# Usage:
10+
# ./scripts/merge-to-release.sh <version> [--preview]
11+
#
12+
# Examples:
13+
# ./scripts/merge-to-release.sh 2.5.0 # main → release/stable/v2
14+
# ./scripts/merge-to-release.sh 2.5.1-preview --preview # preview → release/v2
15+
#
16+
# Prerequisites:
17+
# - git and gh (GitHub CLI) must be installed and authenticated
18+
# ============================================================================
19+
20+
set -euo pipefail
21+
22+
# ── Helpers ──────────────────────────────────────────────────────────────────
23+
24+
usage() {
25+
cat <<EOF
26+
Usage: $(basename "$0") <version> [--preview]
27+
28+
Arguments:
29+
version The version that was just bumped (used to determine major version)
30+
--preview Merge preview → release/v{major} instead of
31+
main → release/stable/v{major}
32+
33+
Examples:
34+
$(basename "$0") 2.5.0 # main → release/stable/v2
35+
$(basename "$0") 2.5.1-preview --preview # preview → release/v2
36+
EOF
37+
exit 1
38+
}
39+
40+
error() {
41+
echo "ERROR: $1" >&2
42+
exit 1
43+
}
44+
45+
info() {
46+
echo "── $1"
47+
}
48+
49+
# ── Parse arguments ──────────────────────────────────────────────────────────
50+
51+
VERSION=""
52+
IS_PREVIEW=false
53+
54+
while [[ $# -gt 0 ]]; do
55+
case "$1" in
56+
--preview)
57+
IS_PREVIEW=true
58+
shift
59+
;;
60+
-h|--help)
61+
usage
62+
;;
63+
*)
64+
if [[ -z "$VERSION" ]]; then
65+
VERSION="$1"
66+
else
67+
error "Unexpected argument: $1"
68+
fi
69+
shift
70+
;;
71+
esac
72+
done
73+
74+
[[ -z "$VERSION" ]] && usage
75+
76+
# Validate version format
77+
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-preview)?$'; then
78+
error "Invalid version format '$VERSION'. Expected: X.Y.Z or X.Y.Z-preview"
79+
fi
80+
81+
# ── Determine branches ──────────────────────────────────────────────────────
82+
83+
# Extract major version (e.g. "2" from "2.5.0" or "2.5.1-preview")
84+
MAJOR_VERSION=$(echo "$VERSION" | cut -d. -f1)
85+
86+
if [[ "$IS_PREVIEW" == true ]]; then
87+
SOURCE_BRANCH="preview"
88+
TARGET_BRANCH="release/v${MAJOR_VERSION}"
89+
PR_TITLE="Merge preview to release/v${MAJOR_VERSION}"
90+
else
91+
SOURCE_BRANCH="main"
92+
TARGET_BRANCH="release/stable/v${MAJOR_VERSION}"
93+
PR_TITLE="Merge main to release/stable/v${MAJOR_VERSION}"
94+
fi
95+
96+
info "Source branch : $SOURCE_BRANCH"
97+
info "Target branch : $TARGET_BRANCH"
98+
info "PR title : $PR_TITLE"
99+
echo ""
100+
101+
# ── Confirm with user ────────────────────────────────────────────────────────
102+
103+
read -rp "Proceed? [y/N] " confirm
104+
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
105+
echo "Aborted."
106+
exit 0
107+
fi
108+
109+
echo ""
110+
111+
# ── Resolve project directory ────────────────────────────────────────────────
112+
113+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
114+
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
115+
cd "$PROJECT_DIR"
116+
117+
# ── Fetch latest branches ───────────────────────────────────────────────────
118+
119+
info "Fetching latest branches..."
120+
git fetch origin "$SOURCE_BRANCH"
121+
git fetch origin "$TARGET_BRANCH"
122+
123+
# ── Create PR ────────────────────────────────────────────────────────────────
124+
125+
info "Creating pull request..."
126+
PR_URL=$(gh pr create \
127+
--base "$TARGET_BRANCH" \
128+
--head "$SOURCE_BRANCH" \
129+
--title "$PR_TITLE" \
130+
--body "Merge \`$SOURCE_BRANCH\` into \`$TARGET_BRANCH\` after version bump \`$VERSION\`.
131+
132+
> **Important**: Use **Merge commit** (not squash) when merging this PR to preserve commit history.
133+
134+
---
135+
*This PR was created automatically by \`scripts/merge-to-release.sh\`.*")
136+
137+
echo ""
138+
info "Done! PR created: $PR_URL"
139+
echo ""
140+
echo "⚠️ Remember: Use \"Merge commit\" (not squash) when merging this PR."

0 commit comments

Comments
 (0)