From 324c90404fbb7d61ccce1afdcb540bbd15d186fb Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sun, 21 Aug 2022 23:26:11 +0530 Subject: [PATCH] wip Signed-off-by: Pranav C --- .github/workflows/release-gui-v2.yml | 68 ++++++++++++++++++++++++++++ packages/nc-gui-v2/nuxt.config.ts | 1 + packages/nc-gui-v2/package.json | 4 +- scripts/upgradeNcGui2.js | 49 ++++++++++++++++++++ 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-gui-v2.yml create mode 100644 scripts/upgradeNcGui2.js diff --git a/.github/workflows/release-gui-v2.yml b/.github/workflows/release-gui-v2.yml new file mode 100644 index 0000000000..42d70ab2e3 --- /dev/null +++ b/.github/workflows/release-gui-v2.yml @@ -0,0 +1,68 @@ +name: "Release : NPM packages" + +on: + workflow_dispatch: + inputs: + tag: + description: "Previous Docker image tag" + required: true + +jobs: + release: + runs-on: ubuntu-latest + env: + working-directory: ./packages/nocodb + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{ github.ref }} + - name: NPM Setup and Publish with 16.15.0 + # Setup .npmrc file to publish to npm + uses: actions/setup-node@v2 + with: + node-version: 16.15.0 + registry-url: 'https://registry.npmjs.org' + - run: | + targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} node scripts/bumpNocodbSdkVersion.js && + cd packages/nocodb-sdk && + npm install && npm run build && npm publish && + cd ../.. && + sleep 30 && + targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node scripts/upgradeNocodbSdk.js && + cd packages/nc-gui-v2 && + npm install && + targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} npm run build:copy:jsdeliver && + cd ../.. && + sleep 60 && + targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node scripts/upgradeNcGui.js && cd packages/nocodb && npm install && npm run obfuscate:build:publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Create Pull Request + if: ${{ github.event.inputs.targetEnv == 'PROD' || inputs.targetEnv == 'PROD' }} + id: cpr + uses: peter-evans/create-pull-request@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # commit-message: Update report + # committer: GitHub + # author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + signoff: true + branch: 'release/${{ github.event.inputs.tag || inputs.tag }}' + delete-branch: true + title: 'Release ${{ github.event.inputs.tag || inputs.tag }}' + labels: 'Bot: Automerge' + - name: Check outputs + if: ${{ github.event.inputs.targetEnv == 'PROD' || inputs.targetEnv == 'PROD' }} + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + - name: automerge + if: ${{ github.event.inputs.targetEnv == 'PROD' || inputs.targetEnv == 'PROD' }} + uses: "pascalgn/automerge-action@v0.14.3" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + PULL_REQUEST: "${{ steps.cpr.outputs.pull-request-number }}" + MERGE_LABELS: "Bot: Automerge" diff --git a/packages/nc-gui-v2/nuxt.config.ts b/packages/nc-gui-v2/nuxt.config.ts index d874e19f56..b5f0289488 100644 --- a/packages/nc-gui-v2/nuxt.config.ts +++ b/packages/nc-gui-v2/nuxt.config.ts @@ -11,6 +11,7 @@ import monacoEditorPlugin from 'vite-plugin-monaco-editor' export default defineNuxtConfig({ modules: ['@vueuse/nuxt', 'nuxt-windicss', '@nuxt/image-edge'], + ssr: false, app: { baseURL: '/dashboard/', diff --git a/packages/nc-gui-v2/package.json b/packages/nc-gui-v2/package.json index cf1b4f1729..9759a385cb 100644 --- a/packages/nc-gui-v2/package.json +++ b/packages/nc-gui-v2/package.json @@ -8,7 +8,9 @@ "lint": "eslint --ext \".js,.jsx,.ts,.tsx,.vue\" --fix --ignore-path .gitignore .", "test": "vitest -c test/vite.config.ts", "test:ui": "vitest -c test/vite.config.ts --ui", - "coverage": "vitest -c test/vite.config.ts run --coverage" + "coverage": "vitest -c test/vite.config.ts run --coverage", + "build:copy:publish": "npm run generate; rm -rf ../nc-lib-gui-2/lib/dist/; rsync -rvzh ./dist/ ../nc-lib-gui-2/lib/dist/ ; npm publish ../nc-lib-gui-2" + }, "dependencies": { "@ckpack/vue-color": "^1.2.0", diff --git a/scripts/upgradeNcGui2.js b/scripts/upgradeNcGui2.js new file mode 100644 index 0000000000..07dc44b9ce --- /dev/null +++ b/scripts/upgradeNcGui2.js @@ -0,0 +1,49 @@ +const fs = require('fs') +const path = require('path') + +const execSync = require('child_process').execSync; + +// extract latest version from package.json +const ncLibPackage = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'packages', 'nc-lib-gui-2', 'package.json'))) + + +const replacePackageName = (filePath) => { + return new Promise((resolve, reject) => { + return fs.readFile(filePath, 'utf8', function (err, data) { + if (err) return reject(err) + var result = data.replace(/nc-lib-gui-2/g, ncLibPackage.name); + return fs.writeFile(filePath, result, 'utf8', function (err) { + if (err) return reject(err) + return resolve() + }); + }); + }) +} + +const bumbVersionAndSave = () => { + // upgrade nc-lib-gui-2 version in nocodb + execSync(`cd packages/nocodb && npm install --save --save-exact ${ncLibPackage.name}@${ncLibPackage.version}`, {}); + const nocodbPackageFilePath = path.join(__dirname, '..', 'packages', 'nocodb', 'package.json') + const nocoLibPackage = JSON.parse(fs.readFileSync(nocodbPackageFilePath)) + if (process.env.targetEnv === 'DEV') { + nocoLibPackage.name = `${nocoLibPackage.name}-daily` + } + nocoLibPackage.version = ncLibPackage.version + fs.writeFileSync(nocodbPackageFilePath, JSON.stringify(nocoLibPackage, null, 2)); +} + +if (process.env.targetEnv === 'DEV') { + // replace nc-lib-gui-2 by nc-lib-gui-2-daily if it is nightly build / pr release + const filePaths = [ + path.join(__dirname, '..', 'packages', 'nocodb', 'Dockerfile'), + path.join(__dirname, '..', 'packages', 'nocodb', 'litestream', 'Dockerfile'), + path.join(__dirname, '..', 'packages', 'nocodb', 'package.json'), + path.join(__dirname, '..', 'packages', 'nocodb', 'README.md'), + path.join(__dirname, '..', 'packages', 'nocodb', 'src', 'lib', 'Noco.ts'), + ] + Promise.all(filePaths.map(filePath => { return replacePackageName(filePath) })).then(() => { + bumbVersionAndSave(); + }) +} else { + bumbVersionAndSave(); +}