Skip to content

Commit 9970beb

Browse files
kyliaualan-agius4
authored andcommitted
docs: Update doc for major version release
1 parent fb7b1e1 commit 9970beb

File tree

3 files changed

+76
-13
lines changed

3 files changed

+76
-13
lines changed

docs/process/release.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ merge commits into LTS branches must open a pull request against the specific ba
101101
In general, cherry picks for LTS should only be done if it meets one of the criteria below:
102102

103103
1. It addresses a critical security vulnerability.
104-
2. It fixes a breaking change in the external environment.
104+
2. It fixes a breaking change in the external environment.
105105
For example, this could happen if one of the dependencies is deleted from NPM.
106106
3. It fixes a legitimate failure on CI for a particular LTS branch.
107107

@@ -122,9 +122,20 @@ As commits are cherry-picked when PRs are merged, creating the release should be
122122
```bash
123123
git commit -a -m 'release: vXX'
124124
git tag 'vXX'
125+
```
126+
127+
The package versions we are about to publish are derived from the git tag that
128+
we just created. Double check that the versions are correct by running the
129+
following command.
130+
131+
```bash
132+
yarn admin packages --version
133+
```
125134

126-
# Make sure to run these commands together, as missing tags can cause CI
127-
# failures.
135+
Now push the commit and the tag to the upstream repository.
136+
**Make sure to run these commands together, as missing tags can cause CI failures.**
137+
138+
```bash
128139
git push upstream && git push upstream --tags
129140
```
130141

@@ -151,7 +162,10 @@ After closing the tab, you have successfully logged in, it is time to publish.
151162

152163
**It is a good idea to wait for CI to be green on the patch branch and tag before doing the release.**
153164

154-
Check out the patch branch (e.g. `9.1.x`), then run:
165+
For the first release of a major version, follow the instructions in
166+
[Publishing a Major Version](#publishing-a-major-version) section.
167+
168+
For non-major release, check out the patch branch (e.g. `9.1.x`), then run:
155169
```bash
156170
yarn # Reload dependencies
157171
yarn admin publish
@@ -208,3 +222,23 @@ If you don't have the firebase CLI installed, you can install it using
208222
`npm install --global firebase-tools` (or use your package manager of choice).
209223

210224
This is detailed in [`etc/cli.angular.io/README.md`](https://github.com/angular/angular-cli/blob/master/etc/cli.angular.io/README.md).
225+
226+
## Publishing a Major Version
227+
228+
For the first release of a major version, say `v10.0.0`, checkout the major branch
229+
(i.e. `10.0.x`), then run:
230+
231+
```bash
232+
yarn # Reload dependencies
233+
yarn admin publish --tag next # a major release is always tagged as next initially
234+
```
235+
236+
Confirm with downstream repositories (Components, etc) that everything is ok.
237+
Once the release is stable, wait for Framework to retag their packages, then
238+
retag the CLI packages as `latest`.
239+
The command below will automatically retag stable packages as well as experimental
240+
packages.
241+
242+
```bash
243+
yarn admin dist-tag --version 10.0.0 --tag latest
244+
```

lib/packages.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,21 @@ function _getVersionFromGit(experimental: boolean): string {
171171
stableVersion += stableVersion.includes('+') ? '.with-local-changes' : '+with-local-changes';
172172
}
173173

174-
experimentalVersion = `0.${stableVersion.replace(/^(\d+)\.(\d+)/, (_, major, minor) => {
175-
return '' + (parseInt(major, 10) * 100 + parseInt(minor, 10));
176-
})}`;
174+
experimentalVersion = stableToExperimentalVersion(stableVersion);
177175

178176
return experimental ? experimentalVersion : stableVersion;
179177
}
180178

179+
/**
180+
* Convert a stable version to its experimental equivalent. For example,
181+
* stable = 10.2.3, experimental = 0.1002.3
182+
* @param stable Must begin with d+.d+ where d is a 0-9 digit.
183+
*/
184+
export function stableToExperimentalVersion(stable: string): string {
185+
return `0.${stable.replace(/^(\d+)\.(\d+)/, (_, major, minor) => {
186+
return '' + (parseInt(major, 10) * 100 + parseInt(minor, 10));
187+
})}`;
188+
}
181189

182190
// All the supported packages. Go through the packages directory and create a map of
183191
// name => PackageInfo. This map is partial as it lacks some information that requires the

scripts/dist-tag.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,56 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
// tslint:disable: no-implicit-dependencies
9+
// tslint:disable: no-implicit-dependencies we import @angular-devkit/core but
10+
// it is not in package.json, which is fine, this is just a script.
1011

1112
import { logging } from '@angular-devkit/core';
1213
import { execSync } from 'child_process';
1314
import { packages, stableToExperimentalVersion } from '../lib/packages';
1415

1516
interface DistTagOptions {
1617
/**
17-
* Version must be specified in format d+.d+.d+ where d is a 0-9 digit.
18-
* This must be a stable version with major version > 0.
19-
* The script will automatically convert stable version to experimental.
18+
* The version of CLI packages published to NPM.
19+
* Version must begin with d+.d+.d+ where d is a 0-9 digit.
20+
* For example, `1.2.3`, `10.0.0-next.0`, or `10.0.0-rc.0`.
21+
* Since we publish both stable and experimental packages to NPM, the version
22+
* provided here must be a stable version with major version > 0.
23+
* The script will automatically convert stable version to experimental for
24+
* experimental packages.
2025
*/
2126
version: string;
2227
/**
2328
* Tag is usually "latest" or "next", but could also be "v10-lts" for example.
2429
*/
2530
tag: string;
31+
/**
32+
* If true, prints the help message.
33+
*/
34+
help: boolean;
2635
}
2736

2837
/**
2938
* This function adds a tag to all public packages in the CLI repo.
3039
*/
3140
export default function(args: DistTagOptions, logger: logging.Logger) {
41+
if (args.help) {
42+
logger.info(`dist-tag adds a tag to all public packages in the CLI repo.
43+
44+
If the packages already have a tag associated with them, then dist-tag will
45+
retag the packages.
46+
47+
Usage:
48+
--version the version of CLI packages published to NPM.
49+
--tag the tag to add to CLI packages`);
50+
51+
return;
52+
}
3253
const {version, tag} = args;
3354
if (!version || version.startsWith('v')) {
3455
throw new Error('Version must be specified in format d+.d+.d+');
3556
}
3657
if (version.startsWith('0')) {
37-
throw new Error('Version must be "stable", with major version > 0');
58+
throw new Error(`Major version must be > 0, did you mean ${stableToExperimentalVersion(version)}?`);
3859
}
3960
if (!tag) {
4061
throw new Error('Tag must be non-empty, for example: latest, next, v10-lts, etc');
@@ -43,7 +64,7 @@ export default function(args: DistTagOptions, logger: logging.Logger) {
4364
for (const {name, experimental} of publicPackages) {
4465
const actualVersion = experimental ? stableToExperimentalVersion(version) : version;
4566
// See https://docs.npmjs.com/cli/dist-tag for documentation
46-
const cmd = `npm dist-tag add ${name}@${actualVersion} ${tag}`;
67+
const cmd = `npm dist-tag add '${name}@${actualVersion}' '${tag}'`;
4768
logger.debug(cmd); // print debug output by specifying --verbose
4869
const output = execSync(cmd, { encoding: 'utf8' });
4970
logger.info(output.trim());

0 commit comments

Comments
 (0)