Skip to content

Commit ee96b8c

Browse files
authored
Merge pull request #110 from livechat/trusted-publishers-pypi-deploy-auth
Update publish-to-pypi.yml workflow after enabling trusted publishers…
2 parents 0cb6fb8 + 79f4b32 commit ee96b8c

File tree

2 files changed

+74
-34
lines changed

2 files changed

+74
-34
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 69 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,77 @@
1-
# For more information see: https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2-
3-
name: Publish Python 🐍 distributions 📦 to TestPyPI and PyPI
1+
name: Publish Python distribution
42

53
on:
6-
release:
7-
types: [published]
8-
9-
jobs:
10-
deploy:
4+
push:
5+
branches:
6+
- master
117

8+
jobs:
9+
build:
10+
name: Build distribution
1211
runs-on: ubuntu-latest
1312

1413
steps:
15-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1615
- name: Set up Python
17-
uses: actions/setup-python@v2
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: "3.8"
19+
- name: Install pypa/build
20+
run: >-
21+
python3 -m
22+
pip install
23+
build
24+
--user
25+
- name: Build a binary wheel and a source tarball
26+
run: python3 -m build
27+
- name: Store the distribution packages
28+
uses: actions/upload-artifact@v3
29+
with:
30+
name: python-package-distributions
31+
path: dist/
32+
33+
publish-to-pypi:
34+
name: Publish to PyPI
35+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
36+
needs:
37+
- build
38+
runs-on: ubuntu-latest
39+
environment:
40+
name: pypi
41+
url: https://pypi.org/p/lc-sdk-python
42+
permissions:
43+
id-token: write # IMPORTANT: mandatory for trusted publishing
44+
45+
steps:
46+
- name: Download all the dists
47+
uses: actions/download-artifact@v3
48+
with:
49+
name: python-package-distributions
50+
path: dist/
51+
- name: Publish to PyPI
52+
uses: pypa/gh-action-pypi-publish@release/v1
53+
54+
publish-to-testpypi:
55+
name: Publish to TestPyPI
56+
needs:
57+
- build
58+
runs-on: ubuntu-latest
59+
60+
environment:
61+
name: testpypi
62+
url: https://test.pypi.org/p/lc-sdk-python
63+
64+
permissions:
65+
id-token: write # IMPORTANT: mandatory for trusted publishing
66+
67+
steps:
68+
- name: Download all the dists
69+
uses: actions/download-artifact@v3
70+
with:
71+
name: python-package-distributions
72+
path: dist/
73+
- name: Publish to TestPyPI
74+
uses: pypa/gh-action-pypi-publish@release/v1
1875
with:
19-
python-version: 3.8
20-
- name: Install dependencies
21-
run: |
22-
python -m pip install --upgrade pip
23-
pip install setuptools wheel twine
24-
- name: Build and publish to TestPyPI
25-
env:
26-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
27-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
28-
run: |
29-
python setup.py sdist bdist_wheel
30-
twine upload --repository testpypi dist/*
31-
- name: Build and publish to PyPI
32-
env:
33-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
34-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
35-
run: |
36-
python setup.py sdist bdist_wheel
37-
twine upload dist/*
38-
76+
skip-existing: true
77+
repository-url: https://test.pypi.org/legacy/

.github/workflows/python-app.yml renamed to .github/workflows/quality-checkup.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
# This workflow will install Python dependencies, run tests and lint with a single version of Python
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: lc-sdk-python tests
4+
name: Quality checkup
55

66
on:
77
push:
88
branches: [ master ]
99
pull_request:
1010
jobs:
1111
build:
12+
name: Setup Python, install dependencies, run linter and tests
1213
runs-on: ubuntu-latest
1314
steps:
14-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1516
- name: Set up Python 3.8
16-
uses: actions/setup-python@v2
17+
uses: actions/setup-python@v4
1718
with:
18-
python-version: 3.8
19+
python-version: "3.8"
1920
- name: Install dependencies
2021
run: |
2122
python -m pip install --upgrade pip

0 commit comments

Comments
 (0)