Skip to content

Commit c66f9d3

Browse files
committed
ci: use trusted publishing for release
See https://docs.pypi.org/trusted-publishers/. Loosely based on pytest CI.
1 parent 30602a2 commit c66f9d3

File tree

2 files changed

+43
-33
lines changed

2 files changed

+43
-33
lines changed

.github/workflows/deploy.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: deploy
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
# Set permissions at the job level.
9+
permissions: {}
10+
11+
jobs:
12+
package:
13+
runs-on: ubuntu-22.04
14+
timeout-minutes: 10
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
persist-credentials: false
20+
21+
- name: Build and Check Package
22+
uses: hynek/build-and-inspect-python-package@2dbbf2b252d3a3c7cec7a810e3ed5983bd17b13a # v2.8.0
23+
24+
deploy:
25+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && github.repository == 'pytest-dev/pytest-django'
26+
needs: [package]
27+
runs-on: ubuntu-22.04
28+
environment: deploy
29+
timeout-minutes: 15
30+
permissions:
31+
contents: read
32+
# For trusted publishing.
33+
id-token: write
34+
35+
steps:
36+
- name: Download Package
37+
uses: actions/download-artifact@v4
38+
with:
39+
name: Packages
40+
path: dist
41+
42+
- name: Publish package
43+
uses: pypa/gh-action-pypi-publish@8a08d616893759ef8e1aa1f2785787c0b97e20d6 # v1.10.0

.github/workflows/main.yml

-33
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
tags:
8-
- "*"
97
pull_request:
108
branches:
119
- main
@@ -126,34 +124,3 @@ jobs:
126124
- name: pypy3-dj32-postgres
127125
python: 'pypy3.9'
128126
allow_failure: false
129-
130-
deploy:
131-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && github.repository == 'pytest-dev/pytest-django'
132-
runs-on: ubuntu-22.04
133-
timeout-minutes: 15
134-
permissions:
135-
contents: read
136-
137-
steps:
138-
- uses: actions/checkout@v4
139-
with:
140-
fetch-depth: 0
141-
persist-credentials: false
142-
143-
- uses: actions/setup-python@v5
144-
with:
145-
python-version: '3.12'
146-
147-
- name: Install dependencies
148-
run: |
149-
python -m pip install --upgrade pip
150-
pip install --upgrade build
151-
152-
- name: Build package
153-
run: python -m build
154-
155-
- name: Publish package
156-
uses: pypa/gh-action-pypi-publish@8a08d616893759ef8e1aa1f2785787c0b97e20d6 # v1.10.0
157-
with:
158-
user: __token__
159-
password: ${{ secrets.pypi_token }}

0 commit comments

Comments
 (0)