Compare commits
24 Commits
0.0.1.post
...
1.0.3.post
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13a584c7d9 | ||
|
|
6dfe0682d7 | ||
|
|
d15b495f0a | ||
|
|
c9df0e7409 | ||
|
|
866e8ff7ff | ||
|
|
d786d27cd7 | ||
|
|
fb2f3eb412 | ||
|
|
d93fd3286c | ||
|
|
f361a5189a | ||
|
|
3751ef1c93 | ||
|
|
d5e003c86c | ||
|
|
8b2b0ca07f | ||
|
|
ab1a69b8f8 | ||
|
|
a564e04219 | ||
|
|
a29c1778fc | ||
|
|
2ee687959e | ||
|
|
e226f16292 | ||
|
|
8ea6b43a73 | ||
|
|
cb213df6b6 | ||
|
|
2c87f5488d | ||
|
|
348204abb5 | ||
|
|
48114149fb | ||
|
|
5eb2f1c5cf | ||
|
|
65927077aa |
152
Jenkinsfile
vendored
152
Jenkinsfile
vendored
@@ -6,6 +6,8 @@
|
||||
// You should have received a copy of the license along with this
|
||||
// work. If not, see <https://creativecommons.org/licenses/by-nc-sa/4.0/>.
|
||||
|
||||
|
||||
|
||||
// configurable settings:
|
||||
// use to send email if workflow problem
|
||||
def _MaintainerName = "CHACHA"
|
||||
@@ -17,7 +19,7 @@ def _bPreRelease = false
|
||||
// toogle Draft flag on Gitea release system => If False, TAG is not created
|
||||
def _bDraft = false
|
||||
// release content / changelog management
|
||||
def _bAutoChangelog = false //Not supported yet
|
||||
def _bAutoChangelog = true //Not supported yet
|
||||
def _ReleaseContent_Title = "_CI/CD Automatic Release_"
|
||||
// full rebuild toogle
|
||||
def _bFullRebuilt = true
|
||||
@@ -94,12 +96,12 @@ pipeline {
|
||||
PY_PROJECT_VERSION = "__NOTSET__"
|
||||
PY_PROJECT_VERSION_STRIPPED = "__NOTSET__"
|
||||
}
|
||||
|
||||
|
||||
stages {
|
||||
|
||||
|
||||
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 +110,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
|
||||
}
|
||||
}
|
||||
@@ -120,45 +121,63 @@ pipeline {
|
||||
echo("_GITEA_BASE_URL: . . . . . . . . $_GITEA_BASE_URL")
|
||||
echo("GIT_COMMIT:. . . . . . . . . . . $GIT_COMMIT ")
|
||||
echo("_PROJECT_USER_NAME:. . . . . . . $_PROJECT_USER_NAME")
|
||||
echo("_GITEA_PROJECT_NAME: . . . . . . $_PROJECT_NAME")
|
||||
echo("_PROJECT_NAME: . . . . . . . . . $_PROJECT_NAME")
|
||||
echo("_MaintainerEmail:. . . . . . . . $_MaintainerEmail")
|
||||
echo("_MaintainerName:. . . . . . . . $_MaintainerName")
|
||||
|
||||
|
||||
sh("virtualenv --pip=embed --setuptools=embed --wheel=embed --no-periodic-update --activators bash,python BUILD_ENV")
|
||||
sh("virtualenv --pip=embed --setuptools=embed --wheel=embed --no-periodic-update --activators bash,python TEST_ENV")
|
||||
sh("virtualenv --pip=embed --setuptools=embed --wheel=embed --no-periodic-update --activators bash,python TOOLS_ENV")
|
||||
|
||||
sh(". ~/BUILD_ENV/bin/activate && pip install --upgrade setuptools build pip copier jinja2-slug toml \"setuptools-git-versioning<2\"")
|
||||
sh(". ~/BUILD_ENV/bin/activate && pip install --upgrade setuptools build pip copier jinja2-slug toml")
|
||||
|
||||
sh(". ~/TOOLS_ENV/bin/activate && pip install simple_rest_client requests")
|
||||
sh(". ~/TOOLS_ENV/bin/activate && pip install git+https://chacha.ddns.net/gitea/chacha/pygitversionhelper.git@master")
|
||||
|
||||
|
||||
script {
|
||||
if(_PROJECT_NAME!="pygitversionhelper") {
|
||||
sh(". ~/TOOLS_ENV/bin/activate && pip install git+https://chacha.ddns.net/gitea/chacha/pygitversionhelper.git@master")
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: need to install pygitversionhelper deps from a better way...
|
||||
sh(". ~/TOOLS_ENV/bin/activate && pip install packaging")
|
||||
}
|
||||
}
|
||||
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")
|
||||
}
|
||||
|
||||
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__'
|
||||
|
|
||||
|from pygitversionhelper import gitversionhelper
|
||||
|import re
|
||||
|
|
||||
|try:
|
||||
| from pygitversionhelper import gitversionhelper
|
||||
|except ImportError:
|
||||
| from src.pygitversionhelper import gitversionhelper
|
||||
|
|
||||
|lastcommit=gitversionhelper.commit.getLast(same_branch=True)
|
||||
|msg=gitversionhelper.commit.getMessage(lastcommit)
|
||||
|
|
||||
@@ -168,46 +187,45 @@ 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"
|
||||
|
||||
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 -
|
||||
|. ~/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())
|
||||
|
||||
latestTag = sh(script: """#!/bin/sh -
|
||||
|. ~/TOOLS_ENV/bin/activate
|
||||
|exec python - << '__EOWRAPPER__'
|
||||
|
|
||||
|try:
|
||||
| from pygitversionhelper import gitversionhelper
|
||||
|except ImportError:
|
||||
| from src.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
|
||||
|exec python - << '__EOWRAPPER__'
|
||||
|
|
||||
|from pygitversionhelper import gitversionhelper
|
||||
|try:
|
||||
| from pygitversionhelper import gitversionhelper
|
||||
|except ImportError:
|
||||
| from src.pygitversionhelper import gitversionhelper
|
||||
|
|
||||
|print(gitversionhelper.version.getCurrentVersion(formated_output=True,version_std="PEP440",bump_type="dev",bump_dev_strategy="post"),end ="")
|
||||
|
|
||||
@@ -217,11 +235,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 / setuptools_scm cant fing tag on other branches, so will guess a wrong 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 -
|
||||
@@ -282,7 +305,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 .")
|
||||
}
|
||||
@@ -311,16 +334,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])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -433,19 +456,24 @@ 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__'
|
||||
|
|
||||
|from simple_rest_client.api import API
|
||||
|from simple_rest_client.resource import Resource
|
||||
|import json
|
||||
|import glob
|
||||
|import requests
|
||||
|import shutil
|
||||
|
|
||||
|from simple_rest_client.api import API
|
||||
|from simple_rest_client.resource import Resource
|
||||
|
|
||||
|try:
|
||||
| from pygitversionhelper import gitversionhelper
|
||||
|except ImportError:
|
||||
| from src.pygitversionhelper import gitversionhelper
|
||||
|
|
||||
|from urllib.parse import urljoin
|
||||
|
|
||||
|class GiteaRepoCommits(Resource):
|
||||
|
||||
@@ -24,8 +24,8 @@ Checkout [Latest Documentation](https://chacha.ddns.net/mkdocs-web/chacha/pygitv
|
||||
- restrict to same branch
|
||||
- both SemVer and PEP440 support
|
||||
- custom output format
|
||||
- configurable default bump type major, minor, patch or dev
|
||||
- configurable default bump type: post, pre-patch, pre-minor, pre-major
|
||||
- configurable default bump type: major, minor, patch or dev
|
||||
- configurable default bump strategy: post, pre-patch, pre-minor, pre-major
|
||||
- ignore non-version tag
|
||||
- force version format
|
||||
|
||||
|
||||
@@ -7,13 +7,12 @@
|
||||
# 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"
|
||||
tag_regex="^(?:v)?(?P<version>\\d+\\.\\d+\\.\\d+)([\\.\\-\\+])?(?:.*)?"
|
||||
|
||||
[project]
|
||||
name = "pygitversionhelper"
|
||||
@@ -51,8 +50,8 @@ where = ["src"]
|
||||
"pygitversionhelper.data" = ["*.*"]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://chacha.ddns.net/gitea/chacha/pygitversionhelper"
|
||||
Documentation = "https://chacha.ddns.net/gitea/chacha/pygitversionhelper/wiki"
|
||||
Homepage = "https://chacha.ddns.net/gitea/chacha/pygitversionhelper/"
|
||||
Documentation = "https://chacha.ddns.net/mkdocs-web/chacha/pygitversionhelper/master/latest/"
|
||||
Tracker = "https://chacha.ddns.net/gitea/chacha/pygitversionhelper/issues"
|
||||
|
||||
[project.optional-dependencies]
|
||||
|
||||
Reference in New Issue
Block a user