-
Notifications
You must be signed in to change notification settings - Fork 4
66 lines (63 loc) · 1.82 KB
/
test-build-publish.yml
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
---
name: Test and Optionally Publish
on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
test:
name: Check code against linter/unit tests
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install tox tox-gh-actions
- name: Test with Tox
run: tox
version-check:
name: Verify that version was updated
runs-on: ubuntu-22.04
if: github.ref != 'refs/heads/master'
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- name: Check version updated
run: bash bin/versionCheck.sh ${GITHUB_BASE_REF##*/} "true"
build-publish:
name: Build and publish Python distributions
runs-on: ubuntu-22.04
needs: [test]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@master
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Update GIT_HASH
run: sed --expression "s|GIT_HASH|$GITHUB_SHA|g" --in-place **/version.py
- name: Build tarball
run: python setup.py sdist
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}