-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (63 loc) · 2.05 KB
/
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
67
68
69
70
71
72
73
74
name: Publish to PyPI
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+' # Matches semantic versioning tags
- '[0-9]+.[0-9]+.[0-9]+-test.*' # Test releases
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.12']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies and run CI
run: |
python -m pip install --upgrade pip
pip install build pytest pytest-cov setuptools_scm
make ci
publish:
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Verify tag version matches package version
run: |
python -m pip install --upgrade pip
pip install build pytest pytest-cov setuptools_scm twine
PACKAGE_VERSION=$(python -m setuptools_scm)
TAG_VERSION=${GITHUB_REF#refs/tags/} # Remove 'refs/tags/' prefix
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
echo "Package version ($PACKAGE_VERSION) does not match tag version ($TAG_VERSION)"
exit 1
fi
- name: Publish to TestPyPI
if: contains(github.ref, 'test')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: make all && twine upload --repository testpypi dist/*
- name: Publish to PyPI
if: "!contains(github.ref, 'test')"
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: make dist
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: dist/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}