Skip to content

Commit 5922241

Browse files
feanilclaude
andcommitted
build: attach release assets before publishing the release
The openedx org now has immutable releases enabled, which freezes a release's assets at the moment the release is published. Our flow created and published the release with python-semantic-release and then uploaded the distributions in a separate step, so those uploads now fail with "HTTP 422: Cannot upload assets to an immutable release". Instead, let python-semantic-release tag, push and build (vcs_release: false) and create the release ourselves with `gh release create`, which creates the release as a draft, uploads the assets, and only then publishes it. Its generated release notes are reused via the release_notes output, so the release body is unchanged. This has been broken since v3.6.1 but stayed silent until now, because python-semantic-release swallowed asset upload errors before v10.6.0. v3.6.1, v3.7.0 and v3.7.1 all published with no release assets, and they are immutable now, so they cannot be backfilled. Immutable releases: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/immutable-releases Silent upload failures: python-semantic-release/python-semantic-release#1395 Failing run: https://github.com/openedx/sample-plugin/actions/runs/32858608339/job/97836889093 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent 43d749c commit 5922241

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,37 @@ jobs:
4040
# Adjust tag with desired version if applicable.
4141
uses: python-semantic-release/python-semantic-release@39dd2052f2ce8282a5d932c31d58a2ca06d2550e # v10.6.1
4242
with:
43-
github_token: ${{ secrets.OPENEDX_SEMANTIC_RELEASE_GITHUB_TOKEN }}
43+
github_token: ${{ secrets.GITHUB_TOKEN }}
4444
git_committer_name: "github-actions"
4545
git_committer_email: "[email protected]"
4646
changelog: "false"
4747
directory: './backend-plugin-sample'
48-
49-
- name: Publish | Upload to GitHub Release Assets
50-
uses: python-semantic-release/publish-action@5a5718ce47b892ef699f2972dae122297771d641 # v10.6.1
48+
# Commit, tag, push and build, but don't create the GitHub release.
49+
# We create it ourselves in the next step so that the distributions
50+
# are attached before the release is published. See that step for why.
51+
vcs_release: "false"
52+
53+
# This repo has immutable releases enabled, which freezes a release's
54+
# assets the moment it is published, so assets cannot be attached
55+
# afterwards. `gh release create` handles this by creating the release as
56+
# a draft, uploading the assets, and only then publishing it:
57+
# https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/immutable-releases
58+
- name: Publish | Create GitHub Release with Assets
5159
if: steps.release.outputs.released == 'true'
52-
with:
53-
github_token: ${{ secrets.OPENEDX_SEMANTIC_RELEASE_GITHUB_TOKEN }}
54-
tag: ${{ steps.release.outputs.tag }}
55-
directory: './backend-plugin-sample'
60+
env:
61+
GH_TOKEN: ${{ secrets.OPENEDX_SEMANTIC_RELEASE_GITHUB_TOKEN }}
62+
# Reuse the release notes python-semantic-release generated for us.
63+
RELEASE_NOTES: ${{ steps.release.outputs.release_notes }}
64+
TAG: ${{ steps.release.outputs.tag }}
65+
run: |
66+
# Output the release notes to a file
67+
printf '%s' "$RELEASE_NOTES" > "$RUNNER_TEMP/release_notes.md"
68+
# Create a draft release
69+
gh release create "$TAG" \
70+
--verify-tag \
71+
--title "$TAG" \
72+
--notes-file "$RUNNER_TEMP/release_notes.md" \
73+
backend-plugin-sample/dist/*
5674
5775
- name: Upload | Backend Distribution Artifacts
5876
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2

0 commit comments

Comments
 (0)