Skip to content

Commit f09a591

Browse files
authored
Create python_publish.yml (#1064)
* Create python-publish.yml Using starter template from the marketplace; made some modifications using the packaging.python.org guide (mainly: add a test deployment workflow). * Remove tag requirement for test publishes, allowing testing of draft releases * Replace dash with underscore in filename to match convention
1 parent 0ab3ef4 commit f09a591

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# This workflow will upload a Python Package using Twine when a release is created
16+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
17+
18+
# This workflow uses actions that are not certified by GitHub.
19+
# They are provided by a third-party and are governed by
20+
# separate terms of service, privacy policy, and support
21+
# documentation.
22+
23+
name: Upload Python Package to PyPI and TestPyPI
24+
25+
on:
26+
release:
27+
types: [published]
28+
29+
permissions:
30+
contents: read
31+
32+
jobs:
33+
deploy:
34+
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- uses: actions/checkout@v3
39+
- name: Set up Python
40+
uses: actions/setup-python@v3
41+
with:
42+
python-version: '3.7'
43+
- name: Install dependencies
44+
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@27b31702a0e7fc50959f5ad993c78deac1bdfc29
59+
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@27b31702a0e7fc50959f5ad993c78deac1bdfc29
65+
with:
66+
user: __token__
67+
password: ${{ secrets.PYPI_PUBLISH_PASSWORD }}
68+
skip_existing: true

0 commit comments

Comments
 (0)