CircleCI-Public / orb-tools-orb

Various tools for authoring and publishing CircleCI orbs
https://circleci.com/orbs/registry/orb/circleci/orb-tools
MIT License
51 stars 74 forks source link

Allow customisation of git tag #162

Closed tdeekens closed 1 year ago

tdeekens commented 1 year ago

Describe Request:

This Orb currently requires the git tag pushed to be e.g. v1.2.3.

At times an Orb will be developed in a repository along side other code.

In those cases demanding a git tag format to be vx.y.z is not sufficient. It would be better to allow a prefix to the tag.

As a result the tag could be circle-orb-v1.2.3 and circle-orb-2-v1.2.3.

As a result one could publish multiple Orbs from one repository as well as a repository in which the current tag is already in use.

KyleTryon commented 1 year ago

Hello @tdeekens While the git tag could match this pattern, the version of the orb itself could not. https://circleci.com/docs/orb-concepts#semantic-versioning

Each individual orb can only publish as X.Y.Z and each version is immutable. With this fact, would being able to customize the got tag with a prefix still be preferable if the orb itself can not?

tdeekens commented 1 year ago

Hi,

thanks for getting back!

Yes, I am aware that each production published Orb is immutable and has to follow regular semantic version.

Even in this case it would still be preferable to prefix the git tag triggering a publish while the released Orb's version omits the prefix.

There are two scenarios I can see this being beneficial:

  1. The Orb living in a repository in which a regular xx.y.z tag scheme is already used by something else
  2. An Orb lives inside a repository with other (often private Orbs) needing to be published in different versions increments

In both cases the prefix would solve the issues one otherwise faces.

rodrigo-fagundes commented 1 year ago

Hi all,

I'm facing the same issue as described by @tdeekens, with multiple orbs living in the same repo. imho, the version pattern could still be checked (as it is now) but allowing us to pass the version as parameter would be awesome. You could still default to CIRCLE_TAG anyways.

It would greatly improve the flexibility and wouldn't hurt whoever uses it right now.

tdeekens commented 1 year ago

Thanks for chiming in,

just to clarify: the CRCLE_TAG is what git tag was previously when then pushed. If a tag is my-orb-v1.0.0 as a git tag then that will be the CIRCLE_TAG. This will then be configured as a filter for a certain Orb to be packed and published.

I then see two options how the Orb can use the tag to know what version to publish:

  1. You pass a tag_prefix parameter which tells the Orb which part of the CIRCLE_TAG to omit when intending to extract the version from the CIRCLE_TAG containing the prefix
  2. You pass the version as parameter yourself. Then you'd have to do what in 1. the Orb does yourself

There might be better options obviously.

rodrigo-fagundes commented 1 year ago

Personally, I prefer option (2) because of separation of concerns. If the job is to publish, it shouldn't (imho) care what's your naming convention.

rodrigo-fagundes commented 1 year ago

I took the initiative and sent a draft PR with a suggestion to illustrate. Sorry if there's something incorrect - I was aiming just at sharing my way of thinking.

rodrigo-fagundes commented 1 year ago

Did you find any workaround @tdeekens ?

tdeekens commented 1 year ago

No, I didn't. I don't think there is. The only work around I could think of is building my own orb-tools which suits my needs exactly. However, I still think this is a valid use case for the Orb and would help others if it was supported.

KyleTryon commented 1 year ago

Hey all, I think i could be misunderstanding.

@tdeekens the tag is not decided by the orb, it id decided by the config file, are you not able to modify the tag regex string in the deploy job?

tdeekens commented 1 year ago

@KyleTryon thanks for getting back. Trying to follow along your question. I can configure the git tag RegExp on "my" job triggering orb-tools to publish. Still orb-tools requires then requires the git tag to follow this format. So If I'd configure my job to trigger on say my-orb-name-v1.2.3 to publish via orb-tools then orb-tools would fail the the CIRCLE_TAG doesn't match the required format by orb-tools.

steinwelberg commented 1 year ago

I already opened an issue for a different (but related) issue: #172.

I would like to have the ability to specify a custom development version.

This used to be possible with the old orb version, but isn't anymore. See #172 for the reasoning why.

KyleTryon commented 1 year ago

Alright folks I think I have a possible solution that should satisfy everyone. We will allow users to supply custom regex strings and we will grep out the version from the matched tag strings. I will follow up shortly with a PR

tdeekens commented 1 year ago

I've adopted what was released. Thanks for your work. Really helps us out!