Refactor ci-deploy script to automatically retrieve package version from package.json, streamline beta flag handling, and remove obsolete functions for directory cleanup and version updating.
This commit is contained in:
@@ -11,17 +11,17 @@ if ! command -v jq &> /dev/null; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
registryUrl="https://npm.techniker.me"
|
registryUrl="https://npm.techniker.me"
|
||||||
packageVersionToDeploy=""
|
packageVersionToDeploy=$(cat package.json | jq -r '.version')
|
||||||
isBeta="false"
|
isBeta="false"
|
||||||
|
|
||||||
while [[ "${#}" -gt 0 ]]; do
|
while [[ "${#}" -gt 0 ]]; do
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
--beta)
|
--beta)
|
||||||
isBeta="${2}"
|
isBeta="true"
|
||||||
shift 2
|
shift
|
||||||
;;
|
;;
|
||||||
--version)
|
--build)
|
||||||
packageVersionToDeploy="${2}"
|
packageVersionToDeploy="${packageVersionToDeploy}-build.${2}"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@@ -31,40 +31,9 @@ while [[ "${#}" -gt 0 ]]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
function cleanDirectory {
|
|
||||||
local directory="${1}"
|
|
||||||
|
|
||||||
if [ -d "${directory}" ]; then
|
|
||||||
echo "Deleting [${directory}]..."
|
|
||||||
rm -rf "${directory}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function updatePackageJsonVersion {
|
|
||||||
local versionToUpdate="${1}"
|
|
||||||
local packageJsonPath="dist/package.json"
|
|
||||||
|
|
||||||
if [ "${isBeta}" == "true" ]; then
|
|
||||||
echo "Updating package.json version to [${versionToUpdate}] (beta)"
|
|
||||||
|
|
||||||
# Use jq for cross-platform compatibility
|
|
||||||
jq ".version = \"${versionToUpdate}\"" "${packageJsonPath}" > tmp.$$.json && mv tmp.$$.json "${packageJsonPath}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Deploying [${packageVersionToDeploy}]"
|
echo "Deploying [${packageVersionToDeploy}]"
|
||||||
echo "isBeta [${isBeta}]"
|
|
||||||
|
|
||||||
cleanDirectory "dist"
|
echo "Publishing to [${registryUrl}]"
|
||||||
|
|
||||||
bun run ci-build
|
|
||||||
|
|
||||||
# Update version if beta and version provided
|
|
||||||
if [ "${isBeta}" == "true" ] && [ -n "${packageVersionToDeploy}" ]; then
|
|
||||||
updatePackageJsonVersion "${packageVersionToDeploy}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Publishing to ${registryUrl}"
|
|
||||||
cd dist
|
cd dist
|
||||||
|
|
||||||
if [ "${isBeta}" == "true" ]; then
|
if [ "${isBeta}" == "true" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user