budibase/scripts/pro/release.sh

101 lines
2.8 KiB
Bash
Raw Normal View History

2022-04-22 11:16:09 +02:00
#!/bin/bash
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 -
#############################################
# 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
#############################################
2022-05-24 13:18:39 +02:00
# POST-PUBLISH - PRO #
2022-04-25 13:19:36 +02:00
#############################################
# Revert build changes on packages/pro/package.json
2022-04-22 12:37:55 +02:00
cd packages/pro
2022-04-22 12:01:27 +02:00
jq '.main = "src/index.ts" | .types = "src/index.ts"' 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
2022-04-22 13:10:39 +02:00
cd -
2022-04-25 13:19:36 +02:00
# Commit and push changes
2022-04-22 12:37:55 +02:00
git add packages/pro/package.json
2022-04-25 13:19:36 +02:00
git commit -m "Prep next development iteration"
2022-04-22 12:01:27 +02:00
git push
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
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