From 415ebd8f4a4c0d911cd9b14152531bf2c8891a9a Mon Sep 17 00:00:00 2001 From: xile611 Date: Fri, 14 Jun 2024 11:56:41 +0800 Subject: [PATCH 1/2] chore: update info pf harmony after release --- .github/workflows/release.yml | 5 ++++- common/scripts/set-changelog-of-harmony.js | 21 +++++++++++++++++++++ common/scripts/set-prerelease-version.js | 13 ++++++++++++- packages/vchart/bundler.config.js | 3 ++- 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 common/scripts/set-changelog-of-harmony.js diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 97ebad3d02..190fbfe069 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -109,7 +109,7 @@ jobs: - name: Commit & Push changes run: | git add . - git commit -m 'build: prelease version ${{ steps.package-version.outputs.current_version }}' -n + git commit -m 'build: release version ${{ steps.package-version.outputs.current_version }}' -n git push origin ${{ github.ref_name }} - name: Collect changelog of rush @@ -118,6 +118,9 @@ jobs: with: version: ${{ steps.package-version.outputs.current_version }} + - name: Update changelog of harmony + run: node common/scripts/set-changelog-of-harmony.js ${{ steps.package-version.outputs.current_version }} ${{ steps.changelog.outputs.markdown }} + - name: Create Release for Tag id: release_tag uses: ncipollo/release-action@v1.12.0 diff --git a/common/scripts/set-changelog-of-harmony.js b/common/scripts/set-changelog-of-harmony.js new file mode 100644 index 0000000000..2af2a7d40c --- /dev/null +++ b/common/scripts/set-changelog-of-harmony.js @@ -0,0 +1,21 @@ +const fs = require('fs') +const path = require('path') + +function setChangelogOfHarmny() { + const nextVersion = process.argv.slice(2)[0]; + const changelogContent = process.argv.slice(2)[1]; + const changelogPath = path.join(__dirname, '../../packages/harmony_vchart/library/CHANGELOG.md'); + let fileContent = fs.readFileSync(changelogPath, { encoding: 'utf-8' }); + + fileContent = ` +## ${nextVersion} + +${changelogContent} + +${fileContent} +`; + + fs.writeFileSync(fileContent, changelogPath) +} + +module.exports = setChangelogOfHarmny; \ No newline at end of file diff --git a/common/scripts/set-prerelease-version.js b/common/scripts/set-prerelease-version.js index 991aa25183..533894c826 100644 --- a/common/scripts/set-prerelease-version.js +++ b/common/scripts/set-prerelease-version.js @@ -4,6 +4,17 @@ const getPackageJson = require('./get-package-json'); const parseVersion = require('./parse-version'); const setJsonFileByKey = require('./set-json-file'); +function writeVersionOfHarmony(nextVersion) { + const ohPackageJsonPath = path.join(__dirname, '../../packages/harmony_vchart/library/oh-package.json5'); + let jsonFile = fs.readFileSync(ohPackageJsonPath, { encoding: 'utf-8' }); + const pkgJson = JSON.parse(jsonFile); + + jsonFile = setJsonFileByKey(jsonFile, pkgJson, ['version'], nextVersion); + + + fs.writeFileSync(pkgJsonPath, jsonFile); +} + function writePrereleaseVersion(nextBump, preReleaseName, nextVersionStr, buildName) { const rushJson = getPackageJson(path.join(__dirname, '../../rush.json')); @@ -86,7 +97,7 @@ function writePrereleaseVersion(nextBump, preReleaseName, nextVersionStr, buildN fs.writeFileSync(pkgJsonPath, jsonFile) }); - + writeVersionOfHarmony(nextVersion); } module.exports = writePrereleaseVersion; \ No newline at end of file diff --git a/packages/vchart/bundler.config.js b/packages/vchart/bundler.config.js index a5f6a297c1..8a78387be3 100644 --- a/packages/vchart/bundler.config.js +++ b/packages/vchart/bundler.config.js @@ -115,10 +115,11 @@ module.exports = { fs.unlinkSync(path.join(__dirname, config.outputDir.umd, `${entry}.min.js`)); }); // harmonyOS - const source = 'index.es.js'; + const source = 'es5/index.es.js'; const dest = '../harmony_vchart/library/src/main/ets/vchart_dist.js'; const envSource = path.join(__dirname, config.outputDir.umd, source); copyFile(envSource, path.join(__dirname, dest)); + fs.unlinkSync(path.join(__dirname, config.outputDir.umd, source)); } } }; From 8c2f1fa26de941c6afe69f6d96195cb6cd03cd32 Mon Sep 17 00:00:00 2001 From: xile611 Date: Fri, 14 Jun 2024 11:58:41 +0800 Subject: [PATCH 2/2] chore: update changelog in bundler.config.js --- packages/vchart/bundler.config.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/vchart/bundler.config.js b/packages/vchart/bundler.config.js index 8a78387be3..8534fad6c7 100644 --- a/packages/vchart/bundler.config.js +++ b/packages/vchart/bundler.config.js @@ -114,12 +114,17 @@ module.exports = { umdEntries.forEach(entry => { fs.unlinkSync(path.join(__dirname, config.outputDir.umd, `${entry}.min.js`)); }); - // harmonyOS - const source = 'es5/index.es.js'; - const dest = '../harmony_vchart/library/src/main/ets/vchart_dist.js'; - const envSource = path.join(__dirname, config.outputDir.umd, source); - copyFile(envSource, path.join(__dirname, dest)); - fs.unlinkSync(path.join(__dirname, config.outputDir.umd, source)); + + try { + // harmonyOS + const source = 'es5/index.es.js'; + const dest = '../harmony_vchart/library/src/main/ets/vchart_dist.js'; + const envSource = path.join(__dirname, config.outputDir.umd, source); + copyFile(envSource, path.join(__dirname, dest)); + fs.unlinkSync(path.join(__dirname, config.outputDir.umd, source)); + } catch(e) { + console.log(`[Error] can't copy es5/index.es.js to harmony`) + } } } };