Skip to content

Commit 8fefd59

Browse files
committed
build: Add git tag / package version check in CircleCI config, fix workflows regex
1 parent e06d8d9 commit 8fefd59

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

.circleci/config.yml

+36-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# PowerAPI CircleCI 2.0 configuration file
2-
version: 2
1+
# PowerAPI CircleCI configuration file
2+
version: 2.1
33
jobs:
44
build:
55
docker:
@@ -43,38 +43,63 @@ jobs:
4343
publish-release:
4444
docker:
4545
- image: circleci/python:3.7
46+
4647
steps:
4748
- checkout
4849

4950
- run:
50-
name: create venv and verify git tag vs. version
51+
name: check git tag with package version
52+
command: |
53+
check_git_tag_with_package_version () {
54+
tag_version=${CIRCLE_TAG#*v}
55+
pkg_version=$(python3 -c "import powerapi; print(powerapi.__version__)" 2>/dev/null || echo "error")
56+
if [ "$tag_version" = "$pkg_version" ]; then
57+
return 0
58+
fi
59+
return 1
60+
}
61+
check_git_tag_with_package_version
62+
63+
- run:
64+
name: prepare environment
5165
command: |
5266
python3 -m venv venv
5367
. venv/bin/activate
5468
pip install --upgrade pip
5569
pip install --upgrade twine
56-
python setup.py verify
5770
5871
- run:
59-
name: generate package and upload it
72+
name: init .pypirc
73+
command: |
74+
echo -e "[pypi]" >> ~/.pypirc
75+
echo -e "username = powerapi" >> ~/.pypirc
76+
echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
77+
78+
- run:
79+
name: generate package
6080
command: |
6181
python3 setup.py sdist bdist_wheel
62-
. venv/bin/activate
63-
twine upload -u powerapi -p $PYPI_PASSWORD dist/*
64-
6582
83+
- run:
84+
name: upload to pypi
85+
command: |
86+
. venv/bin/activate
87+
twine upload dist/*
6688
6789
workflows:
6890
version: 2
69-
main:
91+
build-n-publish:
7092
jobs:
7193
- build:
7294
filters:
7395
tags:
74-
ignore: /v.*/
96+
only: /.*/
97+
7598
- publish-release:
99+
requires:
100+
- build
76101
filters:
77102
branches:
78103
ignore: /.*/
79104
tags:
80-
only: /v.*/
105+
only: /^v.*/

0 commit comments

Comments
 (0)