-
Notifications
You must be signed in to change notification settings - Fork 6
60 lines (49 loc) · 1.46 KB
/
publish-package.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
name: Upload Python Package to PyPI
on:
release:
types: [published]
jobs:
build:
name: Build and deploy
environment: test
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Set environment variables
id: set_env_variables
run: |
echo "PYTHONPATH=." >> "$GITHUB_ENV"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
pip install -r requirements.txt
- name: Test with pytest
run: |
pip install pytest
pytest test/ --doctest-modules --junitxml=junit/test-results-${{ matrix.python-version }}.xml
- name: Extract tag name
id: tag
run: echo "TAG_NAME=$(echo $GITHUB_REF | cut -d / -f 3)" >> "$GITHUB_OUTPUT"
- name: Update version in pyproject.toml
run: >-
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.PKG_VERSION }}/g" pyproject.toml
- name: Build package
run: python -m build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ vars.PYPI_URL }}
password: ${{ secrets.PYPI_API_TOKEN }}