jsr icon indicating copy to clipboard operation
jsr copied to clipboard

[Feature Request] publish using version argument

Open oliver-oloughlin opened this issue 1 year ago • 2 comments

The issue Right now, as far as I can tell, the version of a package must be set in a config json. Be that deno.json, jsr.json or other. I miss the ability to control the version of my package outside of the package itself, specifically through a GitHub workflow that gets triggered on publishing a new release. This creates the possibility of my release version and package version being out of sync (something that I have already done by mistake).

The solution I suggest that the publish command has a --version flag that can be optionally used to provide the new version instead of including it in the config file. I primarily want to be able to pass the exact version number, but it might also be useful to pass patch, minor or major to automatically increment the version.

Potential issues

  • A --version argument should probably not override an existing version entry in the package config, as I imagine that could create issues or confusion when downloading a specific version of the package where the config file says it's another version.
  • Setting a version through an argument could allow publishing the exact same code as a new version, multiple times. Maybe this could be solved through analyzing the contents and recognizing duplicate versions?

oliver-oloughlin avatar Mar 13 '24 21:03 oliver-oloughlin

Yes this feature makes sense to me. I think we should just hard error if the --version flag is passed, if there is also a version field specified in the config file.

Additionally, we'd still require specifying versions for individual packages when publishing a workspace.

lucacasonato avatar Mar 14 '24 10:03 lucacasonato

I agree that hard error in the case of --version flag and version field makes the most sense.

oliver-oloughlin avatar Mar 14 '24 15:03 oliver-oloughlin

Resolved by https://github.com/denoland/deno/pull/26141. Related: #544, #555.

wojpawlik avatar Dec 16 '24 14:12 wojpawlik

Related bug: https://github.com/denoland/deno/issues/27428

NathanFlurry avatar Dec 20 '24 02:12 NathanFlurry

This is implemented as of https://github.com/jsr-io/jsr/pull/868

To use it, remove the version field from the jsr.json/deno.json and then use the --set-version <verison> flag.

Also, I'd recommend checking out https://github.com/dsherret/jsr-publish-on-tag/

dsherret avatar Dec 20 '24 22:12 dsherret