diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 05bd8282..b4fcf018 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -75,6 +75,9 @@ jobs: run: node scripts/update-changelog.mjs if: ${{ github.event.inputs.releaseChannel == 'stable' }} + - name: Update version number in the base class + run: node scripts/update-version-number.mjs + - name: Tagging run: | git add . diff --git a/scripts/update-version-number.mjs b/scripts/update-version-number.mjs new file mode 100644 index 00000000..9aa85639 --- /dev/null +++ b/scripts/update-version-number.mjs @@ -0,0 +1,33 @@ +import fs from 'fs'; +import util from 'util'; +import path, {dirname} from 'path'; +import {fileURLToPath} from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const readFile = util.promisify(fs.readFile); +const writeFile = util.promisify(fs.writeFile); + +const BASE_CLASS_PATH = path.join( + __dirname, + '..', + 'src', + 'includes', + 'VscElement.ts' +); + +async function main() { + const pkgPath = path.join(__dirname, '..', 'package.json'); + const pkg = JSON.parse(fs.readFileSync(pkgPath).toString()); + const {version} = pkg; + + const fc = await readFile(BASE_CLASS_PATH, 'utf-8'); + const newContent = fc.replace(/readonly version = '[a-z0-9-]+';/g, `readonly version = '${version}';`); + + await writeFile(BASE_CLASS_PATH, newContent); + + console.log('VscElement.ts updated successfully'); +} + +main(); diff --git a/src/includes/VscElement.ts b/src/includes/VscElement.ts index fc0504c3..f76700ca 100644 --- a/src/includes/VscElement.ts +++ b/src/includes/VscElement.ts @@ -1,3 +1,6 @@ import {LitElement} from 'lit'; -export class VscElement extends LitElement {} +export class VscElement extends LitElement { + /** VSC Element version */ + public readonly version = '1.0.0-pre.5'; +}