chore: carry oldVersion from lib
parent
b1e290f44d
commit
6bdc8cae1b
|
@ -9,6 +9,7 @@ module.exports = class BaseVersioning {
|
||||||
|
|
||||||
newVersion = null
|
newVersion = null
|
||||||
|
|
||||||
|
oldVersion = null
|
||||||
/**
|
/**
|
||||||
* Set some basic configurations
|
* Set some basic configurations
|
||||||
*
|
*
|
||||||
|
|
|
@ -12,12 +12,12 @@ module.exports = class Git extends BaseVersioning {
|
||||||
const prerelease = core.getBooleanInput('pre-release')
|
const prerelease = core.getBooleanInput('pre-release')
|
||||||
|
|
||||||
gitSemverTags({ tagPrefix, skipUnstable: !prerelease }, async (err, tags) => {
|
gitSemverTags({ tagPrefix, skipUnstable: !prerelease }, async (err, tags) => {
|
||||||
const currentVersion = tags.length > 0 ? tags.shift().replace(tagPrefix, '') : null
|
this.oldVersion = tags.length > 0 ? tags.shift().replace(tagPrefix, '') : null
|
||||||
|
|
||||||
// Get the new version
|
// Get the new version
|
||||||
this.newVersion = await bumpVersion(
|
this.newVersion = await bumpVersion(
|
||||||
releaseType,
|
releaseType,
|
||||||
currentVersion,
|
oldVersion,
|
||||||
)
|
)
|
||||||
|
|
||||||
// We are done
|
// We are done
|
||||||
|
|
|
@ -30,12 +30,12 @@ module.exports = class Json extends BaseVersioning {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the old version
|
// Get the old version
|
||||||
const oldVersion = objectPath.get(jsonContent, this.versionPath, null)
|
this.oldVersion = objectPath.get(jsonContent, this.versionPath, null)
|
||||||
|
|
||||||
// Get the new version
|
// Get the new version
|
||||||
this.newVersion = await bumpVersion(
|
this.newVersion = await bumpVersion(
|
||||||
releaseType,
|
releaseType,
|
||||||
oldVersion,
|
this.oldVersion,
|
||||||
)
|
)
|
||||||
|
|
||||||
core.info(`Bumped file "${this.fileLocation}" from "${oldVersion}" to "${this.newVersion}"`)
|
core.info(`Bumped file "${this.fileLocation}" from "${oldVersion}" to "${this.newVersion}"`)
|
||||||
|
|
|
@ -17,16 +17,16 @@ module.exports = class Toml extends BaseVersioning {
|
||||||
// Read the file
|
// Read the file
|
||||||
const fileContent = this.read()
|
const fileContent = this.read()
|
||||||
const tomlContent = toml.parse(fileContent)
|
const tomlContent = toml.parse(fileContent)
|
||||||
const oldVersion = objectPath.get(tomlContent, this.versionPath, null)
|
this.oldVersion = objectPath.get(tomlContent, this.versionPath, null)
|
||||||
|
|
||||||
// Get the new version
|
// Get the new version
|
||||||
this.newVersion = await bumpVersion(
|
this.newVersion = await bumpVersion(
|
||||||
releaseType,
|
releaseType,
|
||||||
oldVersion,
|
this.oldVersion,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Update the file
|
// Update the file
|
||||||
if (oldVersion) {
|
if (this.oldVersion) {
|
||||||
// Get the name of where the version is in
|
// Get the name of where the version is in
|
||||||
const versionName = this.versionPath.split('.').pop()
|
const versionName = this.versionPath.split('.').pop()
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ module.exports = class Toml extends BaseVersioning {
|
||||||
this.update(
|
this.update(
|
||||||
// We use replace instead of yaml.stringify so we can preserve white spaces and comments
|
// We use replace instead of yaml.stringify so we can preserve white spaces and comments
|
||||||
fileContent.replace(
|
fileContent.replace(
|
||||||
`${versionName} = "${oldVersion}"`,
|
`${versionName} = "${this.oldVersion}"`,
|
||||||
`${versionName} = "${this.newVersion}"`,
|
`${versionName} = "${this.newVersion}"`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,16 +17,16 @@ module.exports = class Yaml extends BaseVersioning {
|
||||||
// Read the file
|
// Read the file
|
||||||
const fileContent = this.read()
|
const fileContent = this.read()
|
||||||
const yamlContent = yaml.parse(fileContent) || {}
|
const yamlContent = yaml.parse(fileContent) || {}
|
||||||
const oldVersion = objectPath.get(yamlContent, this.versionPath, null)
|
this.oldVersion = objectPath.get(yamlContent, this.versionPath, null)
|
||||||
|
|
||||||
// Get the new version
|
// Get the new version
|
||||||
this.newVersion = await bumpVersion(
|
this.newVersion = await bumpVersion(
|
||||||
releaseType,
|
releaseType,
|
||||||
oldVersion,
|
this.oldVersion,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Update the file
|
// Update the file
|
||||||
if (oldVersion) {
|
if (this.oldVersion) {
|
||||||
// Get the name of where the version is in
|
// Get the name of where the version is in
|
||||||
const versionName = this.versionPath.split('.').pop()
|
const versionName = this.versionPath.split('.').pop()
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ module.exports = class Yaml extends BaseVersioning {
|
||||||
// We use replace instead of yaml.stringify so we can preserve white spaces and comments
|
// We use replace instead of yaml.stringify so we can preserve white spaces and comments
|
||||||
// Replace if version was used with single quotes
|
// Replace if version was used with single quotes
|
||||||
fileContent.replace(
|
fileContent.replace(
|
||||||
`${versionName}: '${oldVersion}'`,
|
`${versionName}: '${this.oldVersion}'`,
|
||||||
`${versionName}: '${this.newVersion}'`,
|
`${versionName}: '${this.newVersion}'`,
|
||||||
).replace( // Replace if version was used with double quotes
|
).replace( // Replace if version was used with double quotes
|
||||||
`${versionName}: "${oldVersion}"`,
|
`${versionName}: "${this.oldVersion}"`,
|
||||||
`${versionName}: "${this.newVersion}"`,
|
`${versionName}: "${this.newVersion}"`,
|
||||||
).replace( // Replace if version was used with no quotes
|
).replace( // Replace if version was used with no quotes
|
||||||
`${versionName}: ${oldVersion}`,
|
`${versionName}: ${this.oldVersion}`,
|
||||||
`${versionName}: ${this.newVersion}`,
|
`${versionName}: ${this.newVersion}`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue