Skip to content

Commit

Permalink
chore: adjust version check
Browse files Browse the repository at this point in the history
  • Loading branch information
arnautov-anton committed Feb 27, 2025
1 parent 3283683 commit 57a4e39
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ typings/
.envrc

test/typescript/data.*
.version
2 changes: 1 addition & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
[
"@semantic-release/exec",
{
"prepareCmd": "echo \"NEXT_VERSION=${nextRelease.version}\" >> $GITHUB_ENV"
"prepareCmd": "echo \"${nextRelease.version}\" > .version"
}
],
[
Expand Down
12 changes: 8 additions & 4 deletions scripts/get-package-version.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { execSync } from 'node:child_process';
import { resolve } from 'node:path';
import { readFileSync } from 'node:fs';
import packageJson from '../package.json' with { type: 'json' };

// Get the latest version so that magic string __STREAM_CHAT_REACT_VERSION__ can be replaced with it in the source code (used for reporting purposes)
export default function getPackageVersion() {
let version;
// During release, use the version being released
// see .releaserc.json where the `NEXT_VERSION` env variable is set
if (process.env.NEXT_VERSION) {
version = process.env.NEXT_VERSION;
} else {
// see .releaserc.json where the .version file is generated
try {
version = readFileSync(resolve(import.meta.dirname, '../.version')).toString().trim();
} catch {/* do nothing */}

if (typeof version !== 'string') {
// Otherwise use the latest git tag
try {
version = execSync('git describe --tags --abbrev=0').toString().trim();
Expand Down

0 comments on commit 57a4e39

Please sign in to comment.