budibase/scripts/pro/release.sh

96 lines
2.5 KiB
Bash
Raw Normal View History

2022-04-22 11:16:09 +02:00
#!/bin/bash
# Fail when any command fails
set -e
2022-04-22 11:21:47 +02:00
if [[ -z "${CI}" ]]; then
echo 'Cannot run release.sh unless in CI'
exit 0
fi
2022-04-21 22:55:16 +02:00
2022-04-25 13:19:36 +02:00
#############################################
# SETUP #
#############################################
# Release pro with same version as budibase
2022-04-22 10:43:51 +02:00
VERSION=$(jq -r .version lerna.json)
2022-04-22 11:16:09 +02:00
echo "Version: $VERSION"
COMMAND=$1
echo "Command: $COMMAND"
2022-04-22 10:43:51 +02:00
2022-04-21 22:55:16 +02:00
# Determine tag to use
TAG=""
2022-04-22 11:40:17 +02:00
if [[ $COMMAND == "develop" ]]; then
2022-04-21 22:55:16 +02:00
TAG="develop"
else
TAG="latest"
fi
echo "Releasing version $VERSION"
echo "Releasing tag $TAG"
2022-04-25 13:19:36 +02:00
#############################################
# PRE-PUBLISH #
#############################################
# Go to pro repo root
cd ../budibase-pro
# Install NPM credentials
echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} >> .npmrc
# Sync budibase dependency versions in packages/pro/package.json
2022-04-25 13:19:36 +02:00
# Ensures pro does not use out of date dependency
cd packages/pro
jq '.dependencies."@budibase/backend-core"="'$VERSION'"' package.json > package.json.tmp && mv package.json.tmp package.json
jq '.dependencies."@budibase/types"="'$VERSION'"' package.json > package.json.tmp && mv package.json.tmp package.json
2022-04-25 13:19:36 +02:00
# Go back to pro repo root
cd -
2022-07-27 19:42:06 +02:00
# Update lockfile with new dependency versions
2022-07-27 20:23:17 +02:00
yarn clean -y && yarn bootstrap
# Commit and push
2022-07-27 19:42:06 +02:00
git add packages/pro/yarn.lock
2022-07-27 20:23:17 +02:00
git commit -m "Update dependency versions to $VERSION"
git push
2022-07-27 19:42:06 +02:00
2022-04-25 13:19:36 +02:00
#############################################
# PUBLISH #
#############################################
2022-04-22 11:21:47 +02:00
lerna publish $VERSION --yes --force-publish --dist-tag $TAG
2022-04-21 22:55:16 +02:00
2022-04-25 13:19:36 +02:00
#############################################
# POST-PUBLISH - BUDIBASE #
#############################################
# Go to budibase repo root
2022-04-22 13:10:39 +02:00
cd ../budibase
2022-04-21 22:55:16 +02:00
2022-04-25 13:19:36 +02:00
# Update pro version in packages/server/package.json
cd packages/server
jq '.dependencies."@budibase/pro"="'$VERSION'"' package.json > package.json.tmp && mv package.json.tmp package.json
# Go back to budibase repo root
cd -
# Update pro version in packages/worker/package.json
cd packages/worker
jq '.dependencies."@budibase/pro"="'$VERSION'"' package.json > package.json.tmp && mv package.json.tmp package.json
2022-04-25 13:58:34 +02:00
# Go back to budibase repo root
cd -
# Update lockfile with new pro version
2022-07-27 20:23:17 +02:00
yarn clean -y && yarn bootstrap
2022-04-25 13:19:36 +02:00
# Commit and push changes
2022-04-25 13:58:34 +02:00
git add packages/server/package.json
git add packages/server/yarn.lock
2022-04-25 13:58:34 +02:00
git add packages/worker/package.json
git add packages/worker/yarn.lock
2022-04-25 13:19:36 +02:00
git commit -m "Update pro version to $VERSION"
git push