From 6f9c7fca6623307187d55000e651ce060b4c8990 Mon Sep 17 00:00:00 2001 From: Guillaume Vincent Date: Thu, 23 Dec 2021 14:18:19 +0100 Subject: [PATCH] Update bump version for web-extension --- .../workflows/lesspass-web-extension-publish.yml | 3 -- bin/bump_version.py | 48 +++++++++++++++++----- packages/lesspass-web-extension/.gitignore | 5 --- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/.github/workflows/lesspass-web-extension-publish.yml b/.github/workflows/lesspass-web-extension-publish.yml index dd17d98..db87f87 100644 --- a/.github/workflows/lesspass-web-extension-publish.yml +++ b/.github/workflows/lesspass-web-extension-publish.yml @@ -14,9 +14,6 @@ jobs: with: node-version: "14" - run: yarn install - - run: yarn workspace lesspass-crypto build - - run: yarn workspace lesspass-pure build - - run: yarn workspace lesspass-web-extension build - run: yarn workspace lesspass-web-extension release continue-on-error: true env: diff --git a/bin/bump_version.py b/bin/bump_version.py index 320afe9..26fbaf5 100644 --- a/bin/bump_version.py +++ b/bin/bump_version.py @@ -23,6 +23,21 @@ def print_packages_version(packages): print(f"|{printable_package_name}|{version.rjust(9, ' ')}|") +def get_package_version(package): + with open(os.path.join(root_path, "packages", package, "package.json")) as f: + package_json = json.load(f) + return package_json["version"] + + +def set_version(file_path, version): + with open(file_path) as f: + package_json = json.load(f) + package_json["version"] = version + + with open(file_path, "w", encoding="utf-8") as f: + json.dump(package_json, f, ensure_ascii=False, indent=2) + + if __name__ == "__main__": if len(sys.argv) != 3: usage() @@ -56,17 +71,28 @@ if __name__ == "__main__": if has_error: usage() - print_packages_version(packages) - package_short_name = packages[package] subprocess.run( - ["yarn", "config", "set", "version-tag-prefix", f"{package_short_name}-v"] - ) - subprocess.run( - ["yarn", "config", "set", "version-git-message", f"{package_short_name}-v%s"] + [ + "yarn", + "workspace", + f"{package}", + "version", + f"--{bump}", + "--no-git-tag-version", + "--no-commit-hooks", + ] ) - subprocess.run(["yarn", "workspace", f"{package}", "version", f"--{bump}"]) - subprocess.run(["yarn", "config", "set", "version-tag-prefix", "v"]) - subprocess.run(["yarn", "config", "set", "version-git-message", "v%s"]) - - print_packages_version(packages) + if package == "lesspass-web-extension": + version = get_package_version(package) + set_version( + os.path.join(root_path, "packages", package, "extension", "manifest.json"), + version, + ) + subprocess.run(["yarn", "workspace", "lesspass-crypto", "build"]) + subprocess.run(["yarn", "workspace", "lesspass-pure", "build"]) + subprocess.run(["yarn", "workspace", "lesspass-web-extension", "build"]) + subprocess.run(["git", "add", "."]) + tag = f"{package_short_name}-v{version}" + subprocess.run(["git", "commit", "-a", "-m", tag]) + subprocess.run(["git", "tag", tag]) diff --git a/packages/lesspass-web-extension/.gitignore b/packages/lesspass-web-extension/.gitignore index 9c15f55..567609b 100644 --- a/packages/lesspass-web-extension/.gitignore +++ b/packages/lesspass-web-extension/.gitignore @@ -1,6 +1 @@ build/ -extension/fonts -extension/img -extension/favicon.ico -extension/index.html -extension/lesspass.min.*