-
Notifications
You must be signed in to change notification settings - Fork 3
56 lines (47 loc) · 1.65 KB
/
Copy pathpublish.yml
File metadata and controls
56 lines (47 loc) · 1.65 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
name: publish
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Extract version from tag
run: |
# Removes 'v' prefix from tag (e.g., v1.0.0 -> 1.0.0)
VERSION=${GITHUB_REF_NAME#v}
echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV
echo "Extracted version from tag: $VERSION"
- name: Check package version is PEP440 compliant
# This is only a partial PEP440 match, it just checks the major, minor
# patch, but not any optional suffixes.
run: echo "${{ env.PACKAGE_VERSION }}" | grep -P "^\d+\.\d+\.\d+.*$"
- name: Setup Python 3.11
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install pypa/build and build
run: |
pip install build
python -m build --sdist --wheel --outdir dist/ .
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
- name: Configure git
run: |
git config --local user.name "GitHub Actions Bot"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Deploy docs for release version to gh-pages branch
if: startsWith(github.ref, 'refs/tags/')
run: |
pip install .[docs]
mike deploy --push --update-aliases "${{ env.PACKAGE_VERSION }}" latest