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:
zhenyus 2025-04-21 11:30:59 +08:00
parent a308bcc41e
commit 21b0569e65
2 changed files with 15 additions and 6 deletions

View File

@ -26,11 +26,7 @@ class SemanticReleasingExecutor {
steps.dir(steps.env.workroot) {
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.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.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.env.GIT_LOCAL_BRANCH = "${branch}"
steps.sh """
@ -38,10 +34,23 @@ class SemanticReleasingExecutor {
semantic-release
"""
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) {
steps.env.LATEST_VERSION = steps.readFile('VERSION').trim()
steps.env.SEMANTIC_RELEASED = true
} else if (versionFileExists) {
steps.log.warn("SemanticReleasingExecutor", "VERSION file exists but was not modified recently, skipping release")
}
}
}

View File

@ -7,7 +7,7 @@ executeFreeleapsPipeline {
serviceGitRepo = "https://gitea.freeleaps.mathmast.com/freeleaps/freeleaps-service-hub.git"
serviceGitRepoType = 'monorepo'
serviceGitCredentialsId = 'freeleaps-repos-gitea-credentails'
executeMode = 'on-demand'
executeMode = 'fully'
commitMessageLintEnabled = false
components = [
[