Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Transformerlab App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
TransformerLab
Transformerlab App
Commits
457ba5f4
Commit
457ba5f4
authored
1 year ago
by
aliasaria
Browse files
Options
Downloads
Patches
Plain Diff
script to help bump version for new builds
parent
7ab704b7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/bump_version.js
+61
-0
61 additions, 0 deletions
scripts/bump_version.js
with
61 additions
and
0 deletions
scripts/bump_version.js
0 → 100644
+
61
−
0
View file @
457ba5f4
const
fs
=
require
(
'
fs
'
);
const
{
execSync
}
=
require
(
'
child_process
'
);
const
{
version
}
=
require
(
'
os
'
);
const
files
=
[
'
package.json
'
,
'
package-lock.json
'
,
'
release/app/package.json
'
,
'
release/app/package-lock.json
'
,
];
function
getVersion
()
{
const
data
=
fs
.
readFileSync
(
'
package.json
'
,
'
utf-8
'
);
const
json
=
JSON
.
parse
(
data
);
return
json
.
version
;
}
function
bumpVersion
(
filePath
,
newVersion
)
{
console
.
log
(
`Bumping version in
${
filePath
}
`
);
const
data
=
fs
.
readFileSync
(
filePath
,
'
utf-8
'
);
const
json
=
JSON
.
parse
(
data
);
json
.
version
=
newVersion
;
fs
.
writeFileSync
(
filePath
,
JSON
.
stringify
(
json
,
null
,
2
));
}
// Get argument which can be either 'major', 'minor', or 'patch'
const
versionPart
=
process
.
argv
[
2
];
if
(
versionPart
===
undefined
)
{
console
.
error
(
'
No argument provided. Must provide either "major", "minor", or "patch"
'
);
process
.
exit
(
1
);
}
if
(
versionPart
&&
!
[
'
major
'
,
'
minor
'
,
'
patch
'
].
includes
(
versionPart
))
{
console
.
error
(
'
Invalid argument. Must be either "major", "minor", or "patch"
'
);
process
.
exit
(
1
);
}
const
currentVersion
=
getVersion
();
const
versionParts
=
currentVersion
.
split
(
'
.
'
);
if
(
versionPart
===
'
major
'
)
versionParts
[
0
]
=
parseInt
(
versionParts
[
0
])
+
1
;
// Bump the major version
if
(
versionPart
===
'
minor
'
)
versionParts
[
1
]
=
parseInt
(
versionParts
[
1
])
+
1
;
// Bump the minor version
if
(
versionPart
===
'
patch
'
)
versionParts
[
2
]
=
parseInt
(
versionParts
[
2
])
+
1
;
// Bump the patch version
const
newVersion
=
versionParts
.
join
(
'
.
'
);
console
.
log
(
`Bumping version from
${
currentVersion
}
to
${
newVersion
}
`
);
files
.
forEach
((
file
)
=>
{
bumpVersion
(
file
,
newVersion
);
});
// Add the updated files to git, commit the changes, and tag the new commit
execSync
(
`git add
${
files
.
join
(
'
'
)}
`
);
execSync
(
`git commit -m "Bump version to
${
newVersion
}
"`
);
execSync
(
`git tag v
${
newVersion
}
`
);
console
.
log
(
'
A new commit and tag have been created. Please push the changes to the remote repository to trigger a new build.
'
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment