Skip to content

✨ Add label-based version increment to automated beta branch creation#1275

Merged
donavanbecker merged 4 commits intolatestfrom
copilot/fix-1274
Aug 28, 2025
Merged

✨ Add label-based version increment to automated beta branch creation#1275
donavanbecker merged 4 commits intolatestfrom
copilot/fix-1274

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Aug 28, 2025

This PR enhances the Copilot instructions with automated beta branch creation functionality that uses GitHub labels to determine the appropriate version increment type, ensuring all future pull requests follow the project's development workflow with intelligent version management.

Key Changes

Label-Based Version Management

The system now uses GitHub issue/PR labels to determine version increment types:

  • patch label - Bug fixes, documentation updates, minor improvements (4.3.1 → 4.3.2)
  • minor label - New features, device support additions, non-breaking enhancements (4.3.1 → 4.4.0)
  • major label - Breaking changes, API modifications, major architectural updates (4.3.1 → 5.0.0)

Enhanced Branch Targeting Strategy

The updated instructions include a comprehensive 4-step process:

  1. Primary Target: Look for existing beta branches (e.g., beta-4.3.2, beta-4.4.0)
  2. Automated Creation: If no beta branches exist, automatically create one based on detected labels
  3. Fallback Target: Only use the latest branch if beta branch creation fails
  4. Complete Toolchain: Provide all necessary detection and creation commands

Intelligent Label Processing

Added robust label detection and priority handling:

  • Label priority: When multiple increment labels exist, uses highest priority (major > minor > patch)
  • Fallback behavior: Defaults to patch increment when no relevant labels are found
  • GitHub API integration: Uses github-mcp-server-get_issue and github-mcp-server-get_pull_request for label detection

Automated Beta Branch Creation Workflow

Complete git workflow with label-based version calculation:

# Detect version increment type from issue/PR labels
# Use GitHub API to check labels array for: patch, minor, major

# Calculate next version based on detected labels
if [[ labels contains "major" ]]; then
  NEXT_VERSION=$(node -p "const v=require('./package.json').version.split('.'); v[0]=parseInt(v[0])+1; v[1]='0'; v[2]='0'; v.join('.')")
elif [[ labels contains "minor" ]]; then
  NEXT_VERSION=$(node -p "const v=require('./package.json').version.split('.'); v[1]=parseInt(v[1])+1; v[2]='0'; v.join('.')")
else
  # Default to patch increment (includes when "patch" label found or no labels)
  NEXT_VERSION=$(node -p "const v=require('./package.json').version.split('.'); v[2]=parseInt(v[2])+1; v.join('.')")
fi

BETA_BRANCH="beta-${NEXT_VERSION}"
git fetch origin
git checkout -b "${BETA_BRANCH}" origin/latest
git push origin "${BETA_BRANCH}"

Benefits

  • Explicit version control: Project maintainers can specify version increment type through labels before assigning issues
  • Conservative defaults: Falls back to patch increment when no labels are present, ensuring safe version management
  • Priority handling: Automatically resolves conflicts when multiple increment labels exist
  • Automated workflow: Eliminates manual beta branch creation while maintaining proper release management practices
  • Clear guidance: Provides project maintainers with explicit instructions on label usage

This ensures the development workflow always uses beta branches for testing changes before they reach the main development line, with intelligent version management based on the scope and impact of changes as indicated by GitHub labels.

Fixes #1274.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: donavanbecker <9875439+donavanbecker@users.noreply.github.com>
@donavanbecker
Copy link
Copy Markdown
Collaborator

@copilot, actually if there is no beta branch, can you create one based on the next possible version and then target it to that?

Copilot AI changed the title [WIP] ✨ Update Copilot instructions ✨ Add branch targeting strategy to Copilot instructions Aug 28, 2025
Copilot AI requested a review from donavanbecker August 28, 2025 19:47
Co-authored-by: donavanbecker <9875439+donavanbecker@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Aug 28, 2025

@copilot, actually if there is no beta branch, can you create one based on the next possible version and then target it to that?

I've updated the branch targeting strategy to include beta branch creation functionality as requested. The Copilot instructions now include:

  1. Automatic beta branch creation when no beta branches exist
  2. Version calculation logic supporting patch (4.3.1→4.3.2), minor (4.3.1→4.4.0), and major (4.3.1→5.0.0) increments
  3. Complete git workflow for creating and pushing new beta branches from the latest branch
  4. Guidance on increment types - patch for bug fixes, minor for new features, major for breaking changes

The system will now automatically create a beta branch with the next appropriate version when none exists, then target that branch for PRs. This ensures the development workflow always uses beta branches for testing before merging to main.

Commit: 855d32e

Copilot AI changed the title ✨ Add branch targeting strategy to Copilot instructions ✨ Add automated beta branch creation to Copilot instructions Aug 28, 2025
@donavanbecker
Copy link
Copy Markdown
Collaborator

@copilot should we use labels to determine if it is a patch for bug fixes, minor for new features, major for breaking changes? so the labels could be patch, minor,major and would have to be set before assigning the issue to copilot

Co-authored-by: donavanbecker <9875439+donavanbecker@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Aug 28, 2025

@copilot should we use labels to determine if it is a patch for bug fixes, minor for new features, major for breaking changes? so the labels could be patch, minor,major and would have to be set before...

I've updated the Copilot instructions to use labels for determining version increment types as suggested. The system now:

  1. Checks for labels on issues/PRs before creating beta branches: patch, minor, major
  2. Uses label priority when multiple increment labels exist (major > minor > patch)
  3. Falls back to patch increment when no relevant labels are found
  4. Provides clear guidance for project maintainers on which labels to set before assigning issues to Copilot

The label-based logic is integrated into the beta branch creation workflow, making version management more explicit and intentional rather than always defaulting to patch increments.

Commit: 106beb6

Copilot AI changed the title ✨ Add automated beta branch creation to Copilot instructions ✨ Add label-based version increment to automated beta branch creation Aug 28, 2025
@donavanbecker donavanbecker marked this pull request as ready for review August 28, 2025 20:05
@donavanbecker donavanbecker merged commit a1bf2da into latest Aug 28, 2025
11 of 13 checks passed
@donavanbecker donavanbecker deleted the copilot/fix-1274 branch August 28, 2025 20:05
donavanbecker added a commit that referenced this pull request Sep 18, 2025
…t development (#1262)

This PR creates comprehensive GitHub Copilot instructions to help
developers work effectively with the homebridge-switchbot codebase. The
instructions provide detailed guidance on building, testing, and
developing this TypeScript Homebridge platform plugin for SwitchBot
smart home devices.

**Complete Development Workflow Documentation:**
- Bootstrap and build process with exact commands and timing
expectations
- Dependency installation with required `--legacy-peer-deps` flag due to
TypeDoc conflicts
- TypeScript compilation and plugin UI building (~7 seconds)
- Test execution with Vitest (~2 seconds)
- Documentation generation with TypeDoc (~7 seconds)

**Validation Scenarios:**
- Manual plugin validation to ensure proper Homebridge registration
- Plugin loading verification with Node.js
- TypeScript compilation validation
- Documentation generation without warnings
- Complete workflow timing (~16 seconds total)

**Codebase Navigation Guide:**
- Detailed project structure with 38 TypeScript files across device and
IR device modules
- Key development areas for common tasks (adding devices, configuration
changes)
- File relationships and dependencies
- Base classes and extension patterns for device implementations

**Known Issues and Workarounds:**
- Documented dependency conflicts requiring `--legacy-peer-deps`
- ESLint configuration issues with import/extensions rule
- Build artifact management with updated .gitignore

**Timing and Performance Guidelines:**
- All commands tested with realistic timing expectations
- "NEVER CANCEL" warnings for builds with appropriate timeout
recommendations
- Complete validation workflow benchmarked at under 20 seconds

All commands and scenarios in the instructions have been thoroughly
tested and validated to ensure they work correctly in a fresh
development environment. The instructions follow the imperative tone
requirement and provide exhaustive coverage of the development workflow.

The file is located at `.github/copilot-instructions.md` and provides
over 7,000 characters of comprehensive guidance for GitHub Copilot to
work effectively with this codebase.

Fixes #1261.

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

✨ Add label-based version increment to automated beta branch creation (#1275)

This PR enhances the Copilot instructions with automated beta branch
creation functionality that uses GitHub labels to determine the
appropriate version increment type, ensuring all future pull requests
follow the project's development workflow with intelligent version
management.

The system now uses GitHub issue/PR labels to determine version
increment types:

- **`patch`** label - Bug fixes, documentation updates, minor
improvements (4.3.1 → 4.3.2)
- **`minor`** label - New features, device support additions,
non-breaking enhancements (4.3.1 → 4.4.0)
- **`major`** label - Breaking changes, API modifications, major
architectural updates (4.3.1 → 5.0.0)

The updated instructions include a comprehensive 4-step process:

1. **Primary Target**: Look for existing beta branches (e.g.,
`beta-4.3.2`, `beta-4.4.0`)
2. **Automated Creation**: If no beta branches exist, automatically
create one based on detected labels
3. **Fallback Target**: Only use the `latest` branch if beta branch
creation fails
4. **Complete Toolchain**: Provide all necessary detection and creation
commands

Added robust label detection and priority handling:

- **Label priority**: When multiple increment labels exist, uses highest
priority (major > minor > patch)
- **Fallback behavior**: Defaults to patch increment when no relevant
labels are found
- **GitHub API integration**: Uses `github-mcp-server-get_issue` and
`github-mcp-server-get_pull_request` for label detection

Complete git workflow with label-based version calculation:

```bash

if [[ labels contains "major" ]]; then
  NEXT_VERSION=$(node -p "const v=require('./package.json').version.split('.'); v[0]=parseInt(v[0])+1; v[1]='0'; v[2]='0'; v.join('.')")
elif [[ labels contains "minor" ]]; then
  NEXT_VERSION=$(node -p "const v=require('./package.json').version.split('.'); v[1]=parseInt(v[1])+1; v[2]='0'; v.join('.')")
else
  # Default to patch increment (includes when "patch" label found or no labels)
  NEXT_VERSION=$(node -p "const v=require('./package.json').version.split('.'); v[2]=parseInt(v[2])+1; v.join('.')")
fi

BETA_BRANCH="beta-${NEXT_VERSION}"
git fetch origin
git checkout -b "${BETA_BRANCH}" origin/latest
git push origin "${BETA_BRANCH}"
```

- **Explicit version control**: Project maintainers can specify version
increment type through labels before assigning issues
- **Conservative defaults**: Falls back to patch increment when no
labels are present, ensuring safe version management
- **Priority handling**: Automatically resolves conflicts when multiple
increment labels exist
- **Automated workflow**: Eliminates manual beta branch creation while
maintaining proper release management practices
- **Clear guidance**: Provides project maintainers with explicit
instructions on label usage

This ensures the development workflow always uses beta branches for
testing changes before they reach the main development line, with
intelligent version management based on the scope and impact of changes
as indicated by GitHub labels.

Fixes #1274.

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 Share your feedback on Copilot coding agent for the chance to win a
$200 gift card! Click
[here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start
the survey.

---------

✨ Enhanced Copilot instructions for beta branch targeting and label-based versioning (#1277)

Update Workflow

Co-Authored-By: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-Authored-By: donavanbecker <9875439+donavanbecker@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Update Copilot instructions

2 participants