From cdb17748cbbc601ae59950143a14e6d080b6a263 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Thu, 21 Apr 2022 21:55:16 +0100 Subject: [PATCH] Update pro install and release scripts --- .github/workflows/budibase_ci.yml | 12 ++------ .github/workflows/release-develop.yml | 32 ++------------------- package.json | 9 ++++-- scripts/pro/install.sh | 20 ++++++++++++++ scripts/pro/release.sh | 40 +++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 43 deletions(-) create mode 100755 scripts/pro/install.sh create mode 100755 scripts/pro/release.sh diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index bbab4d5bb7..ebb6e25452 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -31,16 +31,8 @@ jobs: with: node-version: ${{ matrix.node-version }} - # Add @budibase/pro to filesystem - - name: Checkout pro - uses: actions/checkout@v2 - with: - repository: budibase/budibase-pro - ref: ${{ env.BRANCH }} - path: './pro' - token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - - name: Setup pro - run: mv pro ../budibase-pro && cd ../budibase-pro && yarn setup + - name: Install Pro + run: yarn install:pro - run: yarn - run: yarn bootstrap diff --git a/.github/workflows/release-develop.yml b/.github/workflows/release-develop.yml index 9e0e2b3ed1..2a32395299 100644 --- a/.github/workflows/release-develop.yml +++ b/.github/workflows/release-develop.yml @@ -25,26 +25,13 @@ jobs: runs-on: ubuntu-latest steps: - - name: Extract branch name - shell: bash - run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF_NAME})" - id: extract_branch - - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: 14.x - # Add @budibase/pro to filesystem - - name: Checkout pro - uses: actions/checkout@v2 - with: - repository: budibase/budibase-pro - ref: ${{ steps.extract_branch.outputs.branch }} - path: './pro' - token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - - name: Setup pro - run: mv pro ../budibase-pro && cd ../budibase-pro && yarn setup + - name: Install Pro + run: yarn install:pro - run: yarn - run: yarn bootstrap @@ -69,21 +56,6 @@ jobs: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} >> .npmrc yarn release:develop - - name: Get the latest budibase release version - id: version - run: | - release_version=$(cat lerna.json | jq -r '.version') - echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - - - name: Publish @budibase/pro package to NPM - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - VERSION: ${{ steps.previoustag.outputs.tag }} - run: | - cd ../budibase-pro - echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} >> .npmrc - yarn release:develop $RELEASE_VERSION - - name: Build/release Docker images run: | docker login -u $DOCKER_USER -p $DOCKER_PASSWORD diff --git a/package.json b/package.json index 953c4bcd76..52ca51ec32 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,10 @@ "setup": "node ./hosting/scripts/setup.js && yarn && yarn bootstrap && yarn build && yarn dev", "bootstrap": "lerna link && lerna bootstrap && ./scripts/link-dependencies.sh", "build": "lerna run build", - "release": "lerna publish patch --yes --force-publish", - "release:develop": "lerna publish prerelease --yes --force-publish --dist-tag develop", + "release": "lerna publish patch --yes --force-publish && yarn:release:pro", + "release:develop": "lerna publish prerelease --yes --force-publish --dist-tag develop && yarn:release:pro:develop", + "release:pro": "sh ./scripts/pro/release.sh", + "release:pro:develop": "sh ./scripts/pro/release.sh develop", "restore": "yarn run clean && yarn run bootstrap && yarn run build", "nuke": "yarn run nuke:packages && yarn run nuke:docker", "nuke:packages": "yarn run restore", @@ -71,6 +73,7 @@ "mode:cloud": "yarn env:selfhost:disable && yarn env:multi:enable && yarn env:account:disable", "mode:account": "yarn mode:cloud && yarn env:account:enable", "security:audit": "node scripts/audit.js", - "postinstall": "husky install" + "postinstall": "husky install", + "install:pro": "sh ./scripts/pro/install.sh" } } diff --git a/scripts/pro/install.sh b/scripts/pro/install.sh new file mode 100755 index 0000000000..ea48656b79 --- /dev/null +++ b/scripts/pro/install.sh @@ -0,0 +1,20 @@ +if [[ -z "${CI}" ]]; then + echo 'Cannot run insall.sh unless in CI' + exit 0 +fi + +BRANCH=$1 + +cd ../ +echo "Cloning pro repo..." +git clone git@github.com:Budibase/budibase-pro.git +cd budibase-pro + +echo "Checkout branch $BRANCH" +# Try to checkout the matching pro branch +# If branch does not exist we will continue with default branch 'develop' +git checkout $BRANCH +git pull + +echo "Initializing pro repo..." +yarn setup diff --git a/scripts/pro/release.sh b/scripts/pro/release.sh new file mode 100755 index 0000000000..76aafad5af --- /dev/null +++ b/scripts/pro/release.sh @@ -0,0 +1,40 @@ +if [[ -z "${CI}" ]]; then + echo 'Cannot run release.sh unless in CI' + exit 0 +fi + +# Go to pro package +cd ../budibase-pro + +# Install NPM credentials +echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} >> .npmrc + +# Release pro as same version as budibase +VERSION=$(jq -r .version lerna.json) + +# Determine tag to use +COMMAND=$1 +TAG="" +if [[ $COMMAND == "develop" ]] +then + TAG="develop" +else + TAG="latest" +fi + +echo "Releasing version $VERSION" +echo "Releasing tag $TAG" +lerna publish $VERSION --yes --force-publish --dist-tag $TAG + +cd - + +if [[ $COMMAND == "develop" ]] +then + # Pin pro version for develop container build + echo "Pinning pro version" + cd packages/server + jq '.dependencies."@budibase/pro"="'$VERSION'"' package.json > package.json.tmp && mv package.json.tmp package.json + cd - + cd packages/worker + jq '.dependencies."@budibase/pro"="'$VERSION'"' package.json > package.json.tmp && mv package.json.tmp package.json +fi