diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c9d9ea3d60..aaf7c6269e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,6 +63,9 @@ jobs: restore-keys: | ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} + - name: Cheking model is updated... + run: node common/scripts/check_model_version.js + - name: Checking for mis-matching dependencies... run: node common/scripts/install-run-rush.js check diff --git a/common/scripts/check_model_version.js b/common/scripts/check_model_version.js new file mode 100755 index 0000000000..1c0d2bcd0f --- /dev/null +++ b/common/scripts/check_model_version.js @@ -0,0 +1,20 @@ +const exec = require('child_process').exec + +exec('git describe --tags --abbrev=0', (err, stdout, stderr) => { + if (err !== null) { + process.exit(1) + } + const tag = stdout.trim() + exec(`git fetch --tags && git diff ${tag} --name-only`, (err, stdout, stderr) => { + if (err !== null) { + process.exit(1) + } + const changedFiles = stdout.trim().split('\n') + const modelsChanged = changedFiles.some(file => file.startsWith('models/')) + const versionChanged = changedFiles.some(file => file.endsWith('version.txt')) + if (modelsChanged && !versionChanged) { + console.log('Please update model version') + process.exit(1) + } + }) +}) \ No newline at end of file diff --git a/common/scripts/show_version.js b/common/scripts/show_version.js index 4d405ce6f2..99a17e30b5 100644 --- a/common/scripts/show_version.js +++ b/common/scripts/show_version.js @@ -13,19 +13,14 @@ // limitations under the License. // -const exec = require('child_process').exec +const fs = require('fs') +const path = require('path') -exec('git describe --tags --abbrev=0', (err, stdout, stderr) => { - if (err !== null) { - console.log('"0.6.0"') - } - const rawVersion = stdout.trim().replace('v', '').split('.') - if (rawVersion.length === 3) { - const version = { - major: parseInt(rawVersion[0]), - minor: parseInt(rawVersion[1]), - patch: parseInt(rawVersion[2]) - } - console.log(`"${version.major}.${version.minor}.${version.patch}"`) - } -}) +try { + const versionFilePath = path.resolve(__dirname, 'version.txt') + const version = fs.readFileSync(versionFilePath, 'utf8').trim() + + console.log(version) +} catch (error) { + console.log('0.6.0') +} diff --git a/common/scripts/version.txt b/common/scripts/version.txt new file mode 100644 index 0000000000..dd866b3be9 --- /dev/null +++ b/common/scripts/version.txt @@ -0,0 +1 @@ +"0.6.266" \ No newline at end of file