-
Notifications
You must be signed in to change notification settings - Fork 2
39 lines (36 loc) · 1.08 KB
/
pypi-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
name: Upload Python Package
on:
release:
types: [published]
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/foamlib
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install needed packages
run: |
pip install --upgrade setuptools build
- name: Check version number
run: |
TAG="${GITHUB_REF#refs/tags/}"
VERSION_FROM_TAG="${TAG#v}"
PACKAGE_VERSION=$(python -c 'import setuptools; setuptools.setup()' --version)
if [ "$PACKAGE_VERSION" != "$VERSION_FROM_TAG" ]; then
echo "::error title=Version mismatch::$PACKAGE_VERSION (package version) != $VERSION_FROM_TAG (version from tag)"
exit
fi
- name: Build
run: |
python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1