Skip to content

Commit fc81e78

Browse files
fix(ci): inline pypi publish jobs to satisfy trusted publishing
PyPI Trusted Publishing does not support reusable workflows — the publish step must run directly in the calling workflow so the OIDC token's job_workflow_ref matches the trusted publisher config. Removed the reusable pypi-publish.yml and inlined its two jobs (publish-test, publish-pypi) directly into publish.yml. Updated notify-discord to depend on publish-pypi instead of the former reusable publish job. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f7221c3 commit fc81e78

2 files changed

Lines changed: 71 additions & 100 deletions

File tree

.github/workflows/publish.yml

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,83 @@ jobs:
9696
});
9797
EOF
9898
99-
publish:
100-
name: Publish released package
99+
publish-test:
100+
name: Test released package
101101
needs: release
102102
if: ${{ needs.release.outputs.published == 'true' }}
103-
uses: ./.github/workflows/pypi-publish.yml
104-
with:
105-
tag: ${{ needs.release.outputs.tag }}
106-
secrets: inherit
103+
runs-on: ubuntu-latest
104+
steps:
105+
- name: Checkout
106+
uses: actions/checkout@v4
107+
with:
108+
fetch-depth: 0
109+
ref: ${{ needs.release.outputs.tag }}
110+
111+
- name: Setup Python
112+
uses: actions/setup-python@v5
113+
with:
114+
python-version: "3.12"
115+
116+
- name: Install Python dependencies
117+
run: |
118+
python -m pip install --upgrade pip
119+
pip install -e .
120+
121+
- name: Run import test
122+
run: |
123+
python -c "import hatch; print('Hatch package imports successfully')"
124+
125+
publish-pypi:
126+
name: Publish to PyPI
127+
runs-on: ubuntu-latest
128+
needs: [release, publish-test]
129+
if: ${{ needs.release.outputs.published == 'true' }}
130+
outputs:
131+
tag: ${{ steps.published_tag.outputs.tag }}
132+
environment:
133+
name: pypi
134+
url: https://pypi.org/project/hatch-xclam/
135+
permissions:
136+
id-token: write
137+
138+
steps:
139+
- name: Checkout
140+
uses: actions/checkout@v4
141+
with:
142+
fetch-depth: 0
143+
ref: ${{ needs.release.outputs.tag }}
144+
145+
- name: Setup Python
146+
uses: actions/setup-python@v5
147+
with:
148+
python-version: "3.12"
149+
150+
- name: Install Python dependencies
151+
run: |
152+
python -m pip install --upgrade pip
153+
pip install build
154+
155+
- name: Build Python Package
156+
run: python -m build
157+
158+
- name: Publish to PyPI
159+
uses: pypa/gh-action-pypi-publish@release/v1
160+
with:
161+
print-hash: true
162+
verbose: true
163+
skip-existing: true
164+
165+
- name: Record published tag
166+
id: published_tag
167+
run: |
168+
echo "tag=${{ needs.release.outputs.tag }}" >> "$GITHUB_OUTPUT"
107169
108170
notify-discord:
109171
name: Notify Discord
110172
needs:
111173
- release
112-
- publish
113-
if: ${{ needs.release.outputs.published == 'true' && needs.publish.result == 'success' }}
174+
- publish-pypi
175+
if: ${{ needs.release.outputs.published == 'true' && needs.publish-pypi.result == 'success' }}
114176
runs-on: ubuntu-latest
115177
permissions:
116178
contents: read
@@ -119,7 +181,7 @@ jobs:
119181
id: release
120182
uses: actions/github-script@v8
121183
env:
122-
TAG_NAME: ${{ needs.publish.outputs.tag }}
184+
TAG_NAME: ${{ needs.publish-pypi.outputs.tag }}
123185
with:
124186
script: |
125187
const { data: release } = await github.rest.repos.getReleaseByTag({

.github/workflows/pypi-publish.yml

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)