-
Notifications
You must be signed in to change notification settings - Fork 3
45 lines (38 loc) · 1.31 KB
/
push_pypi.yml
File metadata and controls
45 lines (38 loc) · 1.31 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
name: Push to PyPI on bump version
on:
push:
branches:
- main
jobs:
build:
name: Build distribution 📦
environment: push_pypi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v7
with:
python-version: '3.12'
- name: Check if version bumped
id: check_version
run: |
current_version=$(uv version --short)
pypi_version=$(pip index versions mmirage --disable-pip-version-check | grep "Available versions:" | sed -E 's/.*Available versions: ([^,]+).*/\1/')
if [ "$current_version" = "$pypi_version" ]; then
echo "Version not bumped. Exiting."
echo "version_changed=0" >> $GITHUB_OUTPUT
else
echo "Version bumped from $pypi_version to $current_version."
echo "version_changed=1" >> $GITHUB_OUTPUT
fi
- name: Build package
if: ${{ steps.check_version.outputs.version_changed == '1' }}
run: |
uv build
- name: Publish to PyPI
if: ${{ steps.check_version.outputs.version_changed == '1' }}
run: |
uv publish --token ${{ secrets.PYPI_TOKEN }}