Skip to content

Conversation

@BYK
Copy link
Member

@BYK BYK commented Jan 12, 2026

Summary

When minVersion >= 2.19.0 and no custom preReleaseCommand is defined, Craft automatically bumps version numbers based on configured publish targets. This eliminates the need for a scripts/bump-version.sh script in most cases.

How It Works

  1. Craft examines configured targets in .craft.yml
  2. For each target that supports version bumping, it updates the appropriate project files
  3. Targets are processed in config order, deduplicated by type

Supported Targets

Target Detection Version Bump Method
npm package.json npm version --no-git-tag-version
pypi pyproject.toml hatch, poetry, setuptools-scm, or direct edit
crates Cargo.toml cargo set-version (cargo-edit)
gem *.gemspec Direct edit of gemspec + lib/**/version.rb
pub-dev pubspec.yaml Direct edit
hex mix.exs Direct edit
nuget *.csproj dotnet-setversion or direct XML edit

Python (pypi) Detection Priority

  1. [tool.hatch]hatch version <version>
  2. [tool.poetry]poetry version <version>
  3. [tool.setuptools_scm] → No-op (version from git tags)
  4. [project] with version → Direct TOML edit

Breaking Changes

None. Existing projects continue to work unchanged. The feature is gated behind minVersion: "2.19.0".

Fixes #76

When minVersion >= 2.19.0 and no preReleaseCommand is defined, Craft
automatically bumps version numbers based on configured publish targets.

Supported targets:
- npm: npm version --no-git-tag-version
- pypi: hatch, poetry, setuptools-scm, or direct pyproject.toml edit
- crates: cargo set-version (cargo-edit)
- gem: Direct edit of gemspec and lib/**/version.rb
- pub-dev: Direct edit of pubspec.yaml
- hex: Direct edit of mix.exs
- nuget: dotnet-setversion or direct XML edit

Fixes #76
@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • Automatic version bumping from configured targets by BYK in #707

🤖 This preview updates automatically when you update the PR.

BYK added 5 commits January 12, 2026 22:39
For npm/yarn/pnpm monorepos, automatically detect and bump versions in
all workspace packages:

- npm 7+: Uses npm version --workspaces
- yarn/pnpm or npm < 7: Falls back to individual package bumping

Private packages are skipped during workspace version bumping.
Tests cover:
- runAutomaticVersionBumps utility function
- NpmTarget.bumpVersion (including workspace detection)
- PypiTarget.bumpVersion (hatch, poetry, setuptools-scm, direct edit)
- CratesTarget.bumpVersion
- GemTarget.bumpVersion
- PubDevTarget.bumpVersion
- HexTarget.bumpVersion
- NugetTarget.bumpVersion
- Remove obvious comments (// Check if X exists)
- Simplify verbose multi-line comments to single lines
- Remove redundant JSDoc field descriptions
- Clean up try/catch blocks with explicit early returns
- Shorten verbose error messages
rootDir: string,
newVersion: string
): Promise<boolean> {
const gemspecFiles = readdirSync(rootDir).filter(f => f.endsWith('.gemspec'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sentry-ruby is a monorepo of several gems where each gemspec is not in the root dir but a subdir, example: https://github.com/getsentry/sentry-ruby/blob/master/sentry-ruby/sentry-ruby.gemspec

For npm/yarn/pnpm monorepos, Craft automatically detects and bumps versions in all workspace packages:

- **npm 7+**: Uses `npm version --workspaces` to bump all packages at once
- **yarn/pnpm or npm < 7**: Falls back to bumping each non-private package individually
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where's my dear Bun? we can add it later, i think we could just look for Bun lockfiles bun.lockb / bun.lock, add BUN_BIN, USE_BUN env vars, and bun publishsupport.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it supports workspaces too https://bun.com/docs/pm/workspaces

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bump versions directly for known package managers

4 participants