Skip to content

Commit 9fcb06e

Browse files
ci: Split deploy jobs into separate files
1 parent 040778b commit 9fcb06e

File tree

2 files changed

+48
-53
lines changed

2 files changed

+48
-53
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
name: build
22

33
on:
4-
push:
54
pull_request:
65
workflow_call:
76

87
jobs:
98
build:
109
name: Build and Test Package
1110
strategy:
12-
matrix:
13-
version:
14-
- '3.8'
15-
- '3.9'
16-
- '3.10'
17-
- '3.11'
18-
- '3.12'
19-
os: [ubuntu-latest, windows-latest]
11+
matrix:
12+
version:
13+
- '3.8'
14+
- '3.9'
15+
- '3.10'
16+
- '3.11'
17+
- '3.12'
18+
os: [ubuntu-latest, windows-latest]
19+
include:
20+
- version: '3.12'
21+
os: ubuntu-latest
22+
upload: true
2023
runs-on: ${{ matrix.os }}
2124

2225
steps:
@@ -41,7 +44,7 @@ jobs:
4144
4245
- name: Upload the Docs
4346
uses: actions/upload-pages-artifact@v3
44-
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.12'
47+
if: matrix.upload
4548
with:
4649
path: html/
4750

@@ -52,50 +55,8 @@ jobs:
5255
run: python3 -m build
5356

5457
- name: Store the distribution packages
55-
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.12'
58+
if: matrix.upload
5659
uses: actions/upload-artifact@v4
5760
with:
5861
name: python-package-distributions
5962
path: dist/
60-
61-
deploy-testpypi:
62-
name: Deploy Distribution to Test PyPI
63-
if: false # Currently disabled
64-
needs: [build]
65-
runs-on: ubuntu-latest
66-
environment:
67-
name: testpypi
68-
url: https://test.pypi.org/p/sphinx-multiversion
69-
permissions:
70-
id-token: write
71-
72-
steps:
73-
- name: Download the Distributions
74-
uses: actions/download-artifact@v4
75-
with:
76-
name: python-package-distributions
77-
path: dist/
78-
79-
- name: Publish Distributions to Test PyPI
80-
uses: pypa/gh-action-pypi-publish@release/v1
81-
82-
deploy-pypi:
83-
name: Deploy Distribution to PyPI
84-
if: startsWith(github.ref, 'refs/tags/')
85-
needs: [build]
86-
runs-on: ubuntu-latest
87-
environment:
88-
name: pypi
89-
url: https://pypi.org/p/sphinx-multiversion
90-
permissions:
91-
id-token: write
92-
93-
steps:
94-
- name: Download the Distributions
95-
uses: actions/download-artifact@v4
96-
with:
97-
name: python-package-distributions
98-
path: dist/
99-
100-
- name: Publish Distributions to PyPI
101-
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/deploy-pypi.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: deploy-pypi
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
if: github.ref_protected == true
10+
uses: ./.github/workflows/build.yml
11+
12+
deploy-pypi:
13+
if: github.ref_protected == true
14+
needs: [build]
15+
strategy:
16+
matrix:
17+
environment: [test.pypi, pypi]
18+
name: Deploy Distribution to ${{ matrix.environment }}.org
19+
runs-on: ubuntu-latest
20+
environment:
21+
name: ${{ matrix.environment }}
22+
url: https://${{ matrix.environment }}.org/p/sphinx-multiversion
23+
permissions:
24+
id-token: write
25+
26+
steps:
27+
- name: Download the Distributions
28+
uses: actions/download-artifact@v4 # eventually rely on artifacts uploaded to the draft release
29+
with:
30+
name: python-package-distributions
31+
path: dist/
32+
33+
- name: Publish Distributions to ${{ matrix.environment }}.org
34+
uses: pypa/gh-action-pypi-publish@f7600683efdcb7656dec5b29656edb7bc586e597

0 commit comments

Comments
 (0)