-
Notifications
You must be signed in to change notification settings - Fork 4
56 lines (47 loc) · 1.46 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Publish to PyPi
on:
workflow_run:
workflows: ["Run Tests"]
branches: [main]
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
environment: release
permissions:
id-token: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Python
id: setup_python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
id: install_deps
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Build
id: build
run: |
python -m build
- name: Check if version has changed
id: check_version
run: |
LOCAL_VERSION=$(python setup.py --version)
PYPI_VERSION=$(curl -s https://pypi.org/pypi/paddle-python-sdk/json | jq -r '.info.version')
if [ "$LOCAL_VERSION" != "$PYPI_VERSION" ]; then
echo "Version has changed. Current version: $LOCAL_VERSION"
echo "should_publish=true" >> $GITHUB_ENV
else
echo "Version has not changed. Skipping publish."
echo "should_publish=false" >> $GITHUB_ENV
fi
- name: Publish to PyPi
id: publish
if: env.should_publish == 'true'
uses: pypa/gh-action-pypi-publish@release/v1