-
Notifications
You must be signed in to change notification settings - Fork 8
feat: modernize Python tooling (pyproject.toml + uv + semantic-release) #242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
irfanuddinahmad
wants to merge
11
commits into
main
Choose a base branch
from
irfanuddinahmad/uv-migration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9a6b160
feat: consolidate package metadata into pyproject.toml
8e905de
feat: switch dependency management from pip-compile to uv
c7d2388
feat: add semantic-release for automated PyPI publishing
c6a2aca
fix: correct release tag format, exclude tests from wheel, drop stale…
543b2b8
fix: prevent uv sync from implicitly pulling in the dev group
5d13930
fix: publish to PyPI via OIDC instead of token
5a89d56
fix: pin pypa/gh-action-pypi-publish to a commit SHA
0689524
fix: set major_on_zero=false and allow_zero_version=true for consistency
3e3ac11
refactor: adopt src-layout, matching openedx/sample-plugin
61d1897
fix: use uv-venv-lock-runner for the main and pii_check tox envs
99bb817
fix: address review feedback (uv setup, coverage, readme, changelog)
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| name: Semantic Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| run_ci: | ||
| uses: ./.github/workflows/ci.yml | ||
|
|
||
| release: | ||
| needs: run_ci | ||
| runs-on: ubuntu-latest | ||
| if: github.ref_name == 'main' | ||
| concurrency: | ||
| group: ${{ github.workflow }}-release-${{ github.ref_name }} | ||
| cancel-in-progress: false | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| # Note: We checkout the repository at the branch that triggered the workflow. | ||
| # Python Semantic Release will automatically convert shallow clones to full clones | ||
| # if needed to ensure proper history evaluation. However, we forcefully reset the | ||
| # branch to the workflow sha because it is possible that the branch was updated | ||
| # while the workflow was running, which prevents accidentally releasing un-evaluated | ||
| # changes. | ||
| - name: Setup | Checkout Repository on Release Branch | ||
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| ref: ${{ github.ref_name }} | ||
|
|
||
| - name: Setup | Force release branch to be at workflow sha | ||
| run: | | ||
| git reset --hard ${{ github.sha }} | ||
|
|
||
| - name: Action | Semantic Version Release | ||
| id: release | ||
| uses: python-semantic-release/python-semantic-release@350c48fcb3ffcdfd2e0a235206bc2ecea6b69df0 # v10.5.3 | ||
| with: | ||
| github_token: ${{ secrets.OPENEDX_SEMANTIC_RELEASE_GITHUB_TOKEN }} | ||
| git_committer_name: "github-actions" | ||
| git_committer_email: "actions@users.noreply.github.com" | ||
| changelog: "false" | ||
|
|
||
| - name: Publish | Upload to GitHub Release Assets | ||
| uses: python-semantic-release/publish-action@310a9983a0ae878b29f3aac778d7c77c1db27378 # v10.5.3 | ||
| if: steps.release.outputs.released == 'true' | ||
| with: | ||
| github_token: ${{ secrets.OPENEDX_SEMANTIC_RELEASE_GITHUB_TOKEN }} | ||
| tag: ${{ steps.release.outputs.tag }} | ||
|
|
||
| - name: Upload | Distribution Artifacts | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | ||
| if: steps.release.outputs.released == 'true' | ||
| with: | ||
| name: distribution-artifacts | ||
| path: dist | ||
| if-no-files-found: error | ||
|
|
||
| outputs: | ||
| released: ${{ steps.release.outputs.released || 'false' }} | ||
| version: ${{ steps.release.outputs.version }} | ||
|
|
||
| publish_to_pypi: | ||
| # 1. Separate out the publish step from the github release step to run each step at | ||
| # the least amount of token privilege | ||
| # 2. Also, publishing can fail, and its better to have a separate job if you need to retry | ||
| # and it won't require reversing the release. | ||
| runs-on: ubuntu-latest | ||
| needs: release | ||
| if: github.ref_name == 'main' && needs.release.outputs.released == 'true' | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Setup | Download Build Artifacts | ||
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | ||
| with: | ||
| name: distribution-artifacts | ||
| path: dist | ||
|
|
||
| - name: Publish to PyPi | ||
| uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
astral-sh/setup-uvis missing two parameters:Without
enable-cache: truethe uv package cache is not persisted across runs. Withoutpython-version, Python is not managed bysetup-uv, which leaves thesetup pythonstep above still load-bearing rather than redundant.