Skip to content

Commit 7ab26ea

Browse files
authored
Fix and update python_publish.yml (#1217)
* Update python_publish.yml Following [this guide](https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/) * Update python_publish.yml Install build prerequisites * Use default access token for rate limiting Taken from example at https://github.com/arduino/setup-protoc
1 parent 4fb8c06 commit 7ab26ea

File tree

1 file changed

+67
-29
lines changed

1 file changed

+67
-29
lines changed

.github/workflows/python_publish.yml

Lines changed: 67 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,43 +26,81 @@ on:
2626
release:
2727
types: [published]
2828

29-
permissions:
30-
contents: read
31-
3229
jobs:
33-
deploy:
34-
30+
build:
31+
name: Build OpenHTF distribution
3532
runs-on: ubuntu-latest
3633

3734
steps:
3835
- uses: actions/checkout@v4
36+
with:
37+
persist-credentials: false
3938
- name: Set up Python
4039
uses: actions/setup-python@v5
4140
with:
42-
python-version: '3.7'
43-
- name: Install dependencies
41+
python-version: '3.13'
42+
- name: Install pypa/build
43+
run: >-
44+
python3 -m
45+
pip install
46+
build
47+
--user
48+
- name: Install build prerequisites
4449
run: |
45-
python -m pip install --upgrade pip
46-
python -m pip install tox tox-gh-actions
47-
pip install coveralls
48-
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.6/protoc-21.6-linux-x86_64.zip
49-
unzip protoc-21.6-linux-x86_64.zip
50-
sudo cp bin/protoc /usr/bin/protoc && sudo chmod 777 /usr/bin/protoc
51-
sudo cp -r include/. /usr/include && sudo chmod -R +r /usr/include/google
52-
protoc --version
53-
sudo apt-get install -y libusb-1.0-0-dev libprotobuf-dev swig
54-
pip install build
55-
- name: Build package
56-
run: python -m build
57-
- name: Publish distribution to Test PyPI
58-
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc
50+
sudo apt-get install -y libusb-1.0-0-dev libprotobuf-dev swig libevent-dev
51+
- name: Setup protoc
52+
uses: arduino/setup-protoc@v3
53+
with:
54+
repo-token: ${{ secrets.GITHUB_TOKEN }}
55+
- name: Build a binary wheel and source tarball
56+
run: python3 -m build
57+
- name: Store the distribution packages
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: python-package-distributions
61+
path: dist/
62+
63+
publish-to-pypi:
64+
name: Publish OpenHTF distribution to PyPI
65+
if: startsWith(github.ref, 'refs/tags')
66+
needs:
67+
- build
68+
runs-on: ubuntu-latest
69+
environment:
70+
name: pypi
71+
url: https://pypi.org/p/openhtf
72+
permissions:
73+
id-token: write
74+
steps:
75+
- name: Download all the dists
76+
uses: actions/download-artifact@v4
77+
with:
78+
name: python-package-distributions
79+
path: dist/
80+
- name: Publish distribution to PyPI
81+
uses: pypa/gh-action-pypi-publish@release/v1
82+
83+
publish-to-testpypi:
84+
name: Publish OpenHTF distribution to TestPyPI
85+
needs:
86+
- build
87+
runs-on: ubuntu-latest
88+
89+
environment:
90+
name: testpypi
91+
url: https://test.pypi.org/p/openhtf
92+
93+
permissions:
94+
id-token: write
95+
96+
steps:
97+
- name: Download all the dists
98+
uses: actions/download-artifact@v4
5999
with:
60-
password: ${{ secrets.TESTPYPI_PUBLISH_PASSWORD }}
61-
repository_url: https://test.pypi.org/legacy/
62-
- name: Publish package to PyPI
63-
if: startsWith(github.ref, 'refs/tags')
64-
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc
100+
name: python-package-distributions
101+
path: dist/
102+
- name: Publish distribution to TestPyPI
103+
uses: pypa/gh-action-pypi-publish@release/v1
65104
with:
66-
user: __token__
67-
password: ${{ secrets.PYPI_PUBLISH_PASSWORD }}
68-
skip_existing: true
105+
repository-url: https://test.pypi.org/legacy/
106+

0 commit comments

Comments
 (0)