From 321b72bd79c50354a5d0dd11928925298cb9e551 Mon Sep 17 00:00:00 2001 From: Alberto Ricart Date: Tue, 14 Nov 2023 13:55:36 -0600 Subject: [PATCH] [CI] npm bundle check --- bin/check-bundle-version.ts | 32 ++++++++++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 bin/check-bundle-version.ts diff --git a/bin/check-bundle-version.ts b/bin/check-bundle-version.ts new file mode 100644 index 0000000..6464549 --- /dev/null +++ b/bin/check-bundle-version.ts @@ -0,0 +1,32 @@ +/* + * Copyright 2021 The NATS Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +let tag = Deno.env.get("RELEASE_VERSION"); +const pkg = await Deno.readTextFile("package.json"); +const m = JSON.parse(pkg); +if(tag) { + if(tag.startsWith("v")) { + tag = tag.substring(1); + } + if(m.version !== tag) { + console.error(`[ERROR] expected RELEASE_VERSION and package versions to match ${tag} !== ${m.version}`); + Deno.exit(1); + } + console.log(`[OK] RELEASE_VERSION and package versions match ${tag}`); +} else { + console.log(`[SKIP] tag check`); +} + + +Deno.exit(0); diff --git a/package.json b/package.json index dd2c0f6..4bbb863 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "test": "npm run prepare && ava --verbose && deno test -A --unstable test/", "doc": "npm run clean && rm -Rf docs && npm run stage && node_modules/.bin/typedoc --out docs/ && touch ./docs/.nojekyll", "bump-qualifier": "npm version prerelease --no-commit-hooks --no-git-tag-version", - "bump-release": "npm version patch --no-commit-hooks --no-git-tag-version" + "bump-release": "npm version patch --no-commit-hooks --no-git-tag-version", + "check-package": "deno run --allow-all bin/check-bundle-version.ts" }, "engines": { "node": ">=10.0.0"