Skip to content

Instantly share code, notes, and snippets.

@timheuer
Created October 2, 2025 18:07
Show Gist options
  • Save timheuer/82528d83e1fbd04b5483c4ec9cf7b8bd to your computer and use it in GitHub Desktop.
Save timheuer/82528d83e1fbd04b5483c4ec9cf7b8bd to your computer and use it in GitHub Desktop.
nbgv.prompt.md

NBgv (Nerdbank.GitVersioning) Setup Prompt

Help me set up NBgv (Nerdbank.GitVersioning) for my repository following the pattern used in the NuGet Config Editor extension.

Project Context

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

Setup Instructions

Please help me create the following files and configurations:

1. NBgv Configuration (version.json)

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

2. Package.json Version Placeholder

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

3. GitHub Actions Workflow

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

4. Pull Request Workflow

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

Default Configuration Values

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)

VS Code Extension Specific Requirements

If this is a VS Code extension, also ensure:

  • Installation of @vscode/vsce for packaging
  • Use of vsce package command with proper output naming
  • Publishing via vsce publish with PAT token
  • Proper artifact naming using repository name

Secrets Configuration

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

Additional Considerations

  • You MUST ensure fetch-depth: 0 in 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

Questions to Clarify

Before setting up, please confirm:

  1. What type of project is this? (VS Code extension, npm package, .NET library, etc.)
  2. What is your default branch name? (main, master, develop)
  3. What starting version should we use? (0.1, 1.0, etc.)
  4. Do you need any specific path exclusions for builds?
  5. What publishing registry/marketplace should we target?
  6. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment