Skip to content

Commit e49490e

Browse files
kyliauclydin
authored andcommitted
build: determine version to publish from package.json
Currently, the version of a release is determined by the git tag. This PR changes release script to determine the release version from the `version` property in the root `package.json`. Release docs have also been updated.
1 parent f0cc118 commit e49490e

File tree

6 files changed

+27
-45
lines changed

6 files changed

+27
-45
lines changed

docs/process/release.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ Alan | Doug
2222
Charles | Keen
2323
Filipe | Minko
2424

25-
## Triaging Issues
26-
TBD
27-
2825
## Merging PRs
2926

3027
The list of PRs which are currently ready to merge (approved with passing status checks) can
@@ -38,7 +35,6 @@ When ready to merge a PR, run the following command:
3835
yarn ng-dev pr merge <pr>
3936
```
4037

41-
4238
### Maintaining LTS branches
4339

4440
Releases that are under Long Term Support (LTS) are listed on [angular.io](https://angular.io/guide/releases#support-policy-and-schedule).
@@ -57,25 +53,20 @@ In general, cherry picks for LTS should only be done if it meets one of the crit
5753

5854
## Before releasing
5955

60-
Make sure the CI is green.
61-
62-
Consider if you need to update [`packages/schematics/angular/utility/latest-versions.ts`](https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/utility/latest-versions.ts) to reflect changes in dependent versions.
56+
Update `Angular` version in [`packages/schematics/angular/utility/latest-versions.ts`](https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/utility/latest-versions.ts).
6357

6458
## Shepparding
6559

6660
As commits are cherry-picked when PRs are merged, creating the release should be a matter of creating a tag.
6761

68-
Update the package versions to reflect the new release version in **both**:
69-
1. [`package.json`](https://github.com/angular/angular-cli/blob/master/package.json#L3)
70-
1. [`packages/schematics/angular/utility/latest-versions.ts`](https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/utility/latest-versions.ts)
71-
7262
```bash
73-
git commit -a -m 'release: vXX'
63+
git add packages/schematics/angular/utility/latest-versions.ts
64+
git commit -m 'release: vXX'
7465
git tag -a 'vXX' -m 'release: tag vXX'
7566
```
7667

77-
The package versions we are about to publish are derived from the git tag that
78-
we just created. Double check that the versions are correct by running the
68+
The package versions we are about to publish are derived from `version` in the root
69+
[`package.json`](https://github.com/angular/angular-cli/blob/master/package.json#L3). Double check that the versions are correct by running the
7970
following command.
8071

8172
```bash
@@ -94,7 +85,7 @@ git push upstream --follow-tags
9485
**This can ONLY be done by a Google employee.**
9586

9687
Log in to the Wombat publishing service using your own github and google.com
97-
account to publish. This enforces the loging is done using 2Factor auth.
88+
account to publish. This enforces the login is done using 2Factor auth.
9889

9990
Run `npm login --registry https://wombat-dressing-room.appspot.com`:
10091

@@ -110,7 +101,7 @@ After closing the tab, you have successfully logged in, it is time to publish.
110101

111102
**This can ONLY be done by a Google employee.**
112103

113-
**It is a good idea to wait for CI to be green on the patch branch and tag before doing the release.**
104+
**Wait for CI to be green after pushing the release commit.**
114105

115106
For the first release of a major version, follow the instructions in
116107
[Publishing a Major Version](#publishing-a-major-version) section.
@@ -158,6 +149,16 @@ using the `--githubToken` flag. You just then have to confirm the draft.
158149

159150
> **Tags containing `next` or `rc` should be marked as pre-release.**
160151
152+
## Post-release Version Update
153+
154+
Update the package versions to reflect the *next* release version in **both**:
155+
1. `version` in [`package.json`](https://github.com/angular/angular-cli/blob/master/package.json#L3)
156+
1. `DevkitBuild*` in [`packages/schematics/angular/utility/latest-versions.ts`](https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/utility/latest-versions.ts)
157+
158+
```sh
159+
git commit package.json packages/schematics/angular/utility/latest-versions.ts -m "build: bump version to vXX"
160+
```
161+
161162
### Microsite Publishing
162163

163164
The [microsite](https://cli.angular.io/) is the landing page for Angular CLI and

lib/packages.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -160,25 +160,8 @@ function _getSnapshotHash(_pkg: PackageInfo): string {
160160
}
161161

162162

163-
let stableVersion = '';
164-
let experimentalVersion = '';
165-
function _getVersionFromGit(experimental: boolean): string {
166-
if (stableVersion && experimentalVersion) {
167-
return experimental ? experimentalVersion : stableVersion;
168-
}
169-
170-
const hasLocalChanges = _exec(`git status --porcelain`) != '';
171-
const scmVersionTagRaw = _exec(`git describe --match v[0-9]*.[0-9]*.[0-9]* --abbrev=7 --tags`)
172-
.slice(1);
173-
stableVersion = scmVersionTagRaw.replace(/-([0-9]+)-g/, '+$1.');
174-
if (hasLocalChanges) {
175-
stableVersion += stableVersion.includes('+') ? '.with-local-changes' : '+with-local-changes';
176-
}
177-
178-
experimentalVersion = stableToExperimentalVersion(stableVersion);
179-
180-
return experimental ? experimentalVersion : stableVersion;
181-
}
163+
const stableVersion = loadRootPackageJson().version;
164+
const experimentalVersion = stableToExperimentalVersion(stableVersion);
182165

183166
/**
184167
* Convert a stable version to its experimental equivalent. For example,
@@ -245,9 +228,7 @@ export const packages: PackageMap =
245228

246229
dependencies: [],
247230
reverseDependencies: [],
248-
get version() {
249-
return _getVersionFromGit(experimental);
250-
},
231+
version: experimental ? experimentalVersion : stableVersion,
251232
};
252233

253234
return packages;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular/devkit-repo",
3-
"version": "11.2.5",
3+
"version": "11.2.6",
44
"private": true,
55
"description": "Software Development Kit for Angular",
66
"bin": {

packages/schematics/angular/utility/latest-versions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export const latestVersions = {
1818
// For our e2e tests, these versions must match the latest tag present on the branch.
1919
// During RC periods they will not match the latest RC until there's a new git tag, and
2020
// should not be updated.
21-
DevkitBuildAngular: '~0.1102.5',
22-
DevkitBuildNgPackagr: '~0.1102.5',
23-
DevkitBuildWebpack: '~0.1102.5',
21+
DevkitBuildAngular: '~0.1102.6',
22+
DevkitBuildNgPackagr: '~0.1102.6',
23+
DevkitBuildWebpack: '~0.1102.6',
2424

2525
ngPackagr: '^11.0.0',
2626
};

scripts/packages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function(args: { json: boolean, version: boolean, releaseCheck: b
1717
if (args.releaseCheck) {
1818
const {version: root} = loadRootPackageJson();
1919
const experimental = stableToExperimentalVersion(root);
20-
logger.info(`The expected version for the release is ${colors.bold(root)} (${experimental})`);
20+
logger.info(`The expected version for the release is ${colors.bold(root)} (${experimental}) based on root package.json.`);
2121
logger.info(
2222
Object.keys(packages)
2323
.filter(name => !packages[name].private)

scripts/publish.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ function _versionCheck(args: PublishArgs, logger: logging.Logger) {
111111
export default async function (args: PublishArgs, logger: logging.Logger) {
112112
const { tag } = args;
113113
if (!tag) {
114-
// NPM requires that all releases have a tag associated, defaulting to
115-
// `latest`, so there is no way to allow a publish without a tag.
114+
// NPM requires that all releases have a tag associated.
116115
// https://github.com/npm/npm/issues/10625#issuecomment-162106553
116+
// Do not publish without a tag.
117117
throw new Error('--tag is required.');
118118
}
119119

0 commit comments

Comments
 (0)