Skip to content

Commit 2525f04

Browse files
farhanclaude
andcommitted
feat: add PyPI publish workflow via python-semantic-release + OIDC
- Add pypi-release.yml with python-semantic-release and OIDC trusted publishing to PyPI, following org-standard release workflow pattern - Switch pyproject.toml from static version to setuptools-scm dynamic versioning; add [tool.semantic_release] and [tool.setuptools_scm] - Regenerate uv.lock Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fd2de25 commit 2525f04

3 files changed

Lines changed: 91 additions & 1097 deletions

File tree

.github/workflows/pypi-release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
jobs:
8+
run_ci:
9+
uses: ./.github/workflows/ci.yml
10+
11+
release:
12+
needs: run_ci
13+
runs-on: ubuntu-latest
14+
if: github.ref_name == 'master'
15+
concurrency:
16+
group: ${{ github.workflow }}-release-${{ github.ref_name }}
17+
cancel-in-progress: false
18+
19+
permissions:
20+
contents: write
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
25+
with:
26+
ref: ${{ github.ref_name }}
27+
28+
- name: Force branch to workflow sha
29+
run: git reset --hard ${{ github.sha }}
30+
31+
- name: Run Semantic Release
32+
id: release
33+
uses: python-semantic-release/python-semantic-release@d137150c434dab15ebdf01b62c98f703c0163704 # v9.9.0
34+
with:
35+
github_token: ${{ secrets.GITHUB_TOKEN }}
36+
git_committer_name: "github-actions"
37+
git_committer_email: "actions@users.noreply.github.com"
38+
changelog: "false"
39+
40+
- name: Upload to GitHub Release Assets
41+
uses: python-semantic-release/publish-action@297a78b9c98490d2f3041b60e3e696b91dd2ce31 # v9.9.0
42+
if: steps.release.outputs.released == 'true'
43+
with:
44+
github_token: ${{ secrets.GITHUB_TOKEN }}
45+
tag: ${{ steps.release.outputs.tag }}
46+
47+
- name: Upload distribution artifacts
48+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
49+
if: steps.release.outputs.released == 'true'
50+
with:
51+
name: distribution-artifacts
52+
path: dist
53+
if-no-files-found: error
54+
55+
outputs:
56+
released: ${{ steps.release.outputs.released || 'false' }}
57+
version: ${{ steps.release.outputs.version }}
58+
59+
publish_to_pypi:
60+
runs-on: ubuntu-latest
61+
needs: release
62+
if: github.ref_name == 'master' && needs.release.outputs.released == 'true'
63+
64+
permissions:
65+
contents: read
66+
id-token: write # Required for OIDC trusted publishing
67+
68+
steps:
69+
- name: Download build artifacts
70+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
71+
with:
72+
name: distribution-artifacts
73+
path: dist
74+
75+
- name: Publish to PyPI
76+
uses: pypa/gh-action-pypi-publish@4bb033805d9e19112d8c697528791ff53f6c2f74 # v1.9.0

pyproject.toml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
[build-system]
2-
requires = ["setuptools>=61.0"]
2+
requires = ["setuptools>=61.0", "setuptools-scm>8.1"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "mockprock"
7-
version = "2.0.0"
87
description = "Mock proctoring backend for Open edX"
98
readme = "README.rst"
109
requires-python = ">=3.12"
@@ -28,6 +27,8 @@ keywords = [
2827
"openedx",
2928
"proctoring",
3029
]
30+
dynamic = ["version"]
31+
3132
dependencies = []
3233

3334
[project.optional-dependencies]
@@ -128,3 +129,15 @@ show_missing = true
128129
[tool.coverage.html]
129130
directory = "htmlcov"
130131

132+
[tool.semantic_release]
133+
# SETUPTOOLS_SCM_PRETEND_VERSION lets python-semantic-release drive the version
134+
# at build time without needing a setup.py file.
135+
build_command = "pip install build && SETUPTOOLS_SCM_PRETEND_VERSION=$NEW_VERSION python -m build"
136+
137+
[tool.setuptools_scm]
138+
version_scheme = 'only-version'
139+
local_scheme = 'no-local-version'
140+
fallback_version = "2.0.0"
141+
# Only match Python-style version tags (e.g. v2.0.0), skipping npm-style tags (npmv*)
142+
git_describe_command = ["git", "describe", "--dirty", "--tags", "--long", "--match", "v*", "--match", "[0-9]*"]
143+

0 commit comments

Comments
 (0)