Skip to content

Commit 312ca43

Browse files
authored
Release trustme with PyPI Trusted Publishing (#612)
1 parent a8cec28 commit 312ca43

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

Diff for: .github/workflows/release.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Release to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build:
13+
name: Build dists
14+
runs-on: ubuntu-latest
15+
environment: release
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
20+
- name: Setup python
21+
uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 # v4.6.1
22+
with:
23+
python-version: 3.x
24+
- name: Install dependencies
25+
run: python -m pip install build
26+
- name: Build dists
27+
run: python -m build
28+
- name: Upload dists
29+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
30+
with:
31+
name: "dist"
32+
path: "dist/"
33+
if-no-files-found: error
34+
retention-days: 5
35+
36+
pypi-publish:
37+
name: Upload release to PyPI
38+
if: startsWith(github.ref, 'refs/tags/')
39+
needs: [build]
40+
runs-on: ubuntu-latest
41+
environment: release
42+
permissions:
43+
contents: write # Needed to upload dists to GitHub release
44+
id-token: write # Needed for trusted publishing to PyPI
45+
46+
steps:
47+
- name: Download dists
48+
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
49+
with:
50+
name: "dist"
51+
path: "dist/"
52+
- name: Upload dists to GitHub Release
53+
env:
54+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
55+
run: gh release upload ${{ github.ref_name }} dist/* --repo ${{ github.repository }}
56+
- name: Publish package distributions to PyPI
57+
uses: pypa/gh-action-pypi-publish@f5622bde02b04381239da3573277701ceca8f6a0 # v1.8.7

0 commit comments

Comments
 (0)