From 90a01968f49869845af118f341eba3385ff9c89e Mon Sep 17 00:00:00 2001 From: Keen Yee Liau Date: Mon, 22 Mar 2021 20:10:16 -0700 Subject: [PATCH] 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. --- docs/process/release.md | 32 +++++++++---------- lib/packages.ts | 25 ++------------- package.json | 2 +- .../angular/utility/latest-versions.ts | 2 +- scripts/packages.ts | 2 +- scripts/publish.ts | 4 +-- 6 files changed, 24 insertions(+), 43 deletions(-) diff --git a/docs/process/release.md b/docs/process/release.md index 4ed6ace1b5..80ebbf092b 100644 --- a/docs/process/release.md +++ b/docs/process/release.md @@ -22,9 +22,6 @@ Alan | Doug Charles | Keen Filipe | Joey -## Triaging Issues -TBD - ## Merging PRs 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: yarn ng-dev pr merge ``` - ### Maintaining LTS branches Releases that are under Long Term Support (LTS) are listed on [angular.io](https://angular.io/guide/releases#support-policy-and-schedule). @@ -57,26 +53,20 @@ In general, cherry picks for LTS should only be done if it meets one of the crit ## Before releasing -Make sure the CI is green. - -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. +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). ## Shepparding As commits are cherry-picked when PRs are merged, creating the release should be a matter of creating a tag. -Update the package versions to reflect the new release version in **both**: -1. [`package.json`](https://github.com/angular/angular-cli/blob/master/package.json#L3) -1. [`packages/schematics/angular/utility/latest-versions.ts`](https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/utility/latest-versions.ts) - ```bash -git add package.json packages/schematics/angular/utility/latest-versions.ts +git add packages/schematics/angular/utility/latest-versions.ts git commit -m 'release: vXX' git tag -a 'vXX' -m 'release: tag vXX' ``` -The package versions we are about to publish are derived from the git tag that -we just created. Double check that the versions are correct by running the +The package versions we are about to publish are derived from `version` in the root +[`package.json`](https://github.com/angular/angular-cli/blob/master/package.json#L3). Double check that the versions are correct by running the following command. ```bash @@ -95,7 +85,7 @@ git push upstream --follow-tags **This can ONLY be done by a Google employee.** Log in to the Wombat publishing service using your own github and google.com -account to publish. This enforces the loging is done using 2Factor auth. +account to publish. This enforces the login is done using 2Factor auth. Run `npm login --registry https://wombat-dressing-room.appspot.com`: @@ -111,7 +101,7 @@ After closing the tab, you have successfully logged in, it is time to publish. **This can ONLY be done by a Google employee.** -**It is a good idea to wait for CI to be green on the patch branch and tag before doing the release.** +**Wait for CI to be green after pushing the release commit.** For the first release of a major version, follow the instructions in [Publishing a Major Version](#publishing-a-major-version) section. @@ -159,6 +149,16 @@ using the `--githubToken` flag. You just then have to confirm the draft. > **Tags containing `next` or `rc` should be marked as pre-release.** +## Post-release Version Update + +Update the package versions to reflect the *next* release version in **both**: +1. `version` in [`package.json`](https://github.com/angular/angular-cli/blob/master/package.json#L3) +1. `DevkitBuildAngular` in [`packages/schematics/angular/utility/latest-versions.ts`](https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/utility/latest-versions.ts) + +```sh +git commit package.json packages/schematics/angular/utility/latest-versions.ts -m "build: bump version to vXX" +``` + ### Microsite Publishing The [microsite](https://cli.angular.io/) is the landing page for Angular CLI and diff --git a/lib/packages.ts b/lib/packages.ts index 61b95b5efd..8b5d3ca913 100644 --- a/lib/packages.ts +++ b/lib/packages.ts @@ -160,25 +160,8 @@ function _getSnapshotHash(_pkg: PackageInfo): string { } -let stableVersion = ''; -let experimentalVersion = ''; -function _getVersionFromGit(experimental: boolean): string { - if (stableVersion && experimentalVersion) { - return experimental ? experimentalVersion : stableVersion; - } - - const hasLocalChanges = _exec(`git status --porcelain`) != ''; - const scmVersionTagRaw = _exec(`git describe --match v[0-9]*.[0-9]*.[0-9]* --abbrev=7 --tags`) - .slice(1); - stableVersion = scmVersionTagRaw.replace(/-([0-9]+)-g/, '+$1.'); - if (hasLocalChanges) { - stableVersion += stableVersion.includes('+') ? '.with-local-changes' : '+with-local-changes'; - } - - experimentalVersion = stableToExperimentalVersion(stableVersion); - - return experimental ? experimentalVersion : stableVersion; -} +const stableVersion = loadRootPackageJson().version; +const experimentalVersion = stableToExperimentalVersion(stableVersion); /** * Convert a stable version to its experimental equivalent. For example, @@ -245,9 +228,7 @@ export const packages: PackageMap = dependencies: [], reverseDependencies: [], - get version() { - return _getVersionFromGit(experimental); - }, + version: experimental ? experimentalVersion : stableVersion, }; return packages; diff --git a/package.json b/package.json index 4dec235ade..7c95da0a1c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@angular/devkit-repo", - "version": "12.0.0-next.5", + "version": "12.0.0-next.6", "private": true, "description": "Software Development Kit for Angular", "bin": { diff --git a/packages/schematics/angular/utility/latest-versions.ts b/packages/schematics/angular/utility/latest-versions.ts index b014ea2703..f0642511f1 100644 --- a/packages/schematics/angular/utility/latest-versions.ts +++ b/packages/schematics/angular/utility/latest-versions.ts @@ -18,7 +18,7 @@ export const latestVersions = { // For our e2e tests, these versions must match the latest tag present on the branch. // During RC periods they will not match the latest RC until there's a new git tag, and // should not be updated. - DevkitBuildAngular: '~0.1200.0-next.5', + DevkitBuildAngular: '~0.1200.0-next.6', ngPackagr: '^12.0.0-next.0', }; diff --git a/scripts/packages.ts b/scripts/packages.ts index c51921254c..8dcf0e6498 100644 --- a/scripts/packages.ts +++ b/scripts/packages.ts @@ -17,7 +17,7 @@ export default function(args: { json: boolean, version: boolean, releaseCheck: b if (args.releaseCheck) { const {version: root} = loadRootPackageJson(); const experimental = stableToExperimentalVersion(root); - logger.info(`The expected version for the release is ${colors.bold(root)} (${experimental})`); + logger.info(`The expected version for the release is ${colors.bold(root)} (${experimental}) based on root package.json.`); logger.info( Object.keys(packages) .filter(name => !packages[name].private) diff --git a/scripts/publish.ts b/scripts/publish.ts index 7f517e183e..0f6cedde9b 100644 --- a/scripts/publish.ts +++ b/scripts/publish.ts @@ -111,9 +111,9 @@ function _versionCheck(args: PublishArgs, logger: logging.Logger) { export default async function (args: PublishArgs, logger: logging.Logger) { const { tag } = args; if (!tag) { - // NPM requires that all releases have a tag associated, defaulting to - // `latest`, so there is no way to allow a publish without a tag. + // NPM requires that all releases have a tag associated. // https://github.com/npm/npm/issues/10625#issuecomment-162106553 + // Do not publish without a tag. throw new Error('--tag is required.'); }