Skip to content

Commit 9566fc6

Browse files
Merge pull request #2 from jentic/pypi
Pypi
2 parents 69d3da8 + 46397e7 commit 9566fc6

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# This workflow is triggered on push events but only for the arazzo_runner directory.
2+
# It builds and publishes the arazzo-runner to PyPI and TestPyPI.
3+
name: Publish Python distribution of the arazzo-runner to PyPI and TestPyPI
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
paths:
10+
- "runner/arazzo_runner/**"
11+
12+
jobs:
13+
check-version:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
version_changed: ${{ steps.check.outputs.changed }}
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Get current version
20+
id: get_version
21+
run: |
22+
VERSION=$(grep '^version =' runner/pyproject.toml | sed -E 's/version = "([^"]+)"/\1/')
23+
echo "version=$VERSION" >> $GITHUB_OUTPUT
24+
- name: Get published version from PyPI
25+
id: get_pypi_version
26+
run: |
27+
PKG_NAME=$(grep '^name =' runner/pyproject.toml | sed -E 's/name = "([^"]+)"/\1/')
28+
PYPI_VERSION=$(curl -s https://pypi.org/pypi/$PKG_NAME/json | jq -r .info.version)
29+
echo "pypi_version=$PYPI_VERSION" >> $GITHUB_OUTPUT
30+
- name: Check if version changed
31+
id: check
32+
run: |
33+
if [ "${{ steps.get_version.outputs.version }}" = "${{ steps.get_pypi_version.outputs.pypi_version }}" ]; then
34+
echo "changed=false" >> $GITHUB_OUTPUT
35+
else
36+
echo "changed=true" >> $GITHUB_OUTPUT
37+
fi
38+
39+
build:
40+
name: Build distribution 📦
41+
runs-on: ubuntu-latest
42+
needs: check-version
43+
if: needs.check-version.outputs.version_changed == 'true'
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
with:
48+
persist-credentials: false
49+
- name: Set up Python
50+
uses: actions/setup-python@v5
51+
with:
52+
python-version: "3.x"
53+
- name: Install pypa/build
54+
run: >-
55+
python3 -m
56+
pip install
57+
build
58+
--user
59+
- name: Build a binary wheel and a source tarball
60+
run: python3 -m build runner
61+
- name: Store the distribution packages
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: python-package-distributions
65+
path: runner/dist/
66+
67+
publish-to-pypi:
68+
name: >-
69+
Publish Python 🐍 distribution 📦 to PyPI
70+
needs:
71+
- build
72+
- check-version
73+
if: needs.check-version.outputs.version_changed == 'true'
74+
runs-on: ubuntu-latest
75+
environment:
76+
name: pypi
77+
url: https://pypi.org/p/arazzo-runner # Replace <package-name> with your PyPI project name
78+
permissions:
79+
id-token: write # IMPORTANT: mandatory for trusted publishing
80+
81+
steps:
82+
- name: Download all the dists
83+
uses: actions/download-artifact@v4
84+
with:
85+
name: python-package-distributions
86+
path: dist/
87+
- name: Publish distribution 📦 to PyPI
88+
uses: pypa/gh-action-pypi-publish@release/v1
89+
90+
publish-to-testpypi:
91+
name: Publish Python 🐍 distribution 📦 to TestPyPI
92+
needs:
93+
- build
94+
- check-version
95+
if: needs.check-version.outputs.version_changed == 'true'
96+
runs-on: ubuntu-latest
97+
98+
environment:
99+
name: testpypi
100+
url: https://test.pypi.org/p/arazzo-runner
101+
102+
permissions:
103+
id-token: write # IMPORTANT: mandatory for trusted publishing
104+
105+
steps:
106+
- name: Download all the dists
107+
uses: actions/download-artifact@v4
108+
with:
109+
name: python-package-distributions
110+
path: dist/
111+
- name: Publish distribution 📦 to TestPyPI
112+
uses: pypa/gh-action-pypi-publish@release/v1
113+
with:
114+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)