Skip to content

Commit b723b58

Browse files
authored
ci: inline beta release jobs to fix PyPI trusted publishing (#1875)
## Summary PyPI's Trusted Publishing rejects OIDC tokens issued from reusable workflows: > The claims in this token suggest that the calling workflow is a reusable workflow. Reusable workflows are not currently supported by PyPI's Trusted Publishing. `on_master.yaml` was invoking `manual_release_beta.yaml` via `uses:`, which made the OIDC token reflect a reusable workflow call. The same fix was applied in `apify/apify-shared-python#63`. ## Changes - `on_master.yaml`: inline the four beta release jobs (`release_prepare`, `changelog_update`, `pypi_publish`, `doc_release_post_publish`) directly, instead of calling `manual_release_beta.yaml` as a reusable workflow. - `manual_release_beta.yaml`: remove the `workflow_call` trigger (no longer invoked from another workflow) and add a comment explaining why the duplication exists. - Drop the unused `tag_name` output from `release_prepare` in both files. ## Follow-up The PyPI Trusted Publisher for `crawlee` is currently configured for `manual_release_beta.yaml`. After this is merged, an entry for `on_master.yaml` needs to be added on PyPI so the automatic beta release passes verification. See: https://docs.pypi.org/trusted-publishers/troubleshooting/#reusable-workflows-on-github
1 parent 48891c5 commit b723b58

2 files changed

Lines changed: 63 additions & 8 deletions

File tree

.github/workflows/manual_release_beta.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ name: Beta release
22

33
on:
44
# Runs when manually triggered from the GitHub UI.
5+
# Note: This workflow is intentionally NOT a reusable workflow (no `workflow_call`)
6+
# because PyPI's Trusted Publishing does not currently support reusable workflows.
7+
# The same jobs are duplicated in `on_master.yaml` for the automatic beta release on push to master.
8+
# See: https://docs.pypi.org/trusted-publishers/troubleshooting/#reusable-workflows-on-github
59
workflow_dispatch:
610

7-
# Runs when invoked by another workflow.
8-
workflow_call:
9-
1011
permissions:
1112
contents: read
1213

@@ -16,7 +17,6 @@ jobs:
1617
runs-on: ubuntu-latest
1718
outputs:
1819
version_number: ${{ steps.release_prepare.outputs.version_number }}
19-
tag_name: ${{ steps.release_prepare.outputs.tag_name }}
2020
changelog: ${{ steps.release_prepare.outputs.changelog }}
2121
steps:
2222
- uses: apify/workflows/git-cliff-release@main

.github/workflows/on_master.yaml

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,74 @@ jobs:
4545
uses: ./.github/workflows/_tests.yaml
4646
secrets: inherit
4747

48-
beta_release:
48+
# The beta release jobs are intentionally inlined here (instead of calling `manual_release_beta.yaml` via `uses:`)
49+
# because PyPI's Trusted Publishing does not currently support reusable workflows.
50+
# See: https://docs.pypi.org/trusted-publishers/troubleshooting/#reusable-workflows-on-github
51+
release_prepare:
4952
# Run this only for "feat", "fix", "perf", "refactor" and "style" commits.
5053
if: >-
5154
startsWith(github.event.head_commit.message, 'feat') ||
5255
startsWith(github.event.head_commit.message, 'fix') ||
5356
startsWith(github.event.head_commit.message, 'perf') ||
5457
startsWith(github.event.head_commit.message, 'refactor') ||
5558
startsWith(github.event.head_commit.message, 'style')
56-
name: Beta release
59+
name: Beta release / Release prepare
5760
needs: [code_checks, tests]
61+
runs-on: ubuntu-latest
62+
outputs:
63+
version_number: ${{ steps.release_prepare.outputs.version_number }}
64+
changelog: ${{ steps.release_prepare.outputs.changelog }}
65+
steps:
66+
- uses: apify/workflows/git-cliff-release@main
67+
id: release_prepare
68+
name: Release prepare
69+
with:
70+
release_type: prerelease
71+
existing_changelog_path: CHANGELOG.md
72+
73+
changelog_update:
74+
name: Beta release / Changelog update
75+
needs: [release_prepare]
76+
permissions:
77+
contents: write
78+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
79+
with:
80+
version_number: ${{ needs.release_prepare.outputs.version_number }}
81+
changelog: ${{ needs.release_prepare.outputs.changelog }}
82+
secrets: inherit
83+
84+
pypi_publish:
85+
name: Beta release / PyPI publish
86+
needs: [release_prepare, changelog_update]
87+
runs-on: ubuntu-latest
88+
permissions:
89+
contents: write
90+
id-token: write # Required for OIDC authentication.
91+
environment:
92+
name: pypi
93+
url: https://pypi.org/project/crawlee
94+
steps:
95+
- name: Prepare distribution
96+
uses: apify/workflows/prepare-pypi-distribution@main
97+
with:
98+
package_name: crawlee
99+
is_prerelease: "yes"
100+
version_number: ${{ needs.release_prepare.outputs.version_number }}
101+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
102+
103+
# Publish the package to PyPI using PyPA official GitHub action with OIDC authentication.
104+
- name: Publish package to PyPI
105+
uses: pypa/gh-action-pypi-publish@release/v1
106+
107+
doc_release_post_publish:
108+
name: Beta release / Doc release post publish
109+
needs: [changelog_update, pypi_publish]
58110
permissions:
59111
contents: write
60-
id-token: write
61112
pages: write
62-
uses: ./.github/workflows/manual_release_beta.yaml
113+
id-token: write
114+
uses: ./.github/workflows/manual_release_docs.yaml
115+
with:
116+
# Use the ref from the changelog update to include the updated changelog.
117+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
63118
secrets: inherit

0 commit comments

Comments
 (0)