-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (82 loc) · 2.56 KB
/
python-publish.yaml
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
# This workflow will upload a Python Package using Twine when a release is created
name: Upload Python Package
on:
push:
branches:
- 'main'
paths-ignore:
- "*.md"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Remove unnecessary files
run: |
if [ -d opentab/devel ]; then
rm -r opentab/devel;
fi
if [ -f Makefile ]; then
rm Makefile;
fi
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
pip install jinja2-cli
pip install opentab
pip install pyyaml==5.4
pip install jinja2-cli[yaml]
- name: Take new version
run: |
VERSION=$(pip list | grep "opentab" | tr "opentab " " ")
IFS="." read -r -a version_digits <<<"$VERSION"
commit_message=$(git log --reverse -n 1 --pretty="%f")
if [[ "$commit_message" == "Stable"* ]];
then
first_digit=${version_digits[0]}
version_digits[1]=0
version_digits[2]=0
first_digit=$(expr $first_digit + "1")
while [ $? -eq 2 ]
do
first_digit=$(expr $first_digit + "1")
done
version_digits[0]=$first_digit
fi
if [[ "$commit_message" == "Major"* ]];
then
second_digit=${version_digits[1]}
version_digits[2]=0
second_digit=$(expr $second_digit + "1")
version_digits[1]=$second_digit
fi
if [[ "$commit_message" == "Minor"* ]];
then
third_digit=${version_digits[2]}
third_digit=$(expr $third_digit + "1")
version_digits[2]=$third_digit
fi
echo "VERSION=$(echo ${version_digits[*]} | tr " " ".")" >> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
pip install jinja2-cli
- name: Generate the setup.cfg with new version
run: |
echo 'version:' $VERSION >> version.yaml
jinja2 setup.cfg.j2 version.yaml --format=yaml >> setup.cfg
rm setup.cfg.j2 version.yaml
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}