Skip to content

Commit

Permalink
Merge branch 'master' into chore/deprecate-named-pubsub
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 committed Nov 3, 2023
2 parents ebbbf32 + 34a25c2 commit cc98b9c
Show file tree
Hide file tree
Showing 25 changed files with 325 additions and 64 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@
}
]
}
},
{
"files": ["**/ci/*.js"],
"rules": {
"no-undef": "off"
}
}
]
}
27 changes: 25 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,37 @@ jobs:
with:
nim_wakunode_image: wakuorg/go-waku:latest
test_type: go-waku-master
debug: js-waku*
debug: waku*

node_with_nwaku_master:
uses: ./.github/workflows/test-node.yml
with:
nim_wakunode_image: wakuorg/nwaku:deploy-wakuv2-test
test_type: nwaku-master
debug: js-waku*
debug: waku*

pre-release:
name: pre-release
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [check, proto, browser, node]
steps:
- uses: actions/checkout@v3
with:
repository: waku-org/js-waku

- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_JS }}
registry-url: "https://registry.npmjs.org"

- run: npm install

- run: npm run build

- run: npm run publish -- --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_JS_WAKU_PUBLISH }}

maybe-release:
name: release
Expand Down
20 changes: 10 additions & 10 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"packages/utils": "0.0.12",
"packages/utils": "0.0.13",
"packages/proto": "0.0.5",
"packages/interfaces": "0.0.19",
"packages/message-hash": "0.1.8",
"packages/enr": "0.0.18",
"packages/peer-exchange": "0.0.17",
"packages/core": "0.0.24",
"packages/dns-discovery": "0.0.18",
"packages/message-encryption": "0.0.22",
"packages/relay": "0.0.7",
"packages/sdk": "0.0.20"
"packages/interfaces": "0.0.20",
"packages/message-hash": "0.1.9",
"packages/enr": "0.0.19",
"packages/peer-exchange": "0.0.18",
"packages/core": "0.0.25",
"packages/dns-discovery": "0.0.19",
"packages/message-encryption": "0.0.23",
"packages/relay": "0.0.8",
"packages/sdk": "0.0.21"
}
101 changes: 87 additions & 14 deletions ci/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ const PACKAGE_JSON = "package.json";
// hack to get __dirname
const DIR = path.dirname(fileURLToPath(import.meta.url));

const NEXT_TAG = "next";
const LATEST_TAG = "latest";
const CURRENT_TAG = readPublishTag();

const exec = promisify(cp.exec);
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);

run()
.then(() => {
Expand All @@ -23,26 +28,31 @@ async function run() {
const rootPackage = await readJSON(path.resolve(DIR, "../", PACKAGE_JSON));
const workspacePaths = rootPackage.workspaces;

const workspaces = await Promise.all(
workspacePaths.map(async (workspacePath) => {
const workspaceInfo = await readWorkspace(workspacePath);
const allowPublishing = await shouldBePublished(workspaceInfo);
if (CURRENT_TAG === NEXT_TAG) {
await makeReleaseCandidate();
}

if (allowPublishing) {
return workspaceInfo;
}
const workspaces = await Promise.all(workspacePaths.map(readWorkspace));

return;
})
);
if (CURRENT_TAG === NEXT_TAG) {
await upgradeWakuDependencies(workspaces);
}

await Promise.all(
workspaces
.filter((v) => !!v)
.filter(async (info) => {
const allowPublishing = await shouldBePublished(info);

if (allowPublishing) {
return true;
}

return false;
})
.map(async (info) => {
try {
await exec(
`npm publish --workspace ${info.workspace} --tag latest --access public`
`npm publish --workspace ${info.workspace} --tag ${CURRENT_TAG} --access public`
);
console.info(
`Successfully published ${info.workspace} with version ${info.version}.`
Expand All @@ -61,6 +71,11 @@ async function readJSON(path) {
return JSON.parse(rawJSON);
}

async function writeWorkspace(packagePath, text) {
const resolvedPath = path.resolve(DIR, "../", packagePath, PACKAGE_JSON);
await writeFile(resolvedPath, text);
}

async function readWorkspace(packagePath) {
const json = await readJSON(
path.resolve(DIR, "../", packagePath, PACKAGE_JSON)
Expand All @@ -70,13 +85,14 @@ async function readWorkspace(packagePath) {
name: json.name,
private: !!json.private,
version: json.version,
workspace: packagePath
workspace: packagePath,
rawPackageJson: json
};
}

async function shouldBePublished(info) {
if (info.private) {
console.info(`Skipping ${info.path} because it is private.`);
console.info(`Skipping ${info.name} because it is private.`);
return false;
}

Expand All @@ -99,3 +115,60 @@ async function shouldBePublished(info) {
);
}
}

async function makeReleaseCandidate() {
try {
console.info("Marking workspace versions as release candidates.");
await exec(
`npm version prerelease --preid $(git rev-parse --short HEAD) --workspaces true`
);
} catch (e) {
console.error("Failed to mark release candidate versions.", e);
}
}

function readPublishTag() {
const args = process.argv.slice(2);
const tagIndex = args.indexOf("--tag");

if (tagIndex !== -1 && args[tagIndex + 1]) {
return args[tagIndex + 1];
}

return LATEST_TAG;
}

async function upgradeWakuDependencies(workspaces) {
console.log("Upgrading Waku dependencies in workspaces.");
const map = workspaces.reduce((acc, item) => {
if (!item.private) {
acc[item.name] = item;
}
return acc;
}, {});
const packageNames = Object.keys(map);
workspaces.forEach(async (info) => {
if (info.private) {
return;
}
["dependencies", "devDependencies", "peerDependencies"].forEach((type) => {
const deps = info.rawPackageJson[type];
if (!deps) {
return;
}
packageNames.forEach((name) => {
if (deps[name]) {
deps[name] = map[name].version;
}
});
});
try {
await writeWorkspace(info.workspace, JSON.stringify(info.rawPackageJson));
} catch (error) {
console.error(
`Failed to update package.json for ${info.name} with: `,
error
);
}
});
}
25 changes: 25 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ All notable changes to this project will be documented in this file.
The file is maintained by [Release Please](https://github.com/googleapis/release-please) based on [Conventional Commits](https://www.conventionalcommits.org) specification,
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.25](https://github.com/waku-org/js-waku/compare/core-v0.0.24...core-v0.0.25) (2023-11-01)


### Features

* Fail early when trying to send empty payload ([#1642](https://github.com/waku-org/js-waku/issues/1642)) ([6bad4ea](https://github.com/waku-org/js-waku/commit/6bad4ea7d1dee79c296c550390da57ffa824e2cf))
* Logger with log levels ([#1672](https://github.com/waku-org/js-waku/issues/1672)) ([0f7d63e](https://github.com/waku-org/js-waku/commit/0f7d63ef93716223dc8fea7e8cb09e12e267b386))


### Bug Fixes

* Don't dial discovered peers if have already been attempted dial ([#1657](https://github.com/waku-org/js-waku/issues/1657)) ([1892f50](https://github.com/waku-org/js-waku/commit/1892f5093da540530d7ee5640178ebaa46cf769f))
* Filter subscription with `pubsubTopic1` and decoder with `pubsubTopic2` ([#1675](https://github.com/waku-org/js-waku/issues/1675)) ([491366b](https://github.com/waku-org/js-waku/commit/491366bd4f96d5b72f83ca47dea5a93389ec5a27))
* Handle all empty responses in filter ([#1688](https://github.com/waku-org/js-waku/issues/1688)) ([b3864f8](https://github.com/waku-org/js-waku/commit/b3864f8772b072e804954c1096510554ea578424))
* Measure total message size ([#1643](https://github.com/waku-org/js-waku/issues/1643)) ([b7dc3d7](https://github.com/waku-org/js-waku/commit/b7dc3d7576e9444a5acbb036812c05cfccb25815))


### Dependencies

* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from ^0.0.18 to ^0.0.19
* @waku/interfaces bumped from 0.0.19 to 0.0.20
* @waku/utils bumped from 0.0.12 to 0.0.13

## [0.0.24](https://github.com/waku-org/js-waku/compare/core-v0.0.23...core-v0.0.24) (2023-10-16)


Expand Down
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waku/core",
"version": "0.0.24",
"version": "0.0.25",
"description": "TypeScript implementation of the Waku v2 protocol",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
Expand Down Expand Up @@ -73,10 +73,10 @@
},
"dependencies": {
"@noble/hashes": "^1.3.2",
"@waku/enr": "^0.0.18",
"@waku/interfaces": "0.0.19",
"@waku/enr": "^0.0.19",
"@waku/interfaces": "0.0.20",
"@waku/proto": "0.0.5",
"@waku/utils": "0.0.12",
"@waku/utils": "0.0.13",
"debug": "^4.3.4",
"it-all": "^3.0.3",
"it-length-prefixed": "^9.0.1",
Expand Down
17 changes: 17 additions & 0 deletions packages/dns-discovery/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* devDependencies
* @waku/interfaces bumped from 0.0.13 to 0.0.14

## [0.0.19](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.18...dns-discovery-v0.0.19) (2023-11-01)


### Features

* Logger with log levels ([#1672](https://github.com/waku-org/js-waku/issues/1672)) ([0f7d63e](https://github.com/waku-org/js-waku/commit/0f7d63ef93716223dc8fea7e8cb09e12e267b386))


### Dependencies

* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.18 to 0.0.19
* @waku/utils bumped from 0.0.12 to 0.0.13
* devDependencies
* @waku/interfaces bumped from 0.0.19 to 0.0.20

## [0.0.18](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.17...dns-discovery-v0.0.18) (2023-10-16)


Expand Down
8 changes: 4 additions & 4 deletions packages/dns-discovery/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waku/dns-discovery",
"version": "0.0.18",
"version": "0.0.19",
"description": "DNS Peer Discovery (EIP-1459)",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
Expand Down Expand Up @@ -51,8 +51,8 @@
"node": ">=18"
},
"dependencies": {
"@waku/enr": "0.0.18",
"@waku/utils": "0.0.12",
"@waku/enr": "0.0.19",
"@waku/utils": "0.0.13",
"debug": "^4.3.4",
"dns-query": "^0.11.2",
"hi-base32": "^0.5.1",
Expand All @@ -67,7 +67,7 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/chai": "^4.3.5",
"@waku/build-utils": "*",
"@waku/interfaces": "0.0.19",
"@waku/interfaces": "0.0.20",
"chai": "^4.3.7",
"cspell": "^7.3.2",
"mocha": "^10.2.0",
Expand Down
16 changes: 16 additions & 0 deletions packages/enr/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* devDependencies
* @waku/interfaces bumped from 0.0.16 to 0.0.17

## [0.0.19](https://github.com/waku-org/js-waku/compare/enr-v0.0.18...enr-v0.0.19) (2023-11-01)


### Features

* Logger with log levels ([#1672](https://github.com/waku-org/js-waku/issues/1672)) ([0f7d63e](https://github.com/waku-org/js-waku/commit/0f7d63ef93716223dc8fea7e8cb09e12e267b386))


### Dependencies

* The following workspace dependencies were updated
* dependencies
* @waku/utils bumped from 0.0.12 to 0.0.13
* devDependencies
* @waku/interfaces bumped from 0.0.19 to 0.0.20

## [0.0.18](https://github.com/waku-org/js-waku/compare/enr-v0.0.17...enr-v0.0.18) (2023-10-16)


Expand Down
6 changes: 3 additions & 3 deletions packages/enr/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waku/enr",
"version": "0.0.18",
"version": "0.0.19",
"description": "ENR (EIP-778) for Waku",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
Expand Down Expand Up @@ -56,7 +56,7 @@
"@libp2p/peer-id": "^3.0.3",
"@multiformats/multiaddr": "^12.0.0",
"@noble/secp256k1": "^1.7.1",
"@waku/utils": "0.0.12",
"@waku/utils": "0.0.13",
"debug": "^4.3.4",
"js-sha3": "^0.9.2"
},
Expand All @@ -68,7 +68,7 @@
"@types/chai": "^4.3.5",
"@types/mocha": "^10.0.1",
"@waku/build-utils": "*",
"@waku/interfaces": "0.0.19",
"@waku/interfaces": "0.0.20",
"chai": "^4.3.7",
"cspell": "^7.3.2",
"fast-check": "^3.13.1",
Expand Down
7 changes: 7 additions & 0 deletions packages/interfaces/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The file is maintained by [Release Please](https://github.com/googleapis/release-please) based on [Conventional Commits](https://www.conventionalcommits.org) specification,
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.20](https://github.com/waku-org/js-waku/compare/interfaces-v0.0.19...interfaces-v0.0.20) (2023-11-01)


### Features

* Fail early when trying to send empty payload ([#1642](https://github.com/waku-org/js-waku/issues/1642)) ([6bad4ea](https://github.com/waku-org/js-waku/commit/6bad4ea7d1dee79c296c550390da57ffa824e2cf))

## [0.0.19](https://github.com/waku-org/js-waku/compare/interfaces-v0.0.18...interfaces-v0.0.19) (2023-10-16)


Expand Down
Loading

0 comments on commit cc98b9c

Please sign in to comment.