Skip to content

Commit 5fccfe7

Browse files
Merge pull request #7086 from BitGo/revert-7049-configure-lerna-to-skip-git-operations
Revert "feat: update release workflow"
2 parents 1a34ab8 + 7c67909 commit 5fccfe7

File tree

125 files changed

+1170
-1324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1170
-1324
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ jobs:
6060
if: steps.lerna-cache.outputs.cache-hit != 'true' || contains( github.event.pull_request.labels.*.name, 'SKIP_CACHE')
6161
run: yarn install --with-frozen-lockfile --ignore-scripts
6262

63+
- name: Check In-Repo Package Versions
64+
run: yarn run check-versions
65+
6366
- name: build packages
6467
env:
6568
# Workaround for https://github.com/nodejs/node/issues/51555

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
node-version-file: .nvmrc
2727

2828
- name: Install BitGoJS
29-
run: yarn install --with-frozen-lockfile --ignore-scripts
29+
run: yarn install --with-frozen-lockfile
3030

3131
- name: Set Environment Variable for Alpha
3232
if: github.ref != 'refs/heads/master' # only publish changes if on feature branches

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ modules/**/pack-scoped/
1818
coverage
1919
/.direnv/
2020
.claude/
21-
scripts/cache/

check-package-versions.js

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/usr/bin/env node
2+
3+
// Check versions of in-repo packages to make sure they match with the package.json version.
4+
// This is to prevent inadvertent updates of dependency versions for packages which are symlinked
5+
// by lerna. The dependency versions of these packages should only ever be updated in the release branch.
6+
7+
const execa = require('execa');
8+
const path = require('path');
9+
10+
/**
11+
* Create a function which can run lerna commands
12+
* @param lernaPath {string} path to lerna binary
13+
* @returns {function(string, string[], Object.<string, string>): Promise<string>}
14+
*/
15+
function getLernaRunner(lernaPath) {
16+
return async (command, args = [], options = {}) => {
17+
const { stdout } = await execa(lernaPath, [command, ...args], options);
18+
return stdout;
19+
};
20+
}
21+
22+
/**
23+
* Get information on the modules in this repo that are managed by lerna.
24+
* @param lerna {function}
25+
* @returns {Promise<{path: *, name: *, deps: *, version: *}[]>}
26+
*/
27+
async function getLernaManagedModules(lerna) {
28+
const depGraph = JSON.parse(await lerna('list', ['--loglevel', 'silent', '--graph', '--all']));
29+
const managedModules = JSON.parse(await lerna('list', ['--loglevel', 'silent', '--json', '--all']));
30+
const managedModuleNames = managedModules.map(({ name }) => name);
31+
return Object.entries(depGraph).map(([name, deps]) => {
32+
const mod = managedModules.find((mod) => mod.name === name);
33+
return {
34+
name,
35+
deps: deps.filter((d) => managedModuleNames.includes(d)),
36+
path: mod.location,
37+
version: mod.version,
38+
};
39+
});
40+
}
41+
42+
/**
43+
* Build a dictionary from package name to the expected version of that package.
44+
* @param modules
45+
* @returns {Object.<string, string>}
46+
*/
47+
function getExpectedVersions(modules) {
48+
return Object.values(modules).reduce((acc, mod) => {
49+
return Object.assign(acc, { [mod.name]: mod.version });
50+
}, {});
51+
}
52+
53+
/**
54+
* For the module at `modPath`, get the version of the dependency `depName`.
55+
* If the version is prefixed with a carat or tilde, it will be stripped.
56+
* @param modPath {string}
57+
* @param depName {string}
58+
* @returns {string | undefined}
59+
*/
60+
function getDependencyVersion(modPath, depName) {
61+
const packageJsonPath = path.join(modPath, 'package.json');
62+
const {
63+
dependencies = {},
64+
devDependencies = {},
65+
optionalDependencies = {},
66+
peerDependencies = {},
67+
} = require(packageJsonPath);
68+
69+
const deps = { ...dependencies, ...devDependencies, ...optionalDependencies, ...peerDependencies };
70+
if (deps[depName]) {
71+
const matches = deps[depName].match(/^([^~])?(.*)$/);
72+
return matches[matches.length - 1];
73+
}
74+
}
75+
76+
async function main() {
77+
const { stdout: lernaBinary } = await execa('yarn', ['bin', 'lerna'], { cwd: process.cwd() });
78+
79+
const lerna = getLernaRunner(lernaBinary);
80+
81+
const modules = await getLernaManagedModules(lerna);
82+
const expectedVersions = getExpectedVersions(modules);
83+
84+
let exitCode = 0;
85+
86+
for (const mod of modules) {
87+
for (const dep of mod.deps) {
88+
const depVersion = getDependencyVersion(mod.path, dep);
89+
if (depVersion && depVersion !== expectedVersions[dep]) {
90+
// Handle pre-release versions by checking if the base version matches
91+
const baseDepVersion = depVersion.split('-')[0];
92+
const baseExpectedVersion = expectedVersions[dep].split('-')[0];
93+
94+
if (baseDepVersion !== baseExpectedVersion) {
95+
console.log(
96+
`error: expected lerna-managed module ${mod.name} to depend on package ${dep} using version ${expectedVersions[dep]}, but found version ${depVersion} instead`
97+
);
98+
exitCode = 1;
99+
}
100+
}
101+
}
102+
}
103+
104+
return exitCode;
105+
}
106+
107+
main()
108+
.then(process.exit)
109+
.catch((e) => console.error(e));

lerna.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44
"useWorkspaces": true,
55
"command": {
66
"version": {
7-
"message": "chore(root): publish modules",
8-
"allowBranch": "master",
9-
"skipGit": true
10-
},
11-
"publish": {
12-
"skipGit": true,
13-
"allowBranch": "master"
7+
"message": "chore(root): publish modules"
148
}
159
},
1610
"$schema": "node_modules/lerna/schemas/lerna-schema.json",

modules/abstract-cosmos/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bitgo/abstract-cosmos",
3-
"version": "0.0.0-semantic-release-managed",
3+
"version": "11.14.2",
44
"description": "BitGo SDK coin library for COSMOS base implementation",
55
"main": "./dist/src/index.js",
66
"types": "./dist/src/index.d.ts",
@@ -38,10 +38,10 @@
3838
]
3939
},
4040
"dependencies": {
41-
"@bitgo/sdk-core": "0.0.0-semantic-release-managed",
42-
"@bitgo/sdk-lib-mpc": "0.0.0-semantic-release-managed",
43-
"@bitgo/secp256k1": "0.0.0-semantic-release-managed",
44-
"@bitgo/statics": "0.0.0-semantic-release-managed",
41+
"@bitgo/sdk-core": "^36.8.0",
42+
"@bitgo/sdk-lib-mpc": "^10.7.0",
43+
"@bitgo/secp256k1": "^1.5.0",
44+
"@bitgo/statics": "^57.8.0",
4545
"@cosmjs/amino": "^0.29.5",
4646
"@cosmjs/crypto": "^0.30.1",
4747
"@cosmjs/encoding": "^0.29.5",

modules/abstract-eth/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bitgo/abstract-eth",
3-
"version": "0.0.0-semantic-release-managed",
3+
"version": "24.12.0",
44
"description": "BitGo SDK coin library for ETH base implementation",
55
"main": "./dist/src/index.js",
66
"types": "./dist/src/index.d.ts",
@@ -40,10 +40,10 @@
4040
]
4141
},
4242
"dependencies": {
43-
"@bitgo/sdk-core": "0.0.0-semantic-release-managed",
44-
"@bitgo/sdk-lib-mpc": "0.0.0-semantic-release-managed",
45-
"@bitgo/secp256k1": "0.0.0-semantic-release-managed",
46-
"@bitgo/statics": "0.0.0-semantic-release-managed",
43+
"@bitgo/sdk-core": "^36.8.0",
44+
"@bitgo/sdk-lib-mpc": "^10.7.0",
45+
"@bitgo/secp256k1": "^1.5.0",
46+
"@bitgo/statics": "^57.8.0",
4747
"@ethereumjs/common": "^2.6.5",
4848
"@ethereumjs/rlp": "^4.0.0",
4949
"@ethereumjs/tx": "^3.3.0",
@@ -60,8 +60,8 @@
6060
"superagent": "^9.0.1"
6161
},
6262
"devDependencies": {
63-
"@bitgo/sdk-api": "0.0.0-semantic-release-managed",
64-
"@bitgo/sdk-test": "0.0.0-semantic-release-managed",
63+
"@bitgo/sdk-api": "^1.68.3",
64+
"@bitgo/sdk-test": "^9.0.9",
6565
"@types/keccak": "^3.0.5"
6666
},
6767
"gitHead": "18e460ddf02de2dbf13c2aa243478188fb539f0c"

modules/abstract-lightning/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bitgo/abstract-lightning",
3-
"version": "0.0.0-semantic-release-managed",
3+
"version": "7.0.0",
44
"description": "BitGo SDK coin library for base Lightning Network coin implementation",
55
"main": "./dist/src/index.js",
66
"types": "./dist/src/index.d.ts",
@@ -40,10 +40,10 @@
4040
},
4141
"dependencies": {
4242
"@bitgo/public-types": "5.22.0",
43+
"@bitgo/sdk-core": "^36.8.0",
44+
"@bitgo/statics": "^57.8.0",
45+
"@bitgo/utxo-lib": "^11.10.0",
4346
"bip174": "npm:@bitgo-forks/[email protected]",
44-
"@bitgo/sdk-core": "0.0.0-semantic-release-managed",
45-
"@bitgo/statics": "0.0.0-semantic-release-managed",
46-
"@bitgo/utxo-lib": "0.0.0-semantic-release-managed",
4747
"bs58check": "^2.1.2",
4848
"fp-ts": "^2.12.2",
4949
"io-ts": "npm:@bitgo-forks/[email protected]",

modules/abstract-substrate/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bitgo/abstract-substrate",
3-
"version": "0.0.0-semantic-release-managed",
3+
"version": "1.10.4",
44
"description": "BitGo SDK coin library for Substrate base implementation",
55
"main": "./dist/src/index.js",
66
"types": "./dist/src/index.d.ts",
@@ -38,9 +38,9 @@
3838
]
3939
},
4040
"dependencies": {
41-
"@bitgo/sdk-core": "0.0.0-semantic-release-managed",
42-
"@bitgo/sdk-lib-mpc": "0.0.0-semantic-release-managed",
43-
"@bitgo/statics": "0.0.0-semantic-release-managed",
41+
"@bitgo/sdk-core": "^36.8.0",
42+
"@bitgo/sdk-lib-mpc": "^10.7.0",
43+
"@bitgo/statics": "^57.8.0",
4444
"@polkadot/api": "14.1.1",
4545
"@polkadot/keyring": "13.3.1",
4646
"@polkadot/types": "14.1.1",

modules/abstract-utxo/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bitgo/abstract-utxo",
3-
"version": "0.0.0-semantic-release-managed",
3+
"version": "9.26.0",
44
"description": "BitGo SDK coin library for UTXO base implementation",
55
"main": "./dist/src/index.js",
66
"types": "./dist/src/index.d.ts",
@@ -42,12 +42,12 @@
4242
]
4343
},
4444
"dependencies": {
45-
"@bitgo/blockapis": "0.0.0-semantic-release-managed",
46-
"@bitgo/sdk-api": "0.0.0-semantic-release-managed",
47-
"@bitgo/sdk-core": "0.0.0-semantic-release-managed",
48-
"@bitgo/unspents": "0.0.0-semantic-release-managed",
49-
"@bitgo/utxo-core": "0.0.0-semantic-release-managed",
50-
"@bitgo/utxo-lib": "0.0.0-semantic-release-managed",
45+
"@bitgo/blockapis": "^1.11.0",
46+
"@bitgo/sdk-api": "^1.68.3",
47+
"@bitgo/sdk-core": "^36.8.0",
48+
"@bitgo/unspents": "^0.49.0",
49+
"@bitgo/utxo-core": "^1.19.0",
50+
"@bitgo/utxo-lib": "^11.10.0",
5151
"@bitgo/wasm-miniscript": "2.0.0-beta.7",
5252
"@types/lodash": "^4.14.121",
5353
"@types/superagent": "4.1.15",

0 commit comments

Comments
 (0)