Skip to content

Commit 8437e4f

Browse files
committed
Testing the new release workflow
1 parent f90e539 commit 8437e4f

2 files changed

Lines changed: 109 additions & 0 deletions

File tree

File renamed without changes.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Generated initially using github-actions-wizard (https://github.com/cmdr2/github-actions-wizard)
2+
3+
name: CI Pipeline
4+
run-name: CI Pipeline
5+
on:
6+
release:
7+
types:
8+
- created
9+
workflow_run:
10+
workflows:
11+
- Update PCI Database
12+
types:
13+
- completed
14+
workflow_dispatch:
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: 3.x
25+
- name: Install dependencies
26+
run: |-
27+
python -m pip install --upgrade pip
28+
pip install build wheel pytest toml requests
29+
- name: Copy tests
30+
if: steps.check-version.outputs.publish == 'true'
31+
run: |
32+
cp -R tests torchruntime/
33+
- name: Build package
34+
run: |-
35+
python -m build
36+
- name: Upload Artifact
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: build
40+
path: dist
41+
permissions:
42+
contents: read
43+
test:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Download Artifact
47+
uses: actions/download-artifact@v5
48+
with:
49+
name: build
50+
path: dist
51+
- name: Dummy Test Command
52+
run: |-
53+
echo Running tests...
54+
ls dist
55+
find .
56+
cd dist
57+
pip install *.whl
58+
59+
pip show torchruntime
60+
python -m torchruntime --help # test invocation
61+
pytest --pyargs torchruntime # run tests
62+
permissions:
63+
contents: read
64+
needs: build
65+
deploy_to_pypi:
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Download Artifact
69+
uses: actions/download-artifact@v5
70+
with:
71+
name: build
72+
path: dist
73+
- name: Set up Python
74+
uses: actions/setup-python@v4
75+
with:
76+
python-version: 3.x
77+
- name: Install dependencies
78+
run: |-
79+
python -m pip install --upgrade pip
80+
pip install build toml requests
81+
- name: Check PyPI version
82+
id: check-version
83+
run: |-
84+
TOML_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
85+
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'])")
86+
echo "Local version: $TOML_VERSION"
87+
echo "PyPI version: $PYPI_VERSION"
88+
if [ "$TOML_VERSION" = "$PYPI_VERSION" ]; then
89+
echo "Versions match. Skipping publish."
90+
echo "publish=false" >> $GITHUB_OUTPUT
91+
else
92+
echo "Versions differ. Proceeding with publish."
93+
echo "publish=true" >> $GITHUB_OUTPUT
94+
fi
95+
- name: Dummy
96+
run: |
97+
echo "Ready to deploy to PyPI"
98+
ls
99+
find .
100+
# - name: Publish to PyPI
101+
# if: steps.check-version.outputs.publish == 'true'
102+
# uses: pypa/gh-action-pypi-publish@release/v1
103+
# with:
104+
# verbose: true
105+
permissions:
106+
contents: read
107+
id-token: write
108+
if: github.event_name == 'release' && github.event.action == 'created'
109+
needs: test

0 commit comments

Comments
 (0)