From 2f5fb12fbea07ab793c9a07cb18e9add289436e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E6=B5=A9?= <303527871@qq.com> Date: Tue, 26 Nov 2024 01:14:07 +0800 Subject: [PATCH] chore: release 0.1.1 --- package.json | 2 +- publish.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 publish.sh diff --git a/package.json b/package.json index 1b34398..48d0c0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-maui", - "version": "0.1.0", + "version": "0.1.1", "description": "React Native UI Library", "main": "src/index", "scripts": { diff --git a/publish.sh b/publish.sh new file mode 100644 index 0000000..224d16a --- /dev/null +++ b/publish.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# 检查是否以root用户运行 +if [ "$(id -u)" -eq 0 ]; then + echo "This script should not be run as root" + exit 1 +fi + +# 切换到npm官方源 +echo "Switching npm registry to https://registry.npmjs.org/" +npm config set registry https://registry.npmjs.org/ + +# 验证是否切换成功 +current_registry=$(npm config get registry) +if [ "$current_registry" != "https://registry.npmjs.org/" ]; then + echo "Failed to switch npm registry to https://registry.npmjs.org/" + exit 1 +fi + +echo "npm registry has been switched to https://registry.npmjs.org/" + +# 执行npm publish命令 +echo "Executing npm publish..." +npm publish +publish_status=$? + +# 检查publish命令是否成功 +if [ $publish_status -ne 0 ]; then + echo "npm publish failed" + # 切换回npmmirror源之前先退出脚本,避免进一步操作 + exit $publish_status +fi + +echo "npm publish succeeded" + +# 切换到npmmirror源 +echo "Switching npm registry back to https://registry.npmmirror.com/" +npm config set registry https://registry.npmmirror.com/ + +# 验证是否切换成功 +current_registry=$(npm config get registry) +if [ "$current_registry" != "https://registry.npmmirror.com/" ]; then + echo "Failed to switch npm registry to https://registry.npmmirror.com/" + exit 1 +fi + +echo "npm registry has been switched back to https://registry.npmmirror.com/" + +echo "Script execution completed successfully" +exit 0 \ No newline at end of file