Skip to content
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

Generate NPM tag within publish-release bash script #2635

Merged
merged 5 commits into from
Jun 10, 2022

Conversation

vanitabarrett
Copy link
Contributor

@vanitabarrett vanitabarrett commented May 20, 2022

Part of #2004

What

Add logic to existing publish-release bash script to work out the correct NPM tag for a release before publishing it.
This also adds the option to provide a tag yourself if the suggested one doesn't suit.

Why

If we want to release versions of GOV.UK Frontend older than the current major version, e.g: releasing a version 4.5.0. when we've already released version 5.0.0, then we need to be able to override NPM's default "tag" which tags the most recent release as "latest".

Tagging v4.5.0 as "latest" would mean people doing npm install govuk-frontend would get v4.5.0 instead of v5.0.0.

Unfortunately, the only way to NOT tag something as "latest" is to provide a different tag to tag it with. This script compares the tags on Github with the version being proposed. If the version number being proposed is smaller than the highest version tag on Github, the NPM tag will be latest-[MAJOR-VERSION-NUMBER] e.g: latest-4

Examples

Current release New release Tag
4.1.0 4.1.1 latest
4.1.0 4.2.0 latest
4.1.0 3.14.0 latest-3
4.1.0 5.0.0 latest
5.0.0 4.1.5 latest-4

@vanitabarrett vanitabarrett requested a review from a team May 20, 2022 10:49
bin/generate-npm-tag.sh Outdated Show resolved Hide resolved
@36degrees
Copy link
Contributor

This is really neat – great idea 🙌🏻

At the risk of bike-shedding, I think e.g. v4-latest might be clearer than latest-4… although having said that it looks like bootstrap do something very similar so maybe there's a convention here I'm not aware of…

@lfdebrux
Copy link
Member

At the risk of bike-shedding, I think e.g. v4-latest might be clearer than latest-4… although having said that it looks like bootstrap do something very similar so maybe there's a convention here I'm not aware of…

I don't think npm will let you use v4-latest, as they say a tag can't be a valid semantic version, and they say 'the simplest way to avoid semver problems with tags is to use tags that do not begin with a number or the letter v.' [1].

bin/generate-npm-tag.sh Outdated Show resolved Hide resolved
@vanitabarrett
Copy link
Contributor Author

This is really neat – great idea 🙌🏻

At the risk of bike-shedding, I think e.g. v4-latest might be clearer than latest-4… although having said that it looks like bootstrap do something very similar so maybe there's a convention here I'm not aware of…

This was my first though, but what @lfdebrux said above - looks like npm advise against doing this. We could do latest-v4 if that's any better 🤷

If we want to release versions of GOV.UK Frontend older than the current major version,
e.g: releasing a version 4.5.0. when we've already released version 5.0.0, then we need
to be able to override NPM's default "tag" which tags the most recent release as "latest".

Tagging v4.5.0 as "latest" would mean people doing `npm install govuk-frontend` would get
v4.5.0 instead of v5.0.0.

Unfortunately, the only way to NOT tag something as "latest" is to provide a different
tag to tag it with. This script compares the tags on Github with the version being proposed.
If the version number being proposed is smaller than the highest version tag on Github, the
NPM tag will be `latest-[MAJOR-VERSION-NUMBER]` e.g: `latest-4`
@36degrees
Copy link
Contributor

Ahah! That all makes sense. Personally I think latest-v4 makes it a little clearer what the number represents, but not precious about if we'd rather just follow what bootstrap are doing.

Copy link
Member

@lfdebrux lfdebrux left a comment

Choose a reason for hiding this comment

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

One small stylistic suggestion, otherwise looks good to me!

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2635 June 10, 2022 13:58 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2635 June 10, 2022 13:59 Inactive
@vanitabarrett vanitabarrett merged commit 237a2d0 into main Jun 10, 2022
@vanitabarrett vanitabarrett deleted the add-npm-tag-script branch June 10, 2022 14:05
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.

5 participants