-
Notifications
You must be signed in to change notification settings - Fork 5
50 lines (41 loc) · 1.45 KB
/
pypi_release.yaml
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
name: PYPI Release
on:
push:
branches:
- main
- '**'
tags:
- 'v*'
jobs:
pypi_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Source Cargo Environment
run: source $HOME/.cargo/env
- name: Build with UV
run: uvx --from build pyproject-build --installer uv
- name: Check version
id: check_version
run: |
echo $GITHUB_REF_TYPE;
if [ "$GITHUB_REF_TYPE" == "tag" ]; then
NEW_VERSION=$(echo "$GITHUB_REF" | sed -E 's/refs\/tags\/v(.+)/\1/')
CURRENT_VERSION=$(grep '^version =' pyproject.toml | sed -E 's/version = "(.*)"/\1/')
if python -c "from packaging.version import parse as parse_version; exit(0 if parse_version('$NEW_VERSION') > parse_version('$CURRENT_VERSION') else 1)"; then
echo "new_version=true" >> $GITHUB_ENV
else
echo "new_version=false" >> $GITHUB_ENV
fi
else
echo "new_version=false" >> $GITHUB_ENV
fi
- name: Publish
uses: pypa/[email protected]
if: startsWith(github.ref, 'refs/tags/v') && steps.check_version.outputs.new_version == 'true'
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN_TEMP_DOES_NOT_EXIST }}
packages_dir: ./dist/