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
|
||||
|
||||
registryUrl="https://npm.techniker.me"
|
||||
packageVersionToDeploy=""
|
||||
packageVersionToDeploy=$(cat package.json | jq -r '.version')
|
||||
isBeta="false"
|
||||
|
||||
while [[ "${#}" -gt 0 ]]; do
|
||||
case "${1}" in
|
||||
--beta)
|
||||
isBeta="${2}"
|
||||
shift 2
|
||||
isBeta="true"
|
||||
shift
|
||||
;;
|
||||
--version)
|
||||
packageVersionToDeploy="${2}"
|
||||
--build)
|
||||
packageVersionToDeploy="${packageVersionToDeploy}-build.${2}"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
@@ -31,40 +31,9 @@ while [[ "${#}" -gt 0 ]]; do
|
||||
esac
|
||||
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 "isBeta [${isBeta}]"
|
||||
|
||||
cleanDirectory "dist"
|
||||
|
||||
bun run ci-build
|
||||
|
||||
# Update version if beta and version provided
|
||||
if [ "${isBeta}" == "true" ] && [ -n "${packageVersionToDeploy}" ]; then
|
||||
updatePackageJsonVersion "${packageVersionToDeploy}"
|
||||
fi
|
||||
|
||||
echo "Publishing to ${registryUrl}"
|
||||
echo "Publishing to [${registryUrl}]"
|
||||
cd dist
|
||||
|
||||
if [ "${isBeta}" == "true" ]; then
|
||||
|
||||
Reference in New Issue
Block a user