1+ ---
2+
3+ name : Publish release
4+
5+ on :
6+ push :
7+ tags :
8+ # Run when a tag is pushed with a valid semantic version number
9+ - ' v[0-9]+.[0-9]+.[0-9]+'
10+
11+ jobs :
12+ build :
13+ name : Build distribution
14+ runs-on : ubuntu-latest
15+ steps :
16+
17+ - name : Checkout code
18+ uses : actions/checkout@v3
19+ with :
20+ fetch-depth : 0
21+
22+ - name : Set up Python
23+ uses : actions/setup-python@v2
24+ with :
25+ python-version : ' 3.9'
26+
27+ - name : Install Poetry
28+ run : |
29+ python -m pip install --upgrade pip
30+ pip install poetry
31+ pip install poetry-dynamic-versioning
32+
33+ - name : Build
34+ run : |
35+ poetry build
36+
37+ - name : Save build artifacts
38+ uses : actions/upload-artifact@v2
39+ with :
40+ name : dist-artifact
41+ path : dist/
42+
43+ test :
44+ name : Test
45+ needs : build
46+ runs-on : ubuntu-latest
47+ steps :
48+
49+ - name : Set up Python
50+ uses : actions/setup-python@v2
51+ with :
52+ python-version : ' 3.9'
53+
54+ - name : Checkout code
55+ uses : actions/checkout@v3
56+ with :
57+ fetch-depth : 0
58+
59+ - name : Get build artifacts
60+ uses : actions/download-artifact@v2
61+ with :
62+ name : dist-artifact
63+ path : dist/
64+
65+ - name : Install from build
66+ run : |
67+ python -m pip install --upgrade pip
68+ pip install pytest-mock
69+ pip install etpproto --pre --target=dist --find-links=dist/
70+
71+ - name : Copy tests and example data to dist folder for testing against artifacts
72+ run : |
73+ cp -R tests dist/
74+ # cp -R example_data dist/
75+
76+ - name : Run tests
77+ run : pytest dist/tests
78+
79+ publish :
80+ name : Publish to PyPI
81+ needs : [build, test]
82+ runs-on : ubuntu-latest
83+ steps :
84+
85+ - name : Set up Python
86+ uses : actions/setup-python@v2
87+ with :
88+ python-version : ' 3.9'
89+
90+ # Retrieve the code and GIT history so that poetry-dynamic-versioning knows which version to upload
91+ - name : Checkout code
92+ uses : actions/checkout@v3
93+ with :
94+ fetch-depth : 0
95+
96+ - name : Get build artifacts
97+ uses : actions/download-artifact@v2
98+ with :
99+ name : dist-artifact
100+ path : dist/
101+
102+ - name : Install Poetry
103+ run : |
104+ python -m pip install --upgrade pip
105+ pip install poetry
106+ pip install poetry-dynamic-versioning
107+
108+ - name : Upload to PyPI
109+ run : |
110+ poetry config repositories.test https://test.pypi.org/legacy/
111+ poetry publish --username ${{ secrets.POETRY_PYPI_TOKEN_USERNAME}} --password ${{ secrets.POETRY_PYPI_TOKEN_PASSWORD}}
0 commit comments