Skip to content

Commit 835bd1f

Browse files
authored
fix(release): publish PyPI via OIDC on recovery runner (#318)
1 parent 085fc76 commit 835bd1f

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

‎.github/workflows/publish-pypi.yml‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ jobs:
6262
test "$GITHUB_EVENT_NAME" = workflow_dispatch
6363
test "$GITHUB_REF" = refs/heads/main
6464
test "$RELEASE_TAG" = v4.20.0
65-
docker info --format '{{.ServerVersion}}'
65+
test -n "${ACTIONS_ID_TOKEN_REQUEST_URL:-}"
66+
test -n "${ACTIONS_ID_TOKEN_REQUEST_TOKEN:-}"
6667
6768
- name: Checkout the release tag, or main for a first publish
6869
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -170,11 +171,26 @@ jobs:
170171
sha256sum dist/*
171172
172173
- name: Publish to PyPI
173-
if: ${{ github.event_name == 'release' || !inputs.dry_run }}
174+
if: ${{ !inputs.manual_self_hosted && (github.event_name == 'release' || !inputs.dry_run) }}
174175
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
175176
with:
176177
packages-dir: packages/pypi-cli/dist
177178

179+
# The reviewed self-hosted runner has no Docker, so the container action above
180+
# cannot start there. Twine 6.2 obtains the same short-lived PyPI credential
181+
# directly from this job's OIDC identity; no stored API token is needed.
182+
- name: Publish to PyPI from the recovery runner
183+
if: ${{ inputs.manual_self_hosted && !inputs.dry_run }}
184+
shell: bash
185+
working-directory: packages/pypi-cli
186+
run: |
187+
set -Eeuo pipefail
188+
unset TWINE_USERNAME TWINE_PASSWORD
189+
mkdir -p "$RUNNER_TEMP/twine-home"
190+
HOME="$RUNNER_TEMP/twine-home" \
191+
PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring \
192+
python -m twine upload --non-interactive dist/*
193+
178194
- name: Dry run summary
179195
if: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}
180196
shell: bash

0 commit comments

Comments
 (0)