Skip to content

Commit 85edde7

Browse files
authored
Update publish workflow (#315)
1 parent f6f92ca commit 85edde7

4 files changed

Lines changed: 66 additions & 22 deletions

File tree

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ updates:
1111
actions:
1212
patterns:
1313
- "*"
14-
- package-ecosystem: "pip"
14+
- package-ecosystem: "pip" # zizmor: ignore[dependabot-cooldown]
1515
directory: "/"
1616
versioning-strategy: "increase"
1717
schedule:

.github/workflows/pythonpublish.yml

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,66 @@ on:
44
release:
55
types: [published]
66

7+
# Restrict default permissions for all jobs
8+
permissions: {}
9+
710
jobs:
8-
deploy:
11+
build:
12+
name: Build distribution
913
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
1016
steps:
11-
- uses: actions/checkout@v6
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
with:
19+
persist-credentials: false
1220
- name: Set up Python
13-
uses: actions/setup-python@v6
21+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
22+
with:
23+
python-version: "3.x"
24+
- name: Install build dependencies
25+
run: python -m pip install --upgrade pip build
26+
- name: Build package
27+
run: python -m build
28+
- name: Upload distribution artifacts
29+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
30+
with:
31+
name: python-package-distributions
32+
path: dist/
33+
34+
publish:
35+
name: Publish to PyPI
36+
needs: build
37+
runs-on: ubuntu-latest
38+
environment:
39+
name: pypi
40+
permissions:
41+
id-token: write
42+
steps:
43+
- name: Download distribution artifacts
44+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
45+
with:
46+
name: python-package-distributions
47+
path: dist/
48+
- name: Publish package to PyPI
49+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
50+
51+
post-release:
52+
name: Trigger documentation rebuilds
53+
needs: publish
54+
runs-on: ubuntu-latest
55+
environment: rtd-rebuild
56+
permissions:
57+
contents: read
58+
steps:
59+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
60+
with:
61+
persist-credentials: false
62+
- name: Set up Python
63+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
1464
with:
1565
python-version: "3.x"
16-
- name: Install dependencies
17-
run: |
18-
python -m pip install --upgrade pip
19-
python -m pip install -U --user --force-reinstall pep517 setuptools_scm twine
20-
- name: Build and publish
21-
env:
22-
TWINE_USERNAME: __token__
23-
TWINE_PASSWORD: ${{ secrets.PYPI_UPLOAD_TOKEN }}
24-
run: |
25-
python -m pep517.build --binary --source --out-dir wheelhouse .
26-
python -m twine upload --skip-existing wheelhouse/*
27-
- name: Install dependencies
28-
run: |
29-
pip install requests httpie
3066
- name: Build all RTD versions
3167
env:
3268
RTD_AUTH_TOKEN: ${{ secrets.RTD_AUTH_TOKEN }}
33-
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
34-
run: |
35-
python tools/rebuild_all_rtd.py
36-
http POST https://api.netlify.com/api/v1/sites/1ba3a6d4-f1ee-4524-bbec-3edc04720a48/builds "Authorization: Bearer $NETLIFY_AUTH_TOKEN"
69+
run: pipx run tools/rebuild_all_rtd.py

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ ci:
22
autofix_prs: false
33
autoupdate_schedule: "monthly"
44
repos:
5+
- repo: https://github.com/zizmorcore/zizmor-pre-commit
6+
rev: v1.23.1
7+
hooks:
8+
- id: zizmor
59
- repo: https://github.com/astral-sh/ruff-pre-commit
610
rev: "v0.15.9"
711
hooks:

tools/rebuild_all_rtd.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# /// script
2+
# requires-python = ">=3.13"
3+
# dependencies = [
4+
# "requests",
5+
# ]
6+
# ///
7+
18
"""
29
Run all builds for all active versions of all SunPy and SunPy subprojects on
310
RTD.

0 commit comments

Comments
 (0)