Compare commits
7 Commits
1.0.0
...
1.0.2.post
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a564e04219 | ||
|
|
a29c1778fc | ||
|
|
2ee687959e | ||
|
|
e226f16292 | ||
|
|
8ea6b43a73 | ||
|
|
cb213df6b6 | ||
|
|
2c87f5488d |
112
Jenkinsfile
vendored
112
Jenkinsfile
vendored
@@ -99,7 +99,7 @@ pipeline {
|
||||
|
||||
stage("Prepare") {
|
||||
steps {
|
||||
script{
|
||||
script {
|
||||
if (_bFullRebuilt) {
|
||||
// start by cleaning the workspace (not using cleanWs() because we want to keep the directory itself)
|
||||
// => this is needed to fetch it again with custom options
|
||||
@@ -108,8 +108,7 @@ pipeline {
|
||||
else {
|
||||
sh("find ~/. -name . ! -path './TEST_ENV/*' ! -path './BUILD_ENV/*' -o -prune -exec rm -rf -- {} +")
|
||||
}
|
||||
if(_GIT_BRANCH!="master")
|
||||
{
|
||||
if(_GIT_BRANCH!="master") {
|
||||
_bPreRelease = true
|
||||
}
|
||||
}
|
||||
@@ -135,23 +134,47 @@ pipeline {
|
||||
|
||||
sh("git config --global user.email $_MaintainerEmail")
|
||||
sh("git config --global user.name $_MaintainerName")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stage("GetCode") {
|
||||
steps {
|
||||
dir("gitrepo") {
|
||||
// manually checkout the repository, with All branches and tags
|
||||
// manually checkout the repository, with All branches and tags
|
||||
// => because we might need them for version and changelog computing
|
||||
checkout([ $class: "GitSCM",
|
||||
branches: [[name: GIT_BRANCH]],
|
||||
extensions: [[$class: "CloneOption", noTags: false, shallow: false, depth: 0, reference: '']],
|
||||
userRemoteConfigs: [[credentialsId: _SCMCredentials, url: GIT_URL]]])
|
||||
script{
|
||||
if(_GIT_BRANCH=="master")
|
||||
{
|
||||
if(sh(returnStdout: true, script: "git tag --points-at HEAD").trim().isEmpty())
|
||||
{
|
||||
script {
|
||||
|
||||
withCredentials([usernamePassword(credentialsId: _SCMCredentials, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
|
||||
sh("git remote set-url origin https://${GIT_USERNAME}:${GIT_PASSWORD}@chacha.ddns.net/gitea/${_PROJECT_USER_NAME}/${_PROJECT_NAME}.git")
|
||||
}
|
||||
|
||||
// using git to get the latest tag on this branch (before processing)
|
||||
def latestTag_beforeProcessing = sh(returnStdout: true, script: "git tag --sort=-creatordate | head -n 1").trim()
|
||||
echo("latestTag_beforeProcessing:. . . . . . . . . . . . $latestTag_beforeProcessing")
|
||||
|
||||
sh(script: """#!/bin/sh -
|
||||
|. ~/TOOLS_ENV/bin/activate
|
||||
|exec python - << '__EOWRAPPER__'
|
||||
|
|
||||
|from pygitversionhelper import gitversionhelper
|
||||
|
|
||||
|print(f"most recent repository tag: {gitversionhelper.tag.getLastTag()}")
|
||||
|print(f"most recent repository tag: {gitversionhelper.tag.getLastTag(same_branch=True)}")
|
||||
|print(f"number of commit since last tag: {gitversionhelper.tag.getDistanceFromTag()}")
|
||||
|print(f"number of commit since last tag: {gitversionhelper.tag.getDistanceFromTag(same_branch=True)}")
|
||||
|print(f"most recent repository version: {gitversionhelper.version.getLastVersion(formated_output=True)}")
|
||||
|print(f'current repository version: {gitversionhelper.version.getCurrentVersion(formated_output=True,version_std="PEP440",bump_type="dev",bump_dev_strategy="post")}')
|
||||
|
|
||||
|__EOWRAPPER__
|
||||
""".stripMargin())
|
||||
|
||||
if(_GIT_BRANCH=="master") {
|
||||
if(sh(returnStdout: true, script: "git tag --points-at HEAD").trim().isEmpty()) {
|
||||
BUMPED_VERSION = sh(script: """#!/bin/sh -
|
||||
|. ~/TOOLS_ENV/bin/activate
|
||||
|exec python - << '__EOWRAPPER__'
|
||||
@@ -168,28 +191,20 @@ pipeline {
|
||||
|__EOWRAPPER__
|
||||
""".stripMargin(),
|
||||
returnStdout: true).trim()
|
||||
if(BUMPED_VERSION.isEmpty())
|
||||
{
|
||||
if(BUMPED_VERSION.isEmpty()) {
|
||||
echo "master push/merge must have an explicit tag release number, stopping pipeline"
|
||||
currentBuild.getRawBuild().getExecutor().doStop()
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
echo "new-tag requested in commit message: $BUMPED_VERSION"
|
||||
withCredentials([usernamePassword(credentialsId: _SCMCredentials, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
|
||||
sh("git remote set-url origin https://${GIT_USERNAME}:${GIT_PASSWORD}@chacha.ddns.net/gitea/${_PROJECT_USER_NAME}/${_PROJECT_NAME}.git")
|
||||
}
|
||||
|
||||
sh("git tag $BUMPED_VERSION")
|
||||
sh("git push origin --tags")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// using git to get the latest tag on this branch
|
||||
def latestTag = sh(returnStdout: true, script: "git tag --sort=-creatordate | head -n 1").trim()
|
||||
echo("latestTag:. . . . . . . . . . . . $latestTag ")
|
||||
|
||||
sh(script: """#!/bin/sh -
|
||||
|
||||
sh(script: """#!/bin/sh -
|
||||
|. ~/TOOLS_ENV/bin/activate
|
||||
|exec python - << '__EOWRAPPER__'
|
||||
|
|
||||
@@ -204,7 +219,20 @@ pipeline {
|
||||
|
|
||||
|__EOWRAPPER__
|
||||
""".stripMargin())
|
||||
|
||||
|
||||
latestTag = sh(script: """#!/bin/sh -
|
||||
|. ~/TOOLS_ENV/bin/activate
|
||||
|exec python - << '__EOWRAPPER__'
|
||||
|
|
||||
|from pygitversionhelper import gitversionhelper
|
||||
|
|
||||
|print(gitversionhelper.tag.getLastTag(same_branch=True),end ="")
|
||||
|
|
||||
|__EOWRAPPER__
|
||||
""".stripMargin(),
|
||||
returnStdout: true)
|
||||
echo("latestTag:. . . . . . . . . . . . $latestTag ")
|
||||
|
||||
// get current (or bumped) version number from git history
|
||||
PY_PROJECT_VERSION = sh(script: """#!/bin/sh -
|
||||
|. ~/TOOLS_ENV/bin/activate
|
||||
@@ -220,11 +248,16 @@ pipeline {
|
||||
echo("PY_PROJECT_VERSION: . . . . . . . . . $PY_PROJECT_VERSION")
|
||||
PY_PROJECT_VERSION_STRIPPED=ExtractBaseVersion(PY_PROJECT_VERSION)
|
||||
|
||||
// Manually pushing a new tag with version string guessed by gitversionhelper
|
||||
// because setuptools-git-versioning cant fing tag on other branches, so will guess a wring version without this tag.
|
||||
if(latestTag!=PY_PROJECT_VERSION) {
|
||||
sh("git tag $PY_PROJECT_VERSION")
|
||||
sh("git push origin --tags")
|
||||
}
|
||||
|
||||
// specific handling to test the template itself
|
||||
// => little hacky... creating a new git repo with a commit/tag corresponding to HEAD of the official one
|
||||
if(_PROJECT_NAME=="pyChaChaDummyProject") //specific case to test the template itself
|
||||
{
|
||||
|
||||
if(_PROJECT_NAME=="pyChaChaDummyProject") { //specific case to test the template itself
|
||||
sh("rm -Rf ~/_gitrepo || true")
|
||||
|
||||
sh(script: """#!/bin/sh -
|
||||
@@ -285,7 +318,7 @@ pipeline {
|
||||
steps {
|
||||
// no need for a build-env: setuptools is already creating one
|
||||
dir("gitrepo") {
|
||||
script{
|
||||
script {
|
||||
// actually doing the package build
|
||||
sh(". ~/BUILD_ENV/bin/activate && python -m build .")
|
||||
}
|
||||
@@ -314,16 +347,16 @@ pipeline {
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
dir("gitrepo") {
|
||||
publishHTML([
|
||||
reportDir: "helpers-results/quality_check",
|
||||
reportFiles: "report.html",
|
||||
reportName: "quality-report",
|
||||
allowMissing: false,
|
||||
alwaysLinkToLastBuild: true,
|
||||
keepAll: true])
|
||||
}
|
||||
always {
|
||||
dir("gitrepo") {
|
||||
publishHTML([
|
||||
reportDir: "helpers-results/quality_check",
|
||||
reportFiles: "report.html",
|
||||
reportName: "quality-report",
|
||||
allowMissing: false,
|
||||
alwaysLinkToLastBuild: true,
|
||||
keepAll: true])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -436,8 +469,7 @@ pipeline {
|
||||
dir("gitrepo") {
|
||||
script {
|
||||
def CurrentDateTime=java.time.LocalDateTime.now()
|
||||
withCredentials([string( credentialsId: _MkDocsWebCredentials,variable: 'MKDOCSTOKEN' )])
|
||||
{
|
||||
withCredentials([string( credentialsId: _MkDocsWebCredentials,variable: 'MKDOCSTOKEN' )]) {
|
||||
sh(script: """#!/bin/sh -
|
||||
|. ~/TOOLS_ENV/bin/activate
|
||||
|exec python - << '__EOWRAPPER__'
|
||||
|
||||
@@ -7,13 +7,11 @@
|
||||
# work. If not, see <https://creativecommons.org/licenses/by-nc-sa/4.0/>.
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools>=63", "wheel", "setuptools-git-versioning<2"]
|
||||
requires = ["setuptools>=63", "wheel", "setuptools_scm"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.setuptools-git-versioning]
|
||||
enabled = true
|
||||
dev_template = "{tag}.post{ccount}"
|
||||
tag_filter = "^\\d+\\.\\d+\\.\\d+$"
|
||||
[tool.setuptools_scm]
|
||||
version_scheme= "post-release"
|
||||
|
||||
[project]
|
||||
name = "pygitversionhelper"
|
||||
|
||||
Reference in New Issue
Block a user