Skip to content

Commit

Permalink
chore: update release (#1614)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry authored Nov 14, 2023
1 parent 19967e7 commit 4242b02
Show file tree
Hide file tree
Showing 12 changed files with 384 additions and 242 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ jobs:
cmd5: yarn lint
cmd6: yarn test --codeCoverage

- name: Run distributed integration tests with independent local registries
run: yarn nx run-many --target=integration-test --all --withRegistry
- name: Run distributed integration tests with independent local registries (max 1 per agent for improved throughput)
run: yarn nx run-many --target=integration-test --withRegistry --parallel=1

- name: Publish code coverage report
uses: codecov/codecov-action@v3
Expand Down Expand Up @@ -244,7 +244,10 @@ jobs:
# but it should not matter because this should be a full cloud cache hit
run: NX_CLOUD_DISTRIBUTED_EXECUTION=false yarn build

- name: Publish all packages to npm
run: yarn lerna publish --loglevel=verbose --canary --exact --force-publish --yes
- name: Figure out and apply the next canary version
run: yarn ts-node --project ./tsconfig.tools.json ./tools/scripts/apply-canary-version.ts

- name: Publish all packages to npm with the canary tag
run: yarn nx release publish --tag canary
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
7 changes: 6 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
package-lock=false
package-lock=false

# For npm v7 and later, an authToken needs to be present in the publish request (even though we don't use it
# for the publishing to verdaccio)
# Source: https://twitter.com/verdaccio_npm/status/1357798427283910660
//localhost:4872/:_authToken=fake
29 changes: 21 additions & 8 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"nxCloudAccessToken": "Y2MxNmI0YWItNDdhYS00ZWUxLTliZjMtODkzYjZkYTE4YjgxfHJlYWQtd3JpdGU=",
"release": {
"groups": {
"npm": {
"projects": ["*", "!nx-plugin", "!integration-tests*"]
}
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
Expand All @@ -19,17 +26,9 @@
"dependsOn": ["^build"],
"cache": true
},
"test": {
"dependsOn": ["^build"],
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
"cache": true
},
"lint": {
"cache": true
},
"e2e": {
"cache": true
},
"integration-test": {
"dependsOn": ["^build"],
"cache": true
Expand All @@ -39,6 +38,20 @@
},
"check-rule-lists": {
"cache": true
},
"@nx/jest:jest": {
"dependsOn": ["^build"],
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
"cache": true,
"options": {
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
},
"namedInputs": {
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@
"@angular/compiler": "17.0.1",
"@commitlint/cli": "18.2.0",
"@commitlint/config-conventional": "18.1.0",
"@nx/devkit": "17.0.3",
"@nx/eslint-plugin": "17.0.3",
"@nx/jest": "17.0.3",
"@nx/js": "17.0.3",
"@nx/plugin": "17.0.3",
"@nx/workspace": "17.0.3",
"@nx/devkit": "17.1.2",
"@nx/eslint-plugin": "17.1.2",
"@nx/jest": "17.1.2",
"@nx/js": "17.1.2",
"@nx/plugin": "17.1.2",
"@nx/workspace": "17.1.2",
"@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-typescript": "^11.1.0",
Expand Down Expand Up @@ -92,7 +92,7 @@
"lerna": "7.4.2",
"lint-staged": "15.0.2",
"ncp": "2.0.0",
"nx": "17.0.3",
"nx": "17.1.2",
"prettier": "3.0.3",
"prettier-v2-for-jest-inline-snapshots": "npm:prettier@^2",
"rimraf": "5.0.5",
Expand Down
3 changes: 1 addition & 2 deletions packages/builder/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/packages/builder"],
"options": {
"jestConfig": "packages/builder/jest.config.ts",
"passWithNoTests": true
"jestConfig": "packages/builder/jest.config.ts"
}
},
"clean": {
Expand Down
1 change: 1 addition & 0 deletions packages/integration-tests/local-registry/htpasswd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tet:YCNzj8gKzXBWg:autocreated 2023-11-14T11:36:24.640Z
1 change: 0 additions & 1 deletion packages/integration-tests/local-registry/htpassword

This file was deleted.

13 changes: 3 additions & 10 deletions packages/integration-tests/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,9 @@
},
"spawn-and-populate-local-registry": {
"dependsOn": [
{
"target": "build",
"dependencies": true
},
{
"target": "kill-existing-verdaccio"
},
{
"target": "reset-verdaccio-storage"
}
"^build",
"kill-existing-verdaccio",
"reset-verdaccio-storage"
],
"executor": "nx:run-commands",
"options": {
Expand Down
55 changes: 13 additions & 42 deletions packages/integration-tests/publish-to-verdaccio.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#!/usr/bin/env bash

VERSION=$1
NPM_REGISTRY=http://localhost:4872/
set -e

echo
# Change to the root of the monorepo
cd ../../

VERSION=$1
NPM_REGISTRY=$(npm config get registry)

if [[ ! $NPM_REGISTRY == http://localhost* ]]; then
echo "------------------"
Expand All @@ -13,56 +16,24 @@ if [[ ! $NPM_REGISTRY == http://localhost* ]]; then
exit 1;
fi

# Change to the root of the monorepo
cd ../../

echo "Publishing to npm registry $NPM_REGISTRY"

echo ""

echo "Running npx lerna version $VERSION --exact --force-publish --no-git-tag-version --no-push --no-changelog --yes"

npx lerna version $VERSION --exact --force-publish --no-git-tag-version --no-push --no-changelog --yes

echo "Publishing all relevant packages to $NPM_REGISTRY"
echo "Running yarn nx release version $VERSION"

echo ""

# There is no way for us to publish via lerna while our git working directory is not clean,
# which is the case because of our version bump, so manually publish all the relevant packages for now

# For npm v7 and later, an authToken needs to be present in the publish request (even though we don't use it
# for the publishing to verdaccio)
# Source: https://twitter.com/verdaccio_npm/status/1357798427283910660

cd ./packages/builder
npm publish --registry $NPM_REGISTRY --//localhost:4872/:_authToken=fake
cd -

cd ./packages/bundled-angular-compiler
npm publish --registry $NPM_REGISTRY --//localhost:4872/:_authToken=fake
cd -
yarn nx release version $VERSION

cd ./packages/eslint-plugin
npm publish --registry $NPM_REGISTRY --//localhost:4872/:_authToken=fake
cd -

cd ./packages/eslint-plugin-template
npm publish --registry $NPM_REGISTRY --//localhost:4872/:_authToken=fake
cd -
echo ""

cd ./packages/schematics
npm publish --registry $NPM_REGISTRY --//localhost:4872/:_authToken=fake
cd -
echo "Publishing all relevant packages to $NPM_REGISTRY"

cd ./packages/template-parser
npm publish --registry $NPM_REGISTRY --//localhost:4872/:_authToken=fake
cd -
echo ""

cd ./packages/utils
npm publish --registry $NPM_REGISTRY --//localhost:4872/:_authToken=fake
cd -
yarn nx release publish --registry=$NPM_REGISTRY

echo ""

echo "Publishing complete"
echo "Publishing complete"
3 changes: 1 addition & 2 deletions packages/nx-plugin/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/nx-plugin/jest.config.ts",
"passWithNoTests": true
"jestConfig": "packages/nx-plugin/jest.config.ts"
}
}
},
Expand Down
65 changes: 65 additions & 0 deletions tools/scripts/apply-canary-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import execa from 'execa';
import semver from 'semver';

const preid = 'alpha';
const distTag = 'canary';

(async function main() {
const currentLatestVersion = execa
.sync('npm', ['view', '@angular-eslint/eslint-plugin@latest', 'version'])
.stdout?.trim();

const currentCanaryVersion = execa
.sync('npm', [
'view',
`@angular-eslint/eslint-plugin@${distTag}`,
'version',
])
.stdout?.trim();

console.log('\nResolved current versions: ', {
currentLatestVersion,
currentCanaryVersion,
});

let nextCanaryVersion: string | null;

if (semver.gte(currentLatestVersion, currentCanaryVersion)) {
console.log(
'\nLatest version is greater than or equal to the current canary version, starting new prerelease base...',
);
// Determine next minor version above the currentLatestVersion
nextCanaryVersion = semver.inc(
currentLatestVersion,
'prerelease',
undefined,
preid,
);
} else {
console.log(
'\nLatest version is less than the current canary version, incrementing the existing prerelease base...',
);
// Determine next prerelease version above the currentCanaryVersion
nextCanaryVersion = semver.inc(
currentCanaryVersion,
'prerelease',
undefined,
preid,
);
}

if (!nextCanaryVersion) {
console.log(`Error: Unable to determine next canary version`);
process.exit(1);
}

console.log(`\nApplying next canary version with Nx`);

const command = `nx release version ${nextCanaryVersion}`;

console.log(`\n> ${command}\n`);

execa.sync('yarn', command.split(' '), {
stdio: 'inherit',
});
})();
Loading

0 comments on commit 4242b02

Please sign in to comment.