refactor: streamline semantic release process by removing unnecessary installation steps and improving version file checks
Signed-off-by: zhenyus <zhenyus@mathmast.com>
This commit is contained in:
parent
a308bcc41e
commit
21b0569e65
@ -26,11 +26,7 @@ class SemanticReleasingExecutor {
|
|||||||
steps.dir(steps.env.workroot) {
|
steps.dir(steps.env.workroot) {
|
||||||
steps.withCredentials([steps.usernamePassword(credentialsId: credentialsId, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
|
steps.withCredentials([steps.usernamePassword(credentialsId: credentialsId, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
|
||||||
steps.env.GIT_CREDENTIALS = "${steps.env.GIT_USERNAME}:${steps.env.GIT_PASSWORD}"
|
steps.env.GIT_CREDENTIALS = "${steps.env.GIT_USERNAME}:${steps.env.GIT_PASSWORD}"
|
||||||
// steps.log.info("SemanticReleasingExecutor", "Installing semantic-release requirements...")
|
|
||||||
// steps.sh "apt-get -y update && apt-get install -y --no-install-recommends git apt-transport-https ca-certificates curl wget gnupg"
|
|
||||||
steps.writeFile file: '.releaserc.json', text: steps.libraryResource(config)
|
steps.writeFile file: '.releaserc.json', text: steps.libraryResource(config)
|
||||||
// steps.log.info("SemanticReleasingExecutor", "Installing semantic-release plugins...")
|
|
||||||
// steps.sh "npm install -g ${plugins.join(' ')}"
|
|
||||||
steps.sh "git config --global --add safe.directory ${steps.env.workroot}"
|
steps.sh "git config --global --add safe.directory ${steps.env.workroot}"
|
||||||
steps.env.GIT_LOCAL_BRANCH = "${branch}"
|
steps.env.GIT_LOCAL_BRANCH = "${branch}"
|
||||||
steps.sh """
|
steps.sh """
|
||||||
@ -38,10 +34,23 @@ class SemanticReleasingExecutor {
|
|||||||
semantic-release
|
semantic-release
|
||||||
"""
|
"""
|
||||||
steps.log.info("SemanticReleasingExecutor", "Semantic release completed, read latest version from VERSION file")
|
steps.log.info("SemanticReleasingExecutor", "Semantic release completed, read latest version from VERSION file")
|
||||||
def released = steps.sh(script: 'test -f "VERSION"', returnStatus: true) == 0
|
|
||||||
|
// check if VERSION file exists
|
||||||
|
def versionFileExists = steps.sh(script: 'test -f "VERSION"', returnStatus: true) == 0
|
||||||
|
def recentlyModified = false
|
||||||
|
if (versionFileExists) {
|
||||||
|
// check if VERSION file was modified recently (within last minute)
|
||||||
|
def recentlyModified = steps.sh(script: 'stat -c %Y "VERSION"', returnStdout: true).trim() as Long
|
||||||
|
def currentTime = System.currentTimeMillis() / 1000
|
||||||
|
recentlyModified = (currentTime - recentlyModified) < 60
|
||||||
|
}
|
||||||
|
|
||||||
|
def released = fileExists && recentlyModified
|
||||||
if (released) {
|
if (released) {
|
||||||
steps.env.LATEST_VERSION = steps.readFile('VERSION').trim()
|
steps.env.LATEST_VERSION = steps.readFile('VERSION').trim()
|
||||||
steps.env.SEMANTIC_RELEASED = true
|
steps.env.SEMANTIC_RELEASED = true
|
||||||
|
} else if (versionFileExists) {
|
||||||
|
steps.log.warn("SemanticReleasingExecutor", "VERSION file exists but was not modified recently, skipping release")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ executeFreeleapsPipeline {
|
|||||||
serviceGitRepo = "https://gitea.freeleaps.mathmast.com/freeleaps/freeleaps-service-hub.git"
|
serviceGitRepo = "https://gitea.freeleaps.mathmast.com/freeleaps/freeleaps-service-hub.git"
|
||||||
serviceGitRepoType = 'monorepo'
|
serviceGitRepoType = 'monorepo'
|
||||||
serviceGitCredentialsId = 'freeleaps-repos-gitea-credentails'
|
serviceGitCredentialsId = 'freeleaps-repos-gitea-credentails'
|
||||||
executeMode = 'on-demand'
|
executeMode = 'fully'
|
||||||
commitMessageLintEnabled = false
|
commitMessageLintEnabled = false
|
||||||
components = [
|
components = [
|
||||||
[
|
[
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user