-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
114 lines (99 loc) · 4.14 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
stages:
- build
- release
variables:
# Set the Python version
PYTHON_VERSION: "3.10"
before_script:
- python3 -V
- python3 -m venv venv
- source venv/bin/activate
#--------------------------------------------------------------------
build:
stage: build
script:
- pip install chardet wheel Markdown # Install building dependencies
- python3 setup.py sdist bdist_wheel # Build the source distribution and wheel
- |
release_notes_file=bkstools/release.py
latest_release_note_txt=$(python3 - << EOF
found_start=False
found_first=False
found_end=False
with open( r"${release_notes_file}", "r", encoding="latin-1" ) as inputfile:
for l in inputfile.readlines():
if ( not found_start and "From newest to oldest" in l ):
found_start = True
continue
if ( found_start and not found_end and not found_first and r"- \b" in l ):
found_first = True
start_column = l.find( "-" )
elif ( found_start and not found_end and found_first and r"- \b" in l ):
found_end = True
if ( not found_end and found_first ):
ll = l[start_column:-1].replace( '"', r'\"' )
if ( ll.startswith( "-" ) ):
print( ll )
else:
print( " " + ll)
EOF
)
latest_release_note=$(echo -e "${latest_release_note_txt}" \
| python3 -m markdown --output_format=xhtml \
| tr '\r' ' ' | tr '\n' ' ' )
#echo "latest_release_note_txt=${latest_release_note_txt}" # for debugging
#echo "latest_release_note=${latest_release_note}" # for debugging
#SaveVariables build.env latest_release_note
echo "latest_release_note=${latest_release_note}" >> "build.env"
#---
BKSTOOLS_PROJECT_RELEASE=$(cd bkstools ; python3 -c "import release; print(release.PROJECT_RELEASE)")
echo "${CI_JOB_NAME}_CI_JOB_ID=\"${CI_JOB_ID}\"" >> "build.env"
echo "BKSTOOLS_PROJECT_RELEASE=\"${BKSTOOLS_PROJECT_RELEASE}\"" >> "build.env"
echo "gitlab_host=\"gitlab-test.cloud.schunk.com\"" >> "build.env"
artifacts:
paths:
- dist/*.whl
- dist/*.tar.gz
reports:
dotenv: build.env
#--------------------------------------------------------------------
release_job:
stage: release
rules:
- if: $CI_COMMIT_TAG # Run this job when a tag is created only
script:
- |
#Log 'Running release_job to create release in GitLab->Project->Releases'
echo 'Running release_job to create release in GitLab->Project->Releases'
# (Remark: no variable defined here can be used in the release.description below!)
release:
name: 'Release $CI_COMMIT_TAG'
description: "<h3> Description </h3>
<p> Automatically generated release for git tag <b>${CI_COMMIT_TAG}</b>. </p>
<h3> Branches: </h3>
<ul>
<li>BKSTools: <b>${CI_COMMIT_REF_NAME}</b> (${CI_COMMIT_SHA})</li>
</ul>
<h3> Release note: </h3>
${latest_release_note}
<h3> Artifacts: </h3>
<ul>
<li> Created by
<a href='https://${gitlab_host}/python_stuff/BKSTools/-/pipelines/${CI_PIPELINE_ID}' >
pipeline ${CI_PIPELINE_ID}
</a>
</li>
<li> <a href='https://${gitlab_host}/python_stuff/BKSTools/-/jobs/${build_CI_JOB_ID}' title='view CI job results in GitLab'>
<img src='https://${gitlab_host}/uploads/-/system/project/avatar/73/BKSTools.png' width=32 height=32>
BKSTools v${BKSTOOLS_PROJECT_RELEASE}
</a> -
<a href='https://${gitlab_host}/python_stuff/BKSTools/-/jobs/${build_CI_JOB_ID}/artifacts/raw/dist/bkstools-${BKSTOOLS_PROJECT_RELEASE}-py3-none-any.whl' title='download Python wheel for installation with pip, the Python paket manager'>
[ ⇩ ]
</a>
</li>
</ul>"
tag_name: '$CI_COMMIT_TAG'
ref: '$CI_COMMIT_TAG'
dependencies:
- build