Skip to content

Commit f8d594b

Browse files
docs: enhance contributing and releasing documentation for clarity and completeness
Signed-off-by: kmilo <kmilo.denis.glez@yandex.com>
1 parent 1396087 commit f8d594b

3 files changed

Lines changed: 103 additions & 117 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,74 @@
1-
# Contributing
1+
# Contributing to fabric-chaincode-python
22

3-
This project follows the Hyperledger contribution requirements. Please read this file before contributing.
3+
We welcome contributions to the [Hyperledger Fabric](https://hyperledger-fabric.readthedocs.io) Project. There's always plenty to do!
44

5-
Signed-off-by / DCO
6-
--------------------
5+
If you have any questions about the project or how to contribute, you can find us in the [fabric-chaincode-python](https://discord.gg/hyperledger-fabric) channel on [Discord](https://discord.lfdecentralizedtrust.org/).
76

8-
This repository uses the Developer Certificate of Origin (DCO). All commits must be signed off using the `Signed-off-by:` trailer.
7+
Here are a few guidelines to help you contribute successfully.
98

10-
To sign off your commits locally, run:
9+
## Issues
1110

12-
```bash
13-
git commit -s -m "Your commit message"
14-
# or when amending
15-
git commit --amend -s --no-edit
16-
```
11+
All issues are tracked in the issues tab in GitHub. If you find a bug which we don't already know about, you can help us by creating a new issue describing the problem. Please include as much detail as possible to help us track down the cause. If you want to begin contributing code, looking through our open issues is a good way to start. Try looking for recent issues with detailed descriptions first, or ask us on Discord if you're unsure which issue to choose.
1712

18-
The sign-off will add a line like:
13+
## Enhancements
1914

20-
```
21-
Signed-off-by: Your Name <you@example.com>
22-
```
15+
Make sure you have the support of the Hyperledger Fabric community before investing a lot of effort in project enhancements. Please look up the [Fabric RFC](https://github.com/hyperledger/fabric-rfcs) process for large changes.
16+
17+
## Pull Requests
18+
19+
We use our own forks and [GitHub Flow](https://docs.github.com/en/get-started/using-github/github-flow) to deliver changes to the code. Follow these steps to deliver your first pull request:
20+
21+
1. [Fork the repository](https://docs.github.com/en/get-started/exploring-projects-on-github/contributing-to-a-project) and create a new branch from `main`.
22+
2. If you've added code that should be tested, add tests!
23+
3. If you've added any new features or made breaking changes, update the documentation.
24+
4. Ensure all the tests pass.
25+
5. Include a descriptive message and the [Developer Certificate of Origin (DCO) sign-off](https://github.com/dcoapp/app#how-it-works) on all commit messages.
26+
6. [Issue a pull request](https://docs.github.com/en/get-started/exploring-projects-on-github/contributing-to-a-project#making-a-pull-request)!
27+
7. [GitHub Actions](https://github.com/hyperledger/fabric-chaincode-python/actions) builds must succeed before the pull request can be reviewed and coded.
28+
29+
## Coding Style
30+
31+
Please try to be consistent with the rest of the code. The project uses [ruff](https://docs.astral.sh/ruff/) for linting and [black](https://black.readthedocs.io/) for code formatting. You can run `python -m ruff check .` and `python -m black .` to check/format your code before submitting changes to avoid failing the build with formatting violations.
32+
33+
## Code of Conduct Guidelines
2334

24-
Make sure your Git `user.name` and `user.email` are configured correctly:
35+
See our [Code of Conduct Guidelines](CODE_OF_CONDUCT.md).
2536

26-
```bash
27-
git config --global user.name "Your Name"
28-
git config --global user.email "you@example.com"
37+
## Maintainers
38+
39+
Should you have any questions or concerns, please reach out to one of the project's [Maintainers](MAINTAINERS.md).
40+
41+
42+
## How to work with the Codebase
43+
44+
Some useful commands to help with building and testing:
45+
46+
```shell
47+
# Run all tests
48+
pytest -v
49+
50+
# Run linting
51+
python -m ruff check .
52+
53+
# Format code
54+
python -m black .
55+
56+
# Build a wheel
57+
python -m build --sdist --wheel
2958
```
3059

31-
Protobuf bindings
32-
--------------------
60+
You can also scan for vulnerabilities in dependencies:
3361

34-
Bindings come from PyPI (`hyperledger-fabric-protos`) via `requirements.txt` - no extra steps needed.
62+
```shell
63+
make scan
64+
```
3565

36-
If you need to test against unreleased `fabric-protos` changes, see `PROTOS.md` (`scripts/install_fabric_protos.sh` and `scripts/gen_protos.sh`).
66+
## Hyperledger Fabric
3767

68+
See the
69+
[Hyperledger Fabric contributors guide](http://hyperledger-fabric.readthedocs.io/en/latest/CONTRIBUTING.html) for more details, including other Hyperledger Fabric projects you may wish to contribute to.
3870

39-
Licensing
40-
---------
71+
---
4172

42-
This project is licensed under the Apache-2.0 license. By contributing you agree to license your contributions under the same terms.
73+
[![Creative Commons License](https://i.creativecommons.org/l/by/4.0/88x31.png)](http://creativecommons.org/licenses/by/4.0/)
74+
This work is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/).

‎README.md‎

Lines changed: 21 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,36 @@
11
# fabric-chaincode-python
22

3-
Hyperledger Fabric Chaincode shim and Contract API for Python.
3+
[![Lifecycle](https://img.shields.io/badge/lifecycle-experimental- orange.svg)](https://github.com/hyperledger/fabric-chaincode-python/blob/main/lifecycle.md)
4+
[![Python Version](https://img.shields.io/pypi/pyversions/fabric-chaincode-python.svg)](https://pypi.org/project/fabric-chaincode-python/)
5+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
6+
[![GitHub Actions](https://github.com/hyperledger/fabric-chaincode-python/workflows/CI/badge.svg)](https://github.com/hyperledger/fabric-chaincode-python/actions?query=workflow%3ACI)
7+
[![GitHub Release](https://img.shields.io/github/v/release/hyperledger/fabric-chaincode-python.svg)](https://github.com/hyperledger/fabric-chaincode-python/releases)
48

5-
Status
6-
------
7-
- Experimental implementation of a Python chaincode shim and contract API.
8-
- CI runs with Python 3.11; supported Python versions are 3.10 and 3.11.
9+
# Hyperledger Fabric Chaincode shim and Contract API for Python
910

10-
Requirements
11-
------------
12-
- Python 3.10+ (3.11 recommended)
13-
- See `requirements.txt` for runtime dependencies
11+
This repository provides the Python implementation of Hyperledger Fabric chaincode shim and contract API. Chaincodes (smart contracts) can be written in Python to run inside Hyperledger Fabric peers.
1412

15-
Quick start (development)
16-
-------------------------
17-
Clone the repository and create a virtual environment:
13+
## Documentation
1814

19-
```bash
20-
git clone https://github.com/kmilodenisglez/fabric-chaincode-python.git
21-
cd fabric-chaincode-python
22-
python3 -m venv .venv
23-
source .venv/bin/activate
24-
python -m pip install --upgrade pip
25-
pip install -r requirements.txt
26-
```
15+
- API documentation: https://hyperledger.github.io/fabric-chaincode-python/
16+
- Full Documentation on Hyperledger Fabric: https://hyperledger-fabric.readthedocs.io/
17+
- Samples repository: https://github.com/hyperledger/fabric-samples
18+
- Quick-start tutorial: TUTORIAL.md
2719

28-
Run tests:
20+
## Compatibility
2921

30-
```bash
31-
pytest -q
32-
```
22+
For details on what Python versions and Hyperledger Fabric versions can be used, see the [COMPATIBILITY.md](COMPATIBILITY.md).
3323

34-
Build a wheel (release)
35-
-----------------------
36-
Build a wheel that can be published or installed:
24+
## npm Shrinkwrap
3725

38-
```bash
39-
python -m pip install --upgrade build
40-
python -m build --wheel --no-isolation
41-
# artifact will be in dist/*.whl
42-
```
26+
Strongly recommended to create a `requirements.txt` file after testing and before putting your contract into production.
4327

44-
Protobuf bindings
45-
-----------------
46-
This repository consumes the official Python bindings published to PYPI from
47-
`hyperledger/fabric-protos`:
28+
## Contributing
4829

49-
- Package name: `hyperledger-fabric-protos`
50-
- Import namespace: `fabric_protos`
30+
If you are interested in contributing updates to this project, please start with the [contributing guide](CONTRIBUTING.md).
5131

52-
They are installed as a regular dependency via requirements.txt. For custom bindings (local checkout, specific upstream commit) see PROTOS.md.
32+
There is also a [release guide](RELEASING.md) describing the process for publishing new versions.
5333

54-
No vendored protobuf runtime package is required in this repository.
55-
If you need to regenerate bindings locally for debugging, use
56-
`scripts/gen_protos.sh` and keep generated/runtime versions compatible.
34+
## Build Status
5735

58-
Running a chaincode service (example)
59-
------------------------------------
60-
Set the environment variables expected by the example chaincode server:
61-
62-
```bash
63-
export CHAINCODE_ID=basic_1.0:your_package_id_here
64-
export CHAINCODE_SERVER_ADDRESS=127.0.0.1:9999
65-
```
66-
67-
Then start the example service (if `main.py` or an example is present):
68-
69-
```bash
70-
./.venv/bin/python examples/ccaas/asset-transfer-basic/main.py
71-
```
72-
73-
Contributing
74-
------------
75-
- Follow the Developer Certificate of Origin (DCO): sign commits with
76-
`Signed-off-by: Your Name <you@example.com>` (the repository contains a
77-
DCO check workflow).
78-
- The project uses the Apache-2.0 license.
79-
80-
Releasing
81-
---------
82-
For information on how to create releases and publish to PyPI, see [RELEASING.md](RELEASING.md).
83-
84-
More information
85-
----------------
86-
- [RELEASING.md](RELEASING.md) — Release process and PyPI publishing
87-
- [PROTOS.md](PROTOS.md) — Guidance on handling Fabric protobufs
88-
- `scripts/gen_protos.sh` — Protobuf binding regeneration instructions
36+
CI runs with Python 3.11 on `main` and `release-*` branches, and on pull requests.

‎RELEASING.md‎

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,15 @@ The project uses a **main + release branch** model:
88

99
- **`main`** — Development branch with latest features and fixes
1010
- **`release-2.5`** — Release maintenance branch for v2.5.x patch releases
11-
- **Tags** — Git tags (e.g., `v2.5.0`, `v2.5.1`) trigger automated wheel builds and optional PyPI publishing
11+
- **Tags** — Git tags (e.g., `v2.5.0`, `v2.5.1`) trigger automated wheel builds and PyPI publishing
1212

1313
## Making a Release
1414

1515
### Prerequisites
1616

1717
1. Ensure you have push access to the repository
1818
2. All commits must be signed off with DCO (`-s` flag in git commit)
19-
3. Tests must pass locally:
20-
```bash
21-
pytest -v
22-
```
19+
3. Tests must pass locally: `pytest -v`
2320

2421
### Step-by-Step Release Process
2522

@@ -56,6 +53,8 @@ git push origin v2.5.X
5653

5754
Replace `X` with the patch version number (e.g., `v2.5.1`, `v2.5.2`, etc.).
5855

56+
The tag pattern follows semver: `v[0-9]+.[0-9]+.[0-9]+` or `v[0-9]+.[0-9]+.[0-9]+-*` (prerelease).
57+
5958
#### 4. Monitor the Workflow
6059

6160
The tag push automatically triggers the release workflow (`.github/workflows/release.yml`):
@@ -65,12 +64,13 @@ gh run list --repo kmilodenisglez/fabric-chaincode-python --workflow release.yml
6564
```
6665

6766
Expected workflow steps:
67+
6868
1. ✅ Checkout repository
6969
2. ✅ Set up Python 3.11
7070
3. ✅ Install build dependencies
71-
4. ✅ Build wheel
71+
4. ✅ Build distribution (sdist + wheel)
7272
5. ✅ Upload wheel artifact
73-
6. 📤 (Optional) Publish to PyPI (if `PYPI_API_TOKEN` is configured)
73+
6. 📤 Publish to PyPI (if `PYPI_API_TOKEN` is configured and tag is semver)
7474

7575
### Verifying the Release
7676

@@ -83,6 +83,7 @@ gh run view <RUN_ID> --repo kmilodenisglez/fabric-chaincode-python --log
8383
#### Access the Wheel Artifact
8484

8585
Artifacts are available in GitHub Actions run details:
86+
8687
1. Visit: https://github.com/kmilodenisglez/fabric-chaincode-python/actions
8788
2. Click the successful release run (tagged with `v2.5.X`)
8889
3. Download the `wheel` artifact (contains `.whl` file)
@@ -100,33 +101,35 @@ python -c "import src.fabric_shim; print('✓ Package imported successfully')"
100101

101102
To enable automatic PyPI publishing on releases:
102103

103-
#### 1. Create a PyPI Account
104-
- Go to https://pypi.org/account/register/
105-
- Create an account or use existing credentials
104+
1. Create a PyPI Account
105+
- Go to https://pypi.org/account/register/
106+
- Create an account or use existing credentials
106107

107-
#### 2. Generate an API Token
108-
- Log into PyPI
109-
- Navigate to Account → API Tokens
110-
- Create a new token with "Entire repository" scope
111-
- Copy the token (starts with `pypi-`)
108+
2. Generate an API Token
109+
- Log into PyPI
110+
- Navigate to Account → API Tokens
111+
- Create a new token with "Entire repository" scope
112+
- Copy the token (starts with `pypi-`)
112113

113-
#### 3. Add GitHub Secret
114+
3. Add GitHub Secret
114115

115116
```bash
116117
gh secret set PYPI_API_TOKEN --repo kmilodenisglez/fabric-chaincode-python
117118
# Paste the token when prompted
118119
```
119120

120121
Verify the secret is set:
122+
121123
```bash
122124
gh secret list --repo kmilodenisglez/fabric-chaincode-python
123125
```
124126

125127
### Publishing Process
126128

127129
Once the PyPI token is configured, releases automatically:
128-
1. Build the wheel
129-
2. Attempt to publish to PyPI (continues on error if token is invalid/missing)
130+
131+
1. Build the wheel and sdist
132+
2. Publish to PyPI using [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) (OIDC-based, no need for static token in workflow)
130133

131134
You can also manually publish a built wheel:
132135

@@ -140,11 +143,13 @@ python -m twine upload dist/fabric-chaincode-python-*.whl -u __token__ -p $PYPI_
140143
### Build Fails in Workflow
141144

142145
Check the workflow logs:
146+
143147
```bash
144148
gh run view <RUN_ID> --repo kmilodenisglez/fabric-chaincode-python --log
145149
```
146150

147151
Common issues:
152+
148153
- **Missing dependencies**: Ensure `requirements.txt` and `pyproject.toml` are in sync
149154
- **Import errors**: Verify `setup.py` correctly loads the version without importing the package
150155
- **YAML syntax errors**: Validate `.github/workflows/release.yml` with `yamllint`
@@ -186,3 +191,4 @@ git push origin --delete v2.5.X
186191
- [PyPI API Tokens](https://pypi.org/help/#apitoken)
187192
- [GitHub Actions](https://github.com/features/actions)
188193
- [DCO Sign-off](https://probot.github.io/apps/dco/)
194+
- [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish)

0 commit comments

Comments
 (0)