Skip to content

Commit a576f86

Browse files
Merge pull request #4001 from alphagov/backport-npm-version
[support/4.x] Backport: Publishing docs changes, versioning
2 parents 0afe4c7 + 9ac6ddb commit a576f86

File tree

6 files changed

+51
-26
lines changed

6 files changed

+51
-26
lines changed

bin/build-release.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/sh
22
set -e
33

4-
# Check if there are unexpected changes. Changes to CHANGELOG.md and the
5-
# package.json file are expected as part of the normal release process.
6-
changes="$(git status --porcelain -- ':!CHANGELOG.md' ':!package/package.json')"
4+
# Check if there are unexpected changes. Changes to CHANGELOG.md, package.json
5+
# and package-lock.json files are expected as part of the normal release process.
6+
changes="$(git status --porcelain -- ':!CHANGELOG.md' ':!package/package.json' ':!package-lock.json')"
77
if [[ -n $changes ]]; then
88
echo "⚠ Unexpected changes in your working directory:"
99
echo "$changes"
@@ -35,7 +35,7 @@ TAG="v$ALL_PACKAGE_VERSION"
3535
CURRENT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
3636

3737
if [ $(git tag -l "$TAG") ]; then
38-
echo "⚠️ Git tag $TAG already exists. Check you have updated the version in package/package.json correctly."
38+
echo "⚠️ Git tag $TAG already exists. Check you have run `npm version` correctly."
3939
exit 1;
4040
else
4141
git add .

bin/generate-npm-tag.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ CURRENT_VERSION=$(node -p "require('./package/package.json').version")
1010
function version() { echo "$@" | awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }'; }
1111

1212
if [ $CURRENT_VERSION == $HIGHEST_PUBLISHED_VERSION ]; then
13-
echo "⚠️ Git tag $TAG already exists. Check you have updated the version in package/package.json correctly."
13+
echo "⚠️ Git tag $TAG already exists. Check you have run `npm version` correctly."
1414
exit 1
1515
elif [ $(version $CURRENT_VERSION) -ge $(version $HIGHEST_PUBLISHED_VERSION) ]; then
1616
NPM_TAG="latest"

docs/contributing/testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ To make sure your changes work in the Design System, use `npm link` to test befo
139139
cd ../govuk-design-system
140140
git checkout main
141141
git pull
142-
npm install # note running `npm install` after `npm link` will destroy the link.
142+
npm ci # note running `npm ci` after `npm link` will destroy the link.
143143
npm link ../govuk-frontend/package/
144144
```
145145

docs/releasing/publishing-a-pre-release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Projects can point to this branch in their package.json, instead of to the publi
2525

2626
3. Run `nvm use` to make sure you’re using the right version of Node.js and npm.
2727

28-
4. Run `npm ci` to make sure you have the correct dependencies installed.
28+
4. Run `npm ci` to make sure you have the exact dependencies installed.
2929

3030
5. Run `npm run pre-release` to create and push a new branch that contains your changes. This process may take a few moments and will display a `Success!` message.
3131

docs/releasing/publishing-from-a-support-branch.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Read the docs for [what to do before publishing a release](/docs/releasing/befor
3535

3636
4. Create a new branch for your code changes (for example, `git checkout -b fix-the-thing`) from the `support/<MAJOR VERSION NUMBER>.x` branch.
3737

38-
5. Run `npm install` to make sure you have the latest dependencies installed.
38+
5. Run `npm ci` to make sure you have the exact dependencies installed.
3939

4040
6. Make your code changes, and test them following our [standard testing requirements](/docs/contributing/testing.md).
4141

@@ -53,25 +53,35 @@ Read the docs for [what to do before publishing a release](/docs/releasing/befor
5353

5454
3. Run `nvm use` to make sure you’re using the right version of Node.js and npm.
5555

56-
4. Run `npm install` to make sure you have the latest dependencies installed.
56+
4. Run `npm ci` to make sure you have the exact dependencies installed.
5757

58-
5. In the CHANGELOG.md, replace the 'Unreleased' heading with the new version number and its release type. For example, '3.14.1 (Fix release)'. Also add a new 'Unreleased' heading above this new heading, so people raising new pull requests know where to add them in the changelog.
58+
5. Update the [`CHANGELOG.md`](../../CHANGELOG.md) by:
5959

60-
6. Update the `package/package.json` version with the new version number.
60+
- changing the 'Unreleased' heading to the new version number and its release type. For example, '3.14.1 (Fix release)'
61+
- adding a new 'Unreleased' heading above the new version number and release type, so users will know where to add PRs to the changelog
62+
- saving your changes
6163

62-
7. Save the changes. Do not commit.
64+
6. Apply the new version number by running:
6365

64-
8. Run `npm run build-release` to:
66+
```
67+
npm version <NEW VERSION NUMBER> --no-git-tag-version --workspace package
68+
```
6569

66-
- build GOV.UK Frontend into the `/package` and `/dist` directories
67-
- commit the changes
68-
- push a branch to GitHub
70+
This step will update the `package.json` and project `package-lock.json` files.
6971

70-
You will now be prompted to continue or cancel.
72+
Do not commit the changes.
7173

72-
9. Raise a pull request, with `support/<MAJOR VERSION NUMBER>.x` as the base branch to merge into.
74+
7. Run `npm run build-release` to:
7375

74-
10. Once a developer approves the pull request, merge it into `support/<MAJOR VERSION NUMBER>.x`.
76+
- build GOV.UK Frontend into the `/package` and `/dist` directories
77+
- commit the changes
78+
- push a branch to GitHub
79+
80+
You will now be prompted to continue or cancel.
81+
82+
8. Raise a pull request, with `support/<MAJOR VERSION NUMBER>.x` as the base branch to merge into.
83+
84+
9. Once a developer approves the pull request, merge it into `support/<MAJOR VERSION NUMBER>.x`.
7585

7686
### Publish the release to npm
7787

@@ -106,7 +116,7 @@ Read the docs for [what to do after publishing a release](/docs/releasing/after-
106116

107117
1. Check out the `main` branch and pull the latest changes.
108118

109-
2. Run `nvm use` and `npm install` to make sure you have the latest dependencies installed.
119+
2. Run `nvm use` and `npm ci` to make sure you have the exact dependencies installed.
110120

111121
3. Make the same changes as in the patch fix pull request, and test them using our [standard testing requirements](/docs/contributing/testing.md). Remember that `main` will contain changes the support branch did not have, which might affect the code changes you’ll need to make.
112122

docs/releasing/publishing.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,33 @@ Developers should pair on releases. When remote working, it can be useful to be
1010

1111
2. Run `nvm use` to make sure you're using the right version of Node.js and npm.
1212

13-
3. Run `npm install` to make sure you have the latest dependencies installed.
13+
3. Run `npm ci` to make sure you have the exact dependencies installed.
1414

1515
4. Create and check out a new branch (`release-[version-number]`). See the [versioning documentation](/docs/contributing/versioning.md) for more information.
1616

1717
5. Update the [`CHANGELOG.md`](../../CHANGELOG.md) by:
1818

19-
- changing the 'Unreleased' heading to the new version-number and release-type - for example, '3.11.0 (Feature release)'
20-
- adding a new 'Unreleased' heading above the new version-number and release-type, so users will know where to add PRs to the changelog
19+
- changing the 'Unreleased' heading to the new version number and release type. For example, '3.11.0 (Feature release)'
20+
- adding a new 'Unreleased' heading above the new version number and release type, so users will know where to add PRs to the changelog
21+
- saving your changes
2122

22-
6. Update [`package/package.json`](../../package/package.json) version with the new version-number.
23+
6. Apply the new version number by running:
2324

24-
7. Save the changes. Do not commit.
25+
```
26+
npm version <NEW VERSION NUMBER> --no-git-tag-version --workspace package
27+
```
28+
29+
This step will update the `package.json` and project `package-lock.json` files.
30+
31+
Do not commit the changes.
32+
33+
7. Update browser data from ["Can I use"](https://caniuse.com) by running:
34+
35+
```
36+
npx update-browserslist-db@latest
37+
```
38+
39+
This step will update the project `package-lock.json` file if updates are found.
2540

2641
8. Run `npm run build-release` to:
2742

@@ -32,7 +47,7 @@ Developers should pair on releases. When remote working, it can be useful to be
3247
You will now be prompted to continue or cancel.
3348

3449
9. Create a pull request and copy the changelog text.
35-
When reviewing the PR, check that the version-numbers have been updated and that the compiled assets use this version-number.
50+
When reviewing the PR, check that the version numbers have been updated and that the compiled assets use this version number.
3651

3752
10. Once a reviewer approves the pull request, merge it to **main**.
3853

0 commit comments

Comments
 (0)