Skip to content

Commit 77bd851

Browse files
committed
Add workflow to publish to PyPI
1 parent fb9c2f2 commit 77bd851

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

.github/workflows/publish-pypi.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish to PyPI
2+
3+
# Publish to PyPI when a tag is pushed
4+
on:
5+
push:
6+
tags:
7+
- 'ckanapi-**'
8+
9+
jobs:
10+
build:
11+
if: github.repository == 'ckan/ckanapi'
12+
name: Build distribution
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.11"
20+
- name: Install pypa/build
21+
run: python3 -m pip install build --user
22+
- name: Build a binary wheel and a source tarball
23+
run: python3 -m build
24+
- name: Store the distribution packages
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: python-package-distributions
28+
path: dist/
29+
30+
publish-to-pypi:
31+
name: Publish Python distribution on PyPI
32+
needs:
33+
- build
34+
runs-on: ubuntu-latest
35+
environment:
36+
name: pypi
37+
url: https://pypi.org/p/ckanapi
38+
permissions:
39+
id-token: write
40+
steps:
41+
- name: Download all the dists
42+
uses: actions/download-artifact@v4
43+
with:
44+
name: python-package-distributions
45+
path: dist/
46+
- name: Publish distribution to PyPI
47+
uses: pypa/gh-action-pypi-publish@release/v1
48+
49+
publishSkipped:
50+
if: github.repository != 'ckan/ckanapi'
51+
runs-on: ubuntu-latest
52+
steps:
53+
- run: |
54+
echo "## Skipping PyPI publish on downstream repository" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)