1+ name : Publish Package
2+
3+ on :
4+ push :
5+ tags : ["v*.*.*"]
6+ paths-ignore :
7+ - ' **.md'
8+ - ' **.svg'
9+ - ' **.jpg'
10+ - ' **.png'
11+
12+ permissions :
13+ contents : read
14+
15+ jobs :
16+ build :
17+ runs-on : ubuntu-latest
18+ environment : test
19+ steps :
20+ - name : Checkout repo
21+ uses : actions/checkout@v3
22+
23+ - name : Set short SHA
24+ run : echo "IMAGE_TAG=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_ENV
25+
26+ - name : Check for git tag version
27+ id : get_tag
28+ run : |
29+ TAG=$(git describe --tags --exact-match 2> /dev/null || echo "")
30+ if [[ -n "$TAG" ]]; then
31+ echo "IMAGE_TAG=${TAG}" >> $GITHUB_ENV
32+ fi
33+
34+ - name : Set up Python
35+ uses : actions/setup-python@v2
36+ with :
37+ python-version : 3.x
38+
39+ - name : Install Dependencies
40+ run : pip install -r requirements.txt
41+
42+ - name : Run Version Verification
43+ run : |
44+ python -c "from config import CONFIG; import os; current_tag = os.getenv('IMAGE_TAG'); assert CONFIG.VERSION == current_tag, 'Version mismatch: Expected {} but got {}'.format(CONFIG.VERSION, current_tag); print('Version matched!')"
45+
46+
47+ - name : Install Twine
48+ run : |
49+ python -m pip install --upgrade pip
50+ pip install twine
51+
52+ - name : Run Tests
53+ env :
54+ CLIENT_TEST_ENV : ${{ secrets.CLIENT_TEST_ENV }}
55+ run : |
56+ echo "$CLIENT_TEST_ENV" > .env
57+ bash ./test/run_test.sh
58+
59+ - name : Build Package
60+ run : python setup.py sdist bdist_wheel
61+
62+ - name : Publish Package
63+ run : twine upload dist/*
64+ env :
65+ TWINE_USERNAME : ${{ secrets.PYPI_USERNAME }}
66+ TWINE_PASSWORD : ${{ secrets.PYPI_PASSWORD }}
67+
68+ - name : Create Release
69+ uses : actions/create-release@v1
70+ env :
71+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
72+ with :
73+ tag_name : ${{ env.IMAGE_TAG }}
74+ release_name : Release ${{ env.IMAGE_TAG }}
75+ body : |
76+ This is the release for version ${{ env.IMAGE_TAG }}.
77+ draft : false
78+ prerelease : false
0 commit comments