Skip to content

Commit 5a4b7db

Browse files
committed
ci(release): migrate to PyPI trusted publishing
1 parent f215a23 commit 5a4b7db

File tree

2 files changed

+82
-35
lines changed

2 files changed

+82
-35
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
pull_request:
55
push:
66
branches: [master]
7-
tags: ["*"]
87
workflow_dispatch:
98
inputs:
109
pytest_addopts:
@@ -115,37 +114,3 @@ jobs:
115114

116115
# Run tests
117116
- run: devenv test
118-
119-
publish:
120-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
121-
needs:
122-
- build
123-
- flake-check
124-
runs-on: ubuntu-latest
125-
steps:
126-
- uses: actions/checkout@v4
127-
with:
128-
fetch-depth: 0 # Needs all tags to compute dynamic version
129-
- name: Install uv
130-
uses: astral-sh/setup-uv@v5
131-
with:
132-
version: ${{ env.UV_VERSION }}
133-
enable-cache: "true"
134-
cache-suffix: "3.13"
135-
- name: Set up Python
136-
uses: actions/setup-python@v5
137-
with:
138-
python-version: "3.13"
139-
- name: Build dist
140-
run: uv build
141-
- name: Publish distribution 📦 to Test PyPI
142-
uses: pypa/gh-action-pypi-publish@master
143-
with:
144-
user: __token__
145-
password: ${{ secrets.test_pypi_token_copier }}
146-
repository_url: https://test.pypi.org/legacy/
147-
- name: Publish distribution 📦 to PyPI
148-
uses: pypa/gh-action-pypi-publish@master
149-
with:
150-
user: __token__
151-
password: ${{ secrets.pypi_token_copier }}

.github/workflows/release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches: [master]
6+
tags: ["*"]
7+
8+
env:
9+
# renovate: datasource=pypi depName=uv
10+
UV_VERSION: "0.6.13"
11+
12+
jobs:
13+
build:
14+
name: Build project for distribution
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v5
24+
with:
25+
version: ${{ env.UV_VERSION }}
26+
27+
- name: Build project for distribution
28+
run: uv build
29+
30+
- name: Upload artifact containing distribution files
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: dist
34+
path: dist/
35+
if-no-files-found: error
36+
37+
publish-test:
38+
name: Publish package distributions to test.pypi.org
39+
runs-on: ubuntu-latest
40+
needs: [build]
41+
if: startsWith(github.ref, 'refs/tags/')
42+
environment:
43+
name: pypi-test
44+
url: https://test.pypi.org/p/copier
45+
permissions:
46+
id-token: write
47+
48+
steps:
49+
- name: Download artifact containing distribution files
50+
uses: actions/download-artifact@v4
51+
with:
52+
name: dist
53+
path: dist/
54+
55+
- name: Upload package distributions
56+
uses: pypa/gh-action-pypi-publish@release/v1
57+
with:
58+
packages-dir: dist/
59+
repository-url: https://test.pypi.org/legacy/
60+
61+
publish:
62+
name: Publish package distributions to pypi.org
63+
runs-on: ubuntu-latest
64+
needs: [publish-test]
65+
if: startsWith(github.ref, 'refs/tags/')
66+
environment:
67+
name: pypi
68+
url: https://pypi.org/p/copier
69+
permissions:
70+
id-token: write
71+
72+
steps:
73+
- name: Download artifact containing distribution files
74+
uses: actions/download-artifact@v4
75+
with:
76+
name: dist
77+
path: dist/
78+
79+
- name: Upload package distributions
80+
uses: pypa/gh-action-pypi-publish@release/v1
81+
with:
82+
packages-dir: dist/

0 commit comments

Comments
 (0)