Skip to content

Commit

Permalink
Prepare all necessary JS artifacts for build task (#25842)
Browse files Browse the repository at this point in the history
Co-authored-by: Lykoi18 <[email protected]>
  • Loading branch information
alexslavr and Lykoi18 authored Oct 24, 2023
1 parent 3397210 commit 309ab79
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 66 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/update_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Update version in all workspaces

on:
workflow_dispatch:
inputs:
branch_name:
type: string
description: XX_X Branch name (23_2+)
required: true
version:
type: string
description: XX.X.X Set exact version
required: true

jobs:
update_version:
name: Update version and create PR
runs-on: ubuntu-latest

steps:
- name: Get sources
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch_name }}

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.16.1'

- name: Setup git config
run: |
git config --global user.email "[email protected]"
git config --global user.name "DX Robot"
- name: Install packages in devextreme repo
run: npm install --no-audit --no-fund

- name: Bump version
run: npm run all:update-version -- ${{ inputs.version }}

- name: Commit changes and make PR
env:
GITHUB_TOKEN: ${{ secrets.DX_ROBOT_PAT }}
branch_name: 'robot/update-version-${{ inputs.version }}'
run: |
git checkout -b $branch_name
git add . -N
git commit -a -m "Bump devextreme version"
git push --set-upstream origin $branch_name --force
gh pr create --base ${{ inputs.branch_name }} --title "Bump devextreme version (${{ inputs.version }})" --body "Bump devextreme version" --reviewer DevExpress/devextreme-devops
73 changes: 73 additions & 0 deletions build/build-all.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import sh from 'shelljs';
import path from 'node:path';

const MONOREPO_ROOT = path.join(__dirname, '..');
const INTERNAL_TOOLS_ARTIFACTS = path.join(MONOREPO_ROOT, 'artifacts', 'internal-tools');

const OUTPUT_DIR = path.join(MONOREPO_ROOT, 'artifacts');
const NPM_OUTPUT_DIR = path.join(OUTPUT_DIR, 'npm');

sh.mkdir('-p', NPM_OUTPUT_DIR);

const { 'devextreme-main': devextremeVersion, devextreme: devextremeNpmVersion } = JSON.parse(sh.exec('npm pkg get version -ws --json').stdout);
const MAJOR_VERSION = devextremeVersion.split('.').slice(0, 2).join('_');

// Prepare metadata
sh.cd(MONOREPO_ROOT);
sh.exec('npm run tools:discover-declarations');
sh.exec(`npm run tools -- make-aspnet-metadata --version ${MAJOR_VERSION}`);

// Inject descriptions
const DOCUMENTATION_TEMP_DIR = path.join(OUTPUT_DIR, 'doc_tmp');
sh.exec(`git clone -b ${MAJOR_VERSION} --depth 1 --config core.longpaths=true https://github.com/DevExpress/devextreme-documentation.git ${DOCUMENTATION_TEMP_DIR}`);

sh.pushd(DOCUMENTATION_TEMP_DIR);
sh.exec('npm i');
sh.exec(`npm run update-topics -- --artifacts ${INTERNAL_TOOLS_ARTIFACTS}`);
sh.popd();

sh.rm('-rf', DOCUMENTATION_TEMP_DIR);

sh.exec('npm run devextreme:inject-descriptions');

sh.exec('npm run build-dist -w devextreme-main');

// Copy artifacts for DXBuild (Installation)
sh.pushd(path.join(MONOREPO_ROOT, 'packages/devextreme/artifacts'));
sh.cp('-r', 'ts', OUTPUT_DIR);
sh.cp('-r', 'js', OUTPUT_DIR);
sh.cp('-r', 'css', OUTPUT_DIR);
sh.popd();

// TODO: maybe we should add bootstrap to vendors
const BOOTSTRAP_DIR = path.join(MONOREPO_ROOT, 'node_modules', 'bootstrap', 'dist');
sh.cp([path.join(BOOTSTRAP_DIR, 'js', 'bootstrap.js'), path.join(BOOTSTRAP_DIR, 'js', 'bootstrap.min.js')], path.join(OUTPUT_DIR, 'js'));
sh.cp([path.join(BOOTSTRAP_DIR, 'css', 'bootstrap.css'), path.join(BOOTSTRAP_DIR, 'js', 'bootstrap.min.css')], path.join(OUTPUT_DIR, 'css'));

// Update versions for non-semver builds (daily, alpha and beta)
if (devextremeVersion !== devextremeNpmVersion) {
sh.exec(`npm run all:update-version -- ${devextremeNpmVersion}`);
}

const DEVEXTREME_NPM_DIR = path.join(MONOREPO_ROOT, 'packages/devextreme/artifacts/npm');

sh.pushd(path.join(DEVEXTREME_NPM_DIR, 'devextreme'))
sh.exec('npm pack');
sh.cp('*.tgz', NPM_OUTPUT_DIR);
sh.popd();

sh.pushd(path.join(DEVEXTREME_NPM_DIR, 'devextreme-dist'))
sh.exec('npm pack');
sh.cp('*.tgz', NPM_OUTPUT_DIR);
sh.popd();

sh.pushd(path.join(MONOREPO_ROOT, 'packages', 'devextreme-themebuilder'))
sh.exec('npm run build && npm run pack');
sh.cp('dist/*.tgz', NPM_OUTPUT_DIR);
sh.popd();

sh.exec('npm run pack --ws --if-present');

sh.cp(path.join(MONOREPO_ROOT, 'packages', 'devextreme-angular', 'npm', 'dist', '*.tgz'), NPM_OUTPUT_DIR);
sh.cp(path.join(MONOREPO_ROOT, 'packages', 'devextreme-react', 'npm', '*.tgz'), NPM_OUTPUT_DIR);
sh.cp(path.join(MONOREPO_ROOT, 'packages', 'devextreme-vue', 'npm', '*.tgz'), NPM_OUTPUT_DIR);
54 changes: 0 additions & 54 deletions build/pack-all.ts

This file was deleted.

19 changes: 19 additions & 0 deletions build/update-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sh from 'shelljs';
import path from 'node:path';

const version = process.argv[2];

if (version == null) {
console.error(`Usage: 'npm run all:update-version -- $version' (XX.X.X)`);
process.exit(1);
}

const MONOREPO_ROOT = path.join(__dirname, '..');
const packagesPath = path.join(MONOREPO_ROOT, 'packages', '**', 'package.json');
const playgroundsPath = path.join(MONOREPO_ROOT, 'playgrounds', '**', 'package.json');

sh.exec(`npm version ${version} -ws --include-workspace-root --git-tag-version=false --workspaces-update=false`);

sh.sed('-i', /"devextreme(-angular|-react|-vue)?": ".*"/, `"devextreme$1": "~${version}"`, [packagesPath, playgroundsPath]);

sh.exec('npm i');
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"regenerate-all": "nx run-many -t regenerate",
"lint-staged": "lint-staged",
"prepare": "husky install",
"all:pack": "ts-node build/pack-all.ts"
"all:update-version": "ts-node build/update-version.ts",
"all:build": "ts-node build/build-all.ts"
},
"nx": {},
"private": true,
Expand Down
1 change: 0 additions & 1 deletion packages/devextreme-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"codelyzer": "6.0.2",
"core-js": "^2.6.12",
"del": "^2.2.2",
"devextreme": "~23.2.0",
"gulp": "^4.0.2",
"gulp-header": "^1.8.12",
"gulp-replace": "^0.6.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme-themebuilder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "devextreme-themebuilder",
"version": "0.0.1",
"version": "23.2.0",
"description": "DevExtreme ThemeBuilder",
"keywords": [
"devextreme",
Expand Down
15 changes: 9 additions & 6 deletions playgrounds/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"name": "devextreme-angular-playground",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "cross-env NODE_OPTIONS=--openssl-legacy-provider ng serve --open -c dev",
"build": "echo empty"
},
"description": "DevExtreme Angular UI and Visualization Components",
"private": true,
"version": "23.2.0",
"author": "Developer Express Inc.",
"license": "MIT",
"dependencies": {
"@angular/animations": "~12.2.17",
"@angular/common": "~12.2.17",
Expand All @@ -30,5 +28,10 @@
"@angular/language-service": "12.2.17",
"@types/node": "8.10.66",
"ts-node": "7.0.1"
},
"scripts": {
"ng": "ng",
"start": "cross-env NODE_OPTIONS=--openssl-legacy-provider ng serve --open -c dev",
"build": "echo empty"
}
}

0 comments on commit 309ab79

Please sign in to comment.