This document describes the release process for the fabric-chaincode-python package.
The project uses a main + release branch model:
main— Development branch with latest features and fixesrelease-2.5— Release maintenance branch for v2.5.x patch releases- Tags — Git tags (e.g.,
v2.5.0,v2.5.1) trigger automated wheel builds and PyPI publishing
- Ensure you have push access to the repository
- All commits must be signed off with DCO (
-sflag in git commit) - Tests must pass locally:
pytest -v
Make any necessary changes on main (bug fixes, version bumps, documentation):
git checkout main
git pull origin main
# Make your changes...
git add .
git commit -s -m "fix: description of fix"
git push origin maingit checkout release-2.5
git pull origin main
git push origin release-2.5From release-2.5, create an annotated tag (recommended for releases):
COMMIT=$(git rev-parse release-2.5)
git tag -a v2.5.X -m "Release v2.5.X - Description" "$COMMIT"
git push origin v2.5.XReplace X with the patch version number (e.g., v2.5.1, v2.5.2, etc.).
The tag pattern follows semver: v[0-9]+.[0-9]+.[0-9]+ or v[0-9]+.[0-9]+.[0-9]+-* (prerelease).
The tag push automatically triggers the release workflow (.github/workflows/release.yml):
gh run list --repo kmilodenisglez/fabric-chaincode-python --workflow release.yml --limit 5Expected workflow steps:
- ✅ Checkout repository
- ✅ Set up Python 3.11
- ✅ Install build dependencies
- ✅ Build distribution (sdist + wheel)
- ✅ Upload wheel artifact
- 📤 Publish to PyPI (if
PYPI_API_TOKENis configured and tag is semver)
gh run view <RUN_ID> --repo kmilodenisglez/fabric-chaincode-python --logArtifacts are available in GitHub Actions run details:
- Visit: https://github.com/kmilodenisglez/fabric-chaincode-python/actions
- Click the successful release run (tagged with
v2.5.X) - Download the
wheelartifact (contains.whlfile)
pip install dist/fabric-chaincode-python-*.whl
python -c "import src.fabric_shim; print('✓ Package imported successfully')"To enable automatic PyPI publishing on releases:
-
Create a PyPI Account
- Go to https://pypi.org/account/register/
- Create an account or use existing credentials
-
Generate an API Token
- Log into PyPI
- Navigate to Account → API Tokens
- Create a new token with "Entire repository" scope
- Copy the token (starts with
pypi-)
-
Add GitHub Secret
gh secret set PYPI_API_TOKEN --repo kmilodenisglez/fabric-chaincode-python
# Paste the token when promptedVerify the secret is set:
gh secret list --repo kmilodenisglez/fabric-chaincode-pythonOnce the PyPI token is configured, releases automatically:
- Build the wheel and sdist
- Publish to PyPI using pypa/gh-action-pypi-publish (OIDC-based, no need for static token in workflow)
You can also manually publish a built wheel:
pip install twine
python -m twine upload dist/fabric-chaincode-python-*.whl -u __token__ -p $PYPI_API_TOKENCheck the workflow logs:
gh run view <RUN_ID> --repo kmilodenisglez/fabric-chaincode-python --logCommon issues:
- Missing dependencies: Ensure
requirements.txtandpyproject.tomlare in sync - Import errors: Verify
setup.pycorrectly loads the version without importing the package - YAML syntax errors: Validate
.github/workflows/release.ymlwithyamllint
- Verify the token is valid (check GitHub secrets)
- Ensure the version number is unique (PyPI doesn't allow re-uploading the same version)
- For test uploads, use TestPyPI: https://test.pypi.org/
- All commits signed off (
-sflag) - Tests pass locally (
pytest -v) - CHANGELOG updated (if applicable)
- Version bumped in
src/version.py(if applicable) -
release-2.5synced frommain - Release tag created (
v2.5.X) - Workflow run successful
- Wheel artifact downloaded and tested locally
- PyPI publish successful (if enabled)
If a release needs to be rolled back:
# Delete the tag locally and remotely
git tag -d v2.5.X
git push origin --delete v2.5.X
# The workflow run cannot be undone, but the PyPI publish can be manually removed
# by deleting the release on PyPI if necessary