Skip to content

Commit 95a32f8

Browse files
committed
Use an updated workflow file generated using github-actions-wizard
1 parent 42383d5 commit 95a32f8

1 file changed

Lines changed: 55 additions & 63 deletions

File tree

Lines changed: 55 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,75 @@
1-
name: Publish to PyPI
1+
# Generated initially using github-actions-wizard (https://github.com/cmdr2/github-actions-wizard)
22

3+
name: Publish to PyPI
4+
run-name: Deployment
35
on:
46
release:
5-
types: [created]
7+
types:
8+
- created
69
workflow_run:
710
workflows:
811
- Update PCI Database
912
types:
1013
- completed
1114
workflow_dispatch:
12-
1315
jobs:
14-
build-and-publish:
16+
deploy:
1517
runs-on: ubuntu-latest
16-
environment:
17-
name: pypi-prod
18-
url: https://pypi.org/p/torchruntime
19-
permissions:
20-
contents: read
21-
id-token: write
2218
steps:
23-
- uses: actions/checkout@v4
24-
with:
25-
ref: main
19+
- name: Checkout
20+
uses: actions/checkout@v4
2621

27-
- name: Set up Python
28-
uses: actions/setup-python@v4
29-
with:
30-
python-version: '3.x'
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: 3.x
3126

32-
- name: Install dependencies
33-
run: |
34-
python -m pip install --upgrade pip
35-
pip install build wheel pytest toml requests
27+
- name: Install dependencies
28+
run: |-
29+
python -m pip install --upgrade pip
30+
pip install build wheel pytest toml requests
3631
37-
- name: Check PyPI version
38-
id: check-version
39-
run: |
40-
# Read version from pyproject.toml
41-
TOML_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
32+
- name: Check PyPI version
33+
id: check-version
34+
run: |-
35+
TOML_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
36+
PYPI_VERSION=$(python -c "import requests; r = requests.get('https://pypi.org/pypi/torchruntime/json'); print(None if r.status_code == 404 else r.json()['info']['version'])")
37+
echo "Local version: $TOML_VERSION"
38+
echo "PyPI version: $PYPI_VERSION"
39+
if [ "$TOML_VERSION" = "$PYPI_VERSION" ]; then
40+
echo "Versions match. Skipping publish."
41+
echo "publish=false" >> $GITHUB_OUTPUT
42+
else
43+
echo "Versions differ. Proceeding with publish."
44+
echo "publish=true" >> $GITHUB_OUTPUT
45+
fi
4246
43-
# Get latest PyPI version using PyPI JSON API
44-
PYPI_VERSION=$(python -c "import requests; print(requests.get('https://pypi.org/pypi/torchruntime/json').json()['info']['version'])")
47+
- name: Copy tests
48+
if: steps.check-version.outputs.publish == 'true'
49+
run: |
50+
cp -R tests torchruntime/
4551
46-
echo "Local version: $TOML_VERSION"
47-
echo "PyPI version: $PYPI_VERSION"
52+
- name: Build package
53+
if: steps.check-version.outputs.publish == 'true'
54+
run: python -m build
4855

49-
if [ "$TOML_VERSION" = "$PYPI_VERSION" ]; then
50-
echo "Versions match. Skipping publish."
51-
echo "publish=false" >> $GITHUB_OUTPUT
52-
else
53-
echo "Versions differ. Proceeding with publish."
54-
echo "publish=true" >> $GITHUB_OUTPUT
55-
fi
56+
- name: Install and test the package
57+
if: steps.check-version.outputs.publish == 'true'
58+
run: |
59+
mkdir /tmp/install-test
60+
cp dist/*.whl /tmp/install-test
61+
cd /tmp/install-test
62+
pip install *.whl
5663
57-
- name: Copy tests
58-
if: steps.check-version.outputs.publish == 'true'
59-
run: |
60-
cp -R tests torchruntime/
64+
pip show torchruntime
65+
python -m torchruntime --help # test invocation
66+
pytest --pyargs torchruntime # run tests
6167
62-
- name: Build package
63-
if: steps.check-version.outputs.publish == 'true'
64-
run: python -m build
65-
66-
- name: Install and test the package
67-
if: steps.check-version.outputs.publish == 'true'
68-
run: |
69-
mkdir /tmp/install-test
70-
cp dist/*.whl /tmp/install-test
71-
cd /tmp/install-test
72-
pip install *.whl
73-
74-
pip show torchruntime
75-
python -m torchruntime --help # test invocation
76-
pytest --pyargs torchruntime # run tests
77-
78-
- name: Publish to PyPI
79-
if: steps.check-version.outputs.publish == 'true'
80-
uses: pypa/gh-action-pypi-publish@release/v1
81-
with:
82-
# repository-url: https://test.pypi.org/legacy/
83-
verbose: true
68+
- name: Publish to PyPI
69+
if: steps.check-version.outputs.publish == 'true'
70+
uses: pypa/gh-action-pypi-publish@release/v1
71+
with:
72+
verbose: true
73+
permissions:
74+
contents: read
75+
id-token: write

0 commit comments

Comments
 (0)