Skip to content

Commit 0b62620

Browse files
salman2013claude
andcommitted
chore: add python-semantic-release and commitlint workflows
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4e95632 commit 0b62620

5 files changed

Lines changed: 101 additions & 74 deletions

File tree

.github/workflows/python-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: Python Tests
22

33
on:
4-
push:
5-
branches: [main]
64
pull_request:
75
branches:
86
- "**"
7+
# Called from release.yml before publishing on push to main.
8+
workflow_call:
99

1010
jobs:
1111
python-tests:

.github/workflows/release.yml

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,31 @@ on:
55
branches: [main]
66

77
jobs:
8-
ci:
9-
name: Run CI
10-
runs-on: ubuntu-latest
11-
strategy:
12-
fail-fast: true
13-
matrix:
14-
toxenv: [quality, docs, django42, django52]
15-
16-
steps:
17-
- name: Check out repository
18-
uses: actions/checkout@v6
19-
20-
- name: Set up Python
21-
uses: actions/setup-python@v6
22-
with:
23-
python-version: "3.12"
24-
25-
- name: Install uv
26-
uses: astral-sh/setup-uv@v6
27-
28-
- name: Install CI dependencies
29-
run: uv sync --group ci
30-
31-
- name: Run tests (${{ matrix.toxenv }})
32-
env:
33-
TOXENV: ${{ matrix.toxenv }}
34-
run: uv run tox
8+
run_tests:
9+
uses: ./.github/workflows/python-tests.yml
3510

3611
release:
37-
name: Semantic Release
12+
needs: run_tests
3813
runs-on: ubuntu-latest
39-
needs: ci
40-
concurrency: release
14+
if: github.ref_name == 'main'
15+
concurrency:
16+
group: ${{ github.workflow }}-release-${{ github.ref_name }}
17+
cancel-in-progress: false
18+
4119
permissions:
42-
id-token: write # for PyPI trusted publisher (OIDC)
43-
contents: write # to push tags and create GitHub releases
20+
contents: write
4421

4522
steps:
46-
- name: Check out repository
23+
# Checkout at the branch that triggered the workflow, then force-reset to
24+
# the exact sha so we don't accidentally release commits that arrived
25+
# while this workflow was running.
26+
- name: Setup | Checkout Repository on Release Branch
4727
uses: actions/checkout@v6
4828
with:
49-
fetch-depth: 0
29+
ref: ${{ github.ref_name }}
30+
31+
- name: Setup | Force release branch to workflow sha
32+
run: git reset --hard ${{ github.sha }}
5033

5134
- name: Set up Python
5235
uses: actions/setup-python@v6
@@ -66,12 +49,51 @@ jobs:
6649
npm ci
6750
npm run build
6851
69-
- name: Python Semantic Release
52+
- name: Action | Semantic Version Release
7053
id: release
71-
uses: python-semantic-release/python-semantic-release@v9
54+
uses: python-semantic-release/python-semantic-release@v10.5.3
7255
with:
7356
github_token: ${{ secrets.GITHUB_TOKEN }}
57+
git_committer_name: "github-actions"
58+
git_committer_email: "actions@users.noreply.github.com"
59+
changelog: "false"
7460

75-
- name: Publish to PyPI
61+
- name: Publish | Upload to GitHub Release Assets
62+
uses: python-semantic-release/publish-action@v10.5.3
63+
if: steps.release.outputs.released == 'true'
64+
with:
65+
github_token: ${{ secrets.GITHUB_TOKEN }}
66+
tag: ${{ steps.release.outputs.tag }}
67+
68+
- name: Upload | Distribution Artifacts
69+
uses: actions/upload-artifact@v4
7670
if: steps.release.outputs.released == 'true'
71+
with:
72+
name: distribution-artifacts
73+
path: dist/
74+
if-no-files-found: error
75+
76+
outputs:
77+
released: ${{ steps.release.outputs.released || 'false' }}
78+
version: ${{ steps.release.outputs.version }}
79+
80+
publish_to_pypi:
81+
# Separate from the release job for least privilege and retry-ability:
82+
# publishing can fail independently and shouldn't require reversing the release.
83+
runs-on: ubuntu-latest
84+
needs: release
85+
if: github.ref_name == 'main' && needs.release.outputs.released == 'true'
86+
87+
permissions:
88+
contents: read
89+
id-token: write # for PyPI OIDC trusted publisher
90+
91+
steps:
92+
- name: Download Distribution Artifacts
93+
uses: actions/download-artifact@v4
94+
with:
95+
name: distribution-artifacts
96+
path: dist/
97+
98+
- name: Publish to PyPI
7799
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/upgrade-python-requirements.yml

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,17 @@ on:
1111
default: 'main'
1212

1313
jobs:
14-
upgrade:
15-
runs-on: ubuntu-latest
16-
steps:
17-
- name: Check out repository
18-
uses: actions/checkout@v6
19-
with:
20-
ref: ${{ github.event.inputs.branch || 'main' }}
21-
22-
- name: Set up Python
23-
uses: actions/setup-python@v6
24-
with:
25-
python-version: "3.12"
26-
27-
- name: Install uv
28-
uses: astral-sh/setup-uv@v6
29-
30-
- name: Install edx-lint
31-
run: uv pip install edx-lint --system
32-
33-
- name: Upgrade lockfile
34-
run: make upgrade
35-
36-
- name: Create pull request
37-
uses: peter-evans/create-pull-request@v7
38-
with:
39-
token: ${{ secrets.REQUIREMENTS_BOT_GITHUB_TOKEN }}
40-
commit-message: "chore: upgrade Python requirements"
41-
branch: upgrade/python-requirements
42-
delete-branch: true
43-
title: "chore: upgrade Python requirements"
44-
body: |
45-
Automated upgrade of `uv.lock` via `make upgrade`.
46-
reviewers: axim-aximprovements
14+
call-upgrade-python-requirements-workflow:
15+
uses: openedx/.github/.github/workflows/upgrade-python-requirements.yml@master
16+
with:
17+
branch: ${{ github.event.inputs.branch || 'main' }}
18+
# optional parameters below; fill in if you'd like github or email notifications
19+
# user_reviewers: ""
20+
team_reviewers: "axim-aximprovements"
21+
email_address: "aximimprovements@axim.org"
22+
send_success_notification: false
23+
secrets:
24+
requirements_bot_github_token: ${{ secrets.REQUIREMENTS_BOT_GITHUB_TOKEN }}
25+
requirements_bot_github_email: ${{ secrets.REQUIREMENTS_BOT_GITHUB_EMAIL }}
26+
edx_smtp_username: ${{ secrets.EDX_SMTP_USERNAME }}
27+
edx_smtp_password: ${{ secrets.EDX_SMTP_PASSWORD }}

README.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The possible XBlock statuses are:
3131

3232
* In Development: We're building and testing this block.
3333
* Ready to Use: You can try this on your site using the Waffle flag.
34-
* Done: The built-in block has been removed. The setup.py entrypoint has been removed from edx-platform and added to xblock-contrib.
34+
* Done: The built-in block has been removed. The ``pyproject.toml`` entry-point has been removed from edx-platform and added to xblock-contrib.
3535

3636

3737
Additional XBlocks that belong here
@@ -51,6 +51,29 @@ Over time, more XBlocks may be moved here. An XBlock belongs here if and only if
5151
Installation and Development Guide
5252
**********************************
5353

54+
Python Setup
55+
^^^^^^^^^^^^
56+
57+
This project uses `uv <https://docs.astral.sh/uv/>`_ for dependency management.
58+
59+
1. `Install uv <https://docs.astral.sh/uv/getting-started/installation/>`_.
60+
2. Install all development dependencies::
61+
62+
$ make requirements
63+
64+
This runs ``uv sync --group dev`` and installs the package in editable mode.
65+
66+
3. Run the test suite::
67+
68+
$ uv run tox
69+
70+
4. To upgrade all dependencies::
71+
72+
$ make upgrade
73+
74+
Frontend Setup
75+
^^^^^^^^^^^^^^
76+
5477
Study scripts in the ``package.json`` file to understand the available commands.
5578

5679
1. Install this repository into your runtime (for example ``openedx-platform``) as an editable dependency. For Tutor, you can mount this repository for local development.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,6 @@ constraint-dependencies = [
184184
]
185185

186186
[tool.semantic_release]
187-
tag_format = "v{version}"
187+
# We use SETUPTOOLS_SCM_PRETEND_VERSION to pull the version from python-semantic-release
188+
# instead of from version control because the build step happens before the repo gets tagged.
188189
build_command = "SETUPTOOLS_SCM_PRETEND_VERSION=$NEW_VERSION uv build"

0 commit comments

Comments
 (0)