mirror of https://github.com/nocodb/nocodb
Pranav C
2 years ago
4 changed files with 121 additions and 1 deletions
@ -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" |
@ -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…
Reference in new issue