Skip to content
Open
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
133 changes: 133 additions & 0 deletions .github/skills/prepare-release/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
name: prepare-release
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.
---

# Prepare Release

This skill automates the release preparation workflow for the [Azure App Configuration JavaScript Provider](https://github.com/Azure/AppConfiguration-JavaScriptProvider) project.

## When to Use This Skill

Use this skill when you need to:
- Bump the package version for a new stable or preview release
- Create merge PRs to sync branches (test-main → test-preview, test-main → test-release/stable, test-preview → test-release)
- Prepare all the PRs needed before publishing a new release
- Resolve merge conflicts between test-main and test-preview branches

## Background

### Repository Information
- **GitHub Repo**: https://github.com/Azure/AppConfiguration-JavaScriptProvider
- **Package Name**: `@azure/app-configuration-provider`

### Branch Structure
- `test-main` – primary development branch for stable releases
- `test-preview` – development branch for preview releases
- `test-release/stable/v{major}` – release branch for stable versions (e.g., `test-release/stable/v2`)
- `test-release/v{major}` – release branch for preview versions (e.g., `test-release/v2`)

### Version Files
The version must be updated in **all four locations** simultaneously:
1. `src/version.ts` – line 4: `export const VERSION = "<version>";`
2. `package.json` – line 3: `"version": "<version>",`
3. `package-lock.json` – line 3: `"version": "<version>",`
4. `package-lock.json` – line 9: `"version": "<version>",`

### Version Format
- **Stable**: `{major}.{minor}.{patch}` (e.g., `2.4.0`)
- **Preview**: `{major}.{minor}.{patch}-preview` (e.g., `2.4.1-preview`)

## Quick Start

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.

---

### Workflow A: Stable Release

#### Step 1: Version Bump PR

Create a version bump PR targeting `test-main` by running the version bump script:

```bash
./scripts/version-bump.sh <new_version>
```

For example: `./scripts/version-bump.sh 2.5.0`

The script will automatically:
1. Read the current version from `src/version.ts`.
2. Create a new branch from `test-main` named `<username>/version-<new_version>` (e.g., `linglingye/version-2.5.0`).
3. Update the version in all four files (`src/version.ts`, `package.json`, `package-lock.json` lines 3 and 9).
4. Commit, push, and create a PR to `test-main` with title: `Version bump <new_version>`.

When the script prompts `Proceed? [y/N]`, confirm by entering `y`.

#### Step 2: Merge Main to Release Branch

After the version bump PR is merged, create a PR to merge `test-main` into the stable release branch by running:

```bash
./scripts/merge-to-release.sh <new_version>
```

For example: `./scripts/merge-to-release.sh 2.5.0`

When the script prompts `Proceed? [y/N]`, confirm by entering `y`.

> **Important**: Use "Merge commit" (not squash) when merging this PR to preserve commit history.

---

### Workflow B: Preview Release

#### Step 1: Merge Main to Preview (Conflict Resolution)

Create a PR to merge `test-main` into `test-preview`. This will likely have conflicts.

1. Fetch the latest `test-main` and `test-preview` branches.
2. Create a new branch from `test-preview` named `<username>/resolve-conflict` (or similar).
3. Merge `test-main` into this branch. If there are conflicts, inform the user and let them resolve manually.
4. Push the branch and create a PR targeting `test-preview` with title: `Merge test-main to test-preview`.

> **Important**: Use "Merge commit" (not squash) when merging this PR.

**Sample PR**: https://github.com/Azure/AppConfiguration-JavaScriptProvider/pull/272

#### Step 2: Version Bump PR

After the merge-to-preview PR is merged, create a version bump PR targeting `test-preview` by running the version bump script with the `--preview` flag:

```bash
./scripts/version-bump.sh <new_version> --preview
```

For example: `./scripts/version-bump.sh 2.5.1-preview --preview`

When the script prompts `Proceed? [y/N]`, confirm by entering `y`.

#### Step 3: Merge Preview to Release Branch

After the version bump PR is merged, create a PR to merge `test-preview` into the preview release branch by running:

```bash
./scripts/merge-to-release.sh <new_version> --preview
```

For example: `./scripts/merge-to-release.sh 2.5.1-preview --preview`

When the script prompts `Proceed? [y/N]`, confirm by entering `y`.

> **Important**: Use "Merge commit" (not squash) when merging this PR.

---

## Review Checklist

Each PR should be reviewed with the following checks:
- [ ] Version is updated consistently across all 3 files
- [ ] No unintended file changes are included
- [ ] Merge PRs use **merge commit** strategy (not squash)
- [ ] Branch names follow the naming conventions
- [ ] All CI checks pass
140 changes: 140 additions & 0 deletions scripts/merge-to-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#!/bin/bash

# ============================================================================
# merge-to-release.sh
#
# Creates a PR to merge a development branch into its corresponding release
# branch. Used after a version bump PR has been merged.
#
# Usage:
# ./scripts/merge-to-release.sh <version> [--preview]
#
# Examples:
# ./scripts/merge-to-release.sh 2.5.0 # test-main → test-release/stable/v2
# ./scripts/merge-to-release.sh 2.5.1-preview --preview # test-preview → test-release/v2
#
# Prerequisites:
# - git and gh (GitHub CLI) must be installed and authenticated
# ============================================================================

set -euo pipefail

# ── Helpers ──────────────────────────────────────────────────────────────────

usage() {
cat <<EOF
Usage: $(basename "$0") <version> [--preview]

Arguments:
version The version that was just bumped (used to determine major version)
--preview Merge test-preview → test-release/v{major} instead of
test-main → test-release/stable/v{major}

Examples:
$(basename "$0") 2.5.0 # test-main → test-release/stable/v2
$(basename "$0") 2.5.1-preview --preview # test-preview → test-release/v2
EOF
exit 1
}

error() {
echo "ERROR: $1" >&2
exit 1
}

info() {
echo "── $1"
}

# ── Parse arguments ──────────────────────────────────────────────────────────

VERSION=""
IS_PREVIEW=false

while [[ $# -gt 0 ]]; do
case "$1" in
--preview)
IS_PREVIEW=true
shift
;;
-h|--help)
usage
;;
*)
if [[ -z "$VERSION" ]]; then
VERSION="$1"
else
error "Unexpected argument: $1"
fi
shift
;;
esac
done

[[ -z "$VERSION" ]] && usage

# Validate version format
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-preview)?$'; then
error "Invalid version format '$VERSION'. Expected: X.Y.Z or X.Y.Z-preview"
fi

# ── Determine branches ──────────────────────────────────────────────────────

# Extract major version (e.g. "2" from "2.5.0" or "2.5.1-preview")
MAJOR_VERSION=$(echo "$VERSION" | cut -d. -f1)

if [[ "$IS_PREVIEW" == true ]]; then
SOURCE_BRANCH="test-preview"
TARGET_BRANCH="test-release/v${MAJOR_VERSION}"
PR_TITLE="Merge test-preview to test-release/v${MAJOR_VERSION}"
else
SOURCE_BRANCH="test-main"
TARGET_BRANCH="test-release/stable/v${MAJOR_VERSION}"
PR_TITLE="Merge test-main to test-release/stable/v${MAJOR_VERSION}"
fi

info "Source branch : $SOURCE_BRANCH"
info "Target branch : $TARGET_BRANCH"
info "PR title : $PR_TITLE"
echo ""

# ── Confirm with user ────────────────────────────────────────────────────────

read -rp "Proceed? [y/N] " confirm
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 0
fi

echo ""

# ── Resolve project directory ────────────────────────────────────────────────

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_DIR"

# ── Fetch latest branches ───────────────────────────────────────────────────

info "Fetching latest branches..."
git fetch origin "$SOURCE_BRANCH"
git fetch origin "$TARGET_BRANCH"

# ── Create PR ────────────────────────────────────────────────────────────────

info "Creating pull request..."
PR_URL=$(gh pr create \
--base "$TARGET_BRANCH" \
--head "$SOURCE_BRANCH" \
--title "$PR_TITLE" \
--body "Merge \`$SOURCE_BRANCH\` into \`$TARGET_BRANCH\` after version bump \`$VERSION\`.

> **Important**: Use **Merge commit** (not squash) when merging this PR to preserve commit history.

---
*This PR was created automatically by \`scripts/merge-to-release.sh\`.*")

echo ""
info "Done! PR created: $PR_URL"
echo ""
echo "⚠️ Remember: Use \"Merge commit\" (not squash) when merging this PR."
Loading
Loading