semver icon indicating copy to clipboard operation
semver copied to clipboard

feat: add --skipTag flag

Open mpsanchis opened this issue 1 year ago • 3 comments

It would be useful to use the semver plugin as a version calculator, and then use the calculated ${version} or ${tag} at a later stage. For instance, run it at the beginning of a pipeline to get the version, and then use that version to build packages, images, charts, etc. I have added a skipTag flag that allows running the plugin and not tagging the latest commit. In combination with skipCommit and skipProjectChangelog, one can run the plugin without modifying the repository.

An alternative would be to use dryRun, but this doesn't allow calling post targets.

mpsanchis avatar Mar 30 '23 08:03 mpsanchis

Codecov Report

Merging #687 (83c4392) into main (34c931a) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #687   +/-   ##
=======================================
  Coverage   96.78%   96.78%           
=======================================
  Files          28       28           
  Lines         591      591           
  Branches      100      100           
=======================================
  Hits          572      572           
  Misses          9        9           
  Partials       10       10           
Impacted Files Coverage Δ
packages/semver/src/executors/version/index.ts 98.24% <ø> (ø)
packages/semver/src/executors/version/version.ts 100.00% <ø> (ø)
packages/semver/src/executors/version/utils/git.ts 91.83% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Mar 30 '23 08:03 codecov[bot]

Thank you for this PR. I think we would need similar capability.

It would be useful to use the semver plugin as a version calculator, and then use the calculated ${version} or ${tag} at a later stage

How would you use this calculated version for other steps? And how would you ensure the same version is then used for creating the tag & a "release" on GitHub?

gazal-k avatar May 17 '23 10:05 gazal-k

How would you use this calculated version for other steps?

I am already doing it with another home-made nx plugin. The version is stored as an environment variable, and other programs that publish packages/images/charts use that version in the registries they publish to.

how would you ensure the same version is then used for creating the tag & a "release" on GitHub?

Unfortunately, as of now, nx doesn't support passing options as env vars to executors, so some of them (such as ngx-deploy-npm:deploy and @jscutlery/semver:gitlab) must be post-targets. This means (for now) calling @jscutlery/semver:version twice (one for version calculation, and one for passing the version to the post-targets that cannot read env vars)

mpsanchis avatar Jun 13 '23 06:06 mpsanchis