Repository navigation
60 lines (51 loc) · 1.66 KB
/
Copy pathPyPI.yaml
File metadata and controls
60 lines (51 loc) · 1.66 KB
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 when a Release is Published
on:
release:
types: [published]
jobs:
pypi-publish:
name: Publish release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/viscube
permissions:
id-token: write # for PyPI Trusted Publishing
steps:
- name: Check out the release tag
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }} # e.g. v0.1.2
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build tooling
run: |
python -m pip install --upgrade pip
pip install build
- name: Verify meta version == tag
shell: bash
run: |
TAG="${{ github.event.release.tag_name }}"
VER="${TAG#v}" # strip leading 'v' if present
META_VER=$(sed -nE "s/^[[:space:]]*version[[:space:]]*=[[:space:]]*['\"]([^'\"]+)['\"]/\\1/p" viscube/__meta__.py)
echo "meta version: $META_VER"
echo "tag version: $VER"
if [ -z "$META_VER" ]; then
echo "ERROR: Could not find version= in viscube/__meta__.py"
exit 1
fi
if [ "$META_VER" != "$VER" ]; then
echo "ERROR: meta version ($META_VER) != tag ($VER)"
exit 2
fi
- name: Clean old artifacts
run: rm -rf dist/ build/
- name: Build sdist and wheel
run: python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true