-
Notifications
You must be signed in to change notification settings - Fork 1
34 lines (34 loc) · 1.21 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
name: Publish Python 🐍 distributions 📦 to PyPI
on:
release:
types:
- published
jobs:
publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Set Version
id: version
run: |
if [[ "${{ github.event_name }}" == "release" && "${{ github.event.action }}" == "published" ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
else
TIMESTAMP=$(date +'%Y%m%d%H%M%S')
echo "VERSION=0.0.dev${TIMESTAMP}" >> $GITHUB_ENV
fi
- name: Build package
run: python setup.py sdist
env:
VERSION: ${{ env.VERSION }}
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1