-
Notifications
You must be signed in to change notification settings - Fork 258
41 lines (39 loc) · 1.24 KB
/
publish-to-pypi.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
name: Publish Python 🐍 distributions 📦 to PyPI
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
version:
description: 'Version to publish'
required: true
default: ''
jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write # OIDC for PyPi Trusted Publisher feature
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Install pypa/setuptools
run: python -m pip install wheel setuptools
- name: Extract tag name or use manual input
id: get_version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
fi
- name: Update version in setup.py
run: sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.get_version.outputs.VERSION }}/g" setup.py
- name: Build a binary wheel
run: python setup.py sdist bdist_wheel
- name: Publish distribution 📦 to PyPI
uses: pypa/[email protected]