-
-
Notifications
You must be signed in to change notification settings - Fork 18
feat: Automatic version bumping from configured targets #707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
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
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
🤖 This preview updates automatically when you update the PR. |
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')); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Summary
When
minVersion >= 2.19.0and no custompreReleaseCommandis defined, Craft automatically bumps version numbers based on configured publish targets. This eliminates the need for ascripts/bump-version.shscript in most cases.How It Works
targetsin.craft.ymlSupported Targets
npmpackage.jsonnpm version --no-git-tag-versionpypipyproject.tomlcratesCargo.tomlcargo set-version(cargo-edit)gem*.gemspeclib/**/version.rbpub-devpubspec.yamlhexmix.exsnuget*.csprojPython (pypi) Detection Priority
[tool.hatch]→hatch version <version>[tool.poetry]→poetry version <version>[tool.setuptools_scm]→ No-op (version from git tags)[project]with version → Direct TOML editBreaking Changes
None. Existing projects continue to work unchanged. The feature is gated behind
minVersion: "2.19.0".Fixes #76