Browse Source

wip

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3273/head
Pranav C 2 years ago
parent
commit
324c90404f
  1. 68
      .github/workflows/release-gui-v2.yml
  2. 1
      packages/nc-gui-v2/nuxt.config.ts
  3. 4
      packages/nc-gui-v2/package.json
  4. 49
      scripts/upgradeNcGui2.js

68
.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 <noreply@github.com>
# 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"

1
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/',

4
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",

49
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();
}
Loading…
Cancel
Save