Skip to content

Commit 0c52b57

Browse files
committed
Add deploy script
1 parent bd24058 commit 0c52b57

File tree

4 files changed

+43
-12
lines changed

4 files changed

+43
-12
lines changed

Jenkinsfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ pipeline {
105105
environment {
106106
TWINE_REPOSITORY_URL = 'http://gitea.lan:3000/api/packages/root/pypi'
107107
TWINE_CREDENTIALS = credentials('gitea')
108+
TWINE_USERNAME = TWINE_CREDENTIALS_USR
109+
TWINE_PASSWORD = TWINE_CREDENTIALS_PSW
108110
}
109111
steps {
110-
sh 'twine upload --user $TWINE_CREDENTIALS_USR --password $TWINE_CREDENTIALS_PSW dist/*'
112+
sh './tools/deploy-package.sh'
111113
}
112114
}
113115
}

Jenkinsfile.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ node {
8989
passwordVariable: 'TWINE_PASSWORD'
9090
)
9191
]) {
92-
sh 'twine upload dist/*'
92+
sh './tools/deploy-package.sh'
9393
}
9494
}
9595
}

README.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ The Python package is based on the following toolchain:
3636
├── dist Reserved folder for build artifacts
3737
├── docs Sphinx documentation
3838
├── src Python package source code
39-
└── tests Python tests
39+
├── tests Python tests
40+
└── tools Scripts
41+
4042
```
4143

4244
## Build, test and deploy instructions
@@ -52,37 +54,53 @@ Note: the Python virtual environment can be removed using `pipenv --rm`.
5254

5355
**IMPORTANT:** all of the following commands have to be executed within the Python virtual environment!
5456

55-
Build the Sphinx documentation:
57+
### Build documentation
58+
59+
Build the Sphinx documentation: `./tools/build-docs.sh`
5660

5761
```bash
5862
pip install -e . # package installation is required for Git version
5963
cd docs
6064
make html
6165
```
6266

63-
Build the Python package:
67+
### Build Python package
68+
69+
Build the Python package: `./tools/build-package.sh`
6470

6571
```bash
6672
python -m build --wheel
6773
```
6874

69-
Execute static code analysis:
75+
### Run Python linters
76+
77+
Run static code analysis: `./tools/lint-package.sh`
7078

7179
```bash
72-
flake8 src/python_training_project --format=pylint > flake8.log
73-
pylint src/python_training_project --msg-template="{path}:{line}: [{msg_id}, {obj}] {msg} ({symbol})" > pylint.log
74-
mypy src/python_training_project > mypy.log
80+
mkdir -p build
81+
flake8 src/python_training_project --format=pylint > build/flake8.txt
82+
pylint src/python_training_project --msg-template="{path}:{line}: [{msg_id}, {obj}] {msg} ({symbol})" > build/pylint.txt
83+
mypy src/python_training_project > build/mypy.txt
7584
```
7685

77-
Execute Python tests:
86+
### Run Python tests
87+
88+
Run Python tests: `./tools/test-package.sh`
7889

7990
```bash
8091
pip install -e . # package installation is required for path resolution
92+
mkdir -p build
8193
pytest
8294
```
8395

84-
Deploy the Python package:
96+
### Deploy Python package
97+
98+
Deploy the Python package: `./tools/deploy-package.sh`
8599

86100
```bash
87-
twine upload --repository-url REPOSITORY_URL --username USERNAME --password PASSWORD dist/*
101+
# Make sure to set the following environment variables
102+
# TWINE_REPOSITORY_URL
103+
# TWINE_USERNAME
104+
# TWINE_PASSWORD
105+
twine upload dist/*
88106
```

tools/deploy-package.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash -e
2+
3+
# Get Git root directory
4+
REPO_ROOT=$(git rev-parse --show-toplevel)
5+
6+
pushd "${REPO_ROOT}" 2>&1 > /dev/null
7+
8+
echo "Deploying package..."
9+
twine upload dist/*
10+
11+
popd 2>&1 > /dev/null

0 commit comments

Comments
 (0)