Skip to content

Commit c0c5bb4

Browse files
committed
Publish releases using trusted publishers
1 parent 39f132b commit c0c5bb4

File tree

1 file changed

+58
-9
lines changed

1 file changed

+58
-9
lines changed

.github/workflows/release.yaml

+58-9
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,28 @@ name: Publish releases
55
on:
66
release:
77
types: [published]
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
description: "Version for release on TestPyPI"
12+
required: true
813
env:
914
PYTHON_VERSION: "3.12"
1015

1116
jobs:
12-
build-and-publish-pypi:
17+
build:
1318
name: Builds and publishes releases to PyPI
1419
runs-on: ubuntu-latest
1520
steps:
1621
- uses: actions/[email protected]
17-
- name: Get tag
18-
id: vars
22+
- name: Store version from inputs
23+
if: github.event_name == 'workflow_dispatch'
24+
run: echo "tag=${{ inputs.version }}"
25+
- name: Get version from tag
26+
if: github.event_name == 'release'
1927
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
2028
- name: Validate version number
29+
if: github.event_name == 'release'
2130
run: >-
2231
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
2332
if ! [[ "${tag}" =~ "b" ]]; then
@@ -53,10 +62,50 @@ jobs:
5362
- name: Build python package
5463
run: >-
5564
python3 -m build
56-
- name: Publish release to PyPI
57-
uses: pypa/[email protected]
65+
- name: Store the distribution packages
66+
uses: actions/upload-artifact@v4
5867
with:
59-
user: __token__
60-
password: ${{ secrets.PYPI_TOKEN }}
61-
- name: Wait for PyPI
62-
run: sleep 300
68+
name: python-package-distributions
69+
path: dist/
70+
71+
publish-pypi:
72+
name: Publishes releases to PyPI
73+
runs-on: ubuntu-latest
74+
if: github.event_name == 'release'
75+
needs:
76+
- build
77+
environment:
78+
name: pypi
79+
url: https://pypi.org/p/aiohasupervisor
80+
permissions:
81+
id-token: write
82+
steps:
83+
- name: Download all the dists
84+
uses: actions/download-artifact@v4
85+
with:
86+
name: python-package-distributions
87+
path: dist/
88+
- name: Publish distribution 📦 to PyPI
89+
uses: pypa/gh-action-pypi-publish@release/v1
90+
91+
publish-test-pypi:
92+
name: Publishes releases to Test-PyPI
93+
runs-on: ubuntu-latest
94+
if: github.event_name == 'workflow_dispatch'
95+
needs:
96+
- build
97+
environment:
98+
name: testpypi
99+
url: https://test.pypi.org/p/aiohasupervisor
100+
permissions:
101+
id-token: write
102+
steps:
103+
- name: Download all the dists
104+
uses: actions/download-artifact@v4
105+
with:
106+
name: python-package-distributions
107+
path: dist/
108+
- name: Publish distribution 📦 to TestPyPI
109+
uses: pypa/gh-action-pypi-publish@release/v1
110+
with:
111+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)