Help me set up NBgv (Nerdbank.GitVersioning) for my repository following the pattern used in the NuGet Config Editor extension.
I'm working on a VS Code extension and want to implement semantic versioning using NBgv with the following requirements:
- Main branch:
main(or specify your default branch) - Release strategy: Releases should be triggered from the main branch and version tags
- CI/CD integration: GitHub Actions workflow that uses NBgv for versioning
- Package.json integration: For VS Code extensions, the version should be stamped into package.json
- Artifact generation: Build and publish artifacts with proper version numbers
Please help me create the following files and configurations:
Create a version.json file in the repository root with:
- Current version starting at
0.1(or specify your starting version) - Public release configuration for main branch and version tags
- Cloud build integration for build numbers
- Proper JSON schema reference for validation
If this is a Node.js/VS Code extension project, ensure package.json has:
- Version set to
"0.0.0-placeholder"(NBgv will replace this) - All other package metadata properly configured
Create a complete CI/CD workflow (.github/workflows/build.yml) that:
- Triggers on pushes to main branch (with appropriate path exclusions)
- Supports manual workflow dispatch
- Uses NBgv to stamp version into package.json
- Builds and packages the project
- Publishes to appropriate registry (VS Code Marketplace, npm, etc.)
- Creates GitHub releases with version tags using softprops/[email protected]
- Uploads build artifacts
Create a PR validation workflow (.github/workflows/pr-build.yml) that:
- Runs on pull requests to main branch
- Validates the build without publishing
- Ensures NBgv versioning works correctly
- Runs tests and linting
Use these defaults unless I specify otherwise:
Version Configuration:
- Starting version:
0.1 - Version increment: patch for regular commits, minor/major via conventional commits or manual tags
- Public release refs:
^refs/heads/main$and^refs/tags/v\\d+\\.\\d+ - Build number format: enabled for cloud builds
Workflow Configuration:
- Node.js version:
20.x - Build runner:
ubuntu-latest - Path exclusions:
**/*.md,**/*.gitignore,**/*.gitattributes,.github/**,resources/**,docs/**,sample/**,scripts/**
Repository Permissions:
contents: write(for creating tags and releases)pull-requests: write(for PR comments, if applicable)
If this is a VS Code extension, also ensure:
- Installation of
@vscode/vscefor packaging - Use of
vsce packagecommand with proper output naming - Publishing via
vsce publishwith PAT token - Proper artifact naming using repository name
Remind me to configure these repository secrets:
VSCE_PAT: Personal Access Token for VS Code Marketplace (if applicable)- Any other publishing tokens needed for the specific project type
- You MUST ensure
fetch-depth: 0in checkout action for proper Git history - Include build artifact uploads for debugging and manual distribution
- Generate release notes automatically from commits
- Handle both automatic (push to main) and manual (workflow_dispatch) triggers
- Validate that NBgv outputs are working correctly with debug echo statements
Before setting up, please confirm:
- What type of project is this? (VS Code extension, npm package, .NET library, etc.)
- What is your default branch name? (main, master, develop)
- What starting version should we use? (0.1, 1.0, etc.)
- Do you need any specific path exclusions for builds?
- What publishing registry/marketplace should we target?
- Do you have any specific build scripts or package managers beyond npm?
Generate the complete configuration files with appropriate comments explaining each section and how to customize them for different project types.