-
-
Notifications
You must be signed in to change notification settings - Fork 42
77 lines (76 loc) · 2.33 KB
/
ci_deploy_workflow.yml
File metadata and controls
77 lines (76 loc) · 2.33 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Generated initially using github-actions-wizard (https://github.com/cmdr2/github-actions-wizard)
name: CI Pipeline
run-name: CI Pipeline
on:
release:
types:
- created
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x
cache: pip
- name: Install dependencies
run: |-
python -m pip install --upgrade pip
pip install build wheel
- name: Build package
run: |-
python -m build
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: build
path: |-
dist
pyproject.toml
deploy_to_pypi_on_release:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
if: github.event_name == 'release' && github.event.action == 'created'
needs: build
steps:
- name: Download Artifact
uses: actions/download-artifact@v5
with:
name: build
path: .
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x
cache: pip
- run: |-
python -m pip install --upgrade pip
pip install toml requests
- name: Check PyPI version
id: check-version
run: |-
PACKAGE_NAME=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['name'])")
TOML_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
PYPI_VERSION=$(python -c "import requests; r = requests.get('https://pypi.org/pypi/$PACKAGE_NAME/json'); print(None if r.status_code == 404 else r.json()['info']['version'])")
echo "Package name: $PACKAGE_NAME"
echo "Local version: $TOML_VERSION"
echo "PyPI version: $PYPI_VERSION"
if [ "$TOML_VERSION" = "$PYPI_VERSION" ]; then
echo "Versions match. Skipping publish."
echo "publish=false" >> $GITHUB_OUTPUT
else
echo "Versions differ. Proceeding with publish."
echo "publish=true" >> $GITHUB_OUTPUT
fi
- name: Publish to PyPI
if: steps.check-version.outputs.publish == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true