Skip to content

Commit 9547152

Browse files
authored
Merge pull request #201 from ymyzk/pypi-publish
Configure trusted publishing to PyPI
2 parents 6709276 + 3c35a4a commit 9547152

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

.github/workflows/packaging.yml

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,58 @@ on:
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
1615
strategy:
1716
matrix:
1817
python-version: [3.13]
19-
2018
steps:
2119
- uses: actions/checkout@v3
2220
- name: Set up Python ${{ matrix.python-version }}
2321
uses: actions/setup-python@v4
2422
with:
2523
python-version: ${{ matrix.python-version }}
2624
- name: Install dependencies
27-
run: |
28-
python -m pip install --upgrade build twine
25+
run: python -m pip install --upgrade build
2926
- name: Create packages
3027
run: python -m build
31-
- name: Run twine check
32-
run: twine check dist/*
3328
- uses: actions/upload-artifact@v4
3429
with:
3530
name: tox-gh-actions-dist
3631
path: dist
32+
33+
pypi-publish:
34+
needs:
35+
- build
36+
runs-on: ubuntu-latest
37+
if: github.event_name == 'release'
38+
environment: pypi
39+
permissions:
40+
id-token: write # Required for using pypa/gh-actions-pypi-publish
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: actions/download-artifact@v4
44+
with:
45+
name: tox-gh-actions-dist
46+
path: dist
47+
- name: Publish package distributions to PyPI
48+
uses: pypa/gh-action-pypi-publish@release/v1
49+
50+
github-release:
51+
needs:
52+
- build
53+
runs-on: ubuntu-latest
54+
if: github.event_name == 'release'
55+
environment: release
56+
permissions:
57+
contents: write # Required for uploading artifacts to GitHub release
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: actions/download-artifact@v4
61+
with:
62+
name: tox-gh-actions-dist
63+
path: dist
64+
- name: Upload artifacts to GitHub release
65+
working-directory: ./dist
66+
env:
67+
GH_TOKEN: ${{ github.token }}
68+
run: gh release upload "${{ github.event.release.tag_name }}" ./*

0 commit comments

Comments
 (0)