Skip to content

Commit ce93440

Browse files
authored
Merge pull request #295 from OpenTabular/feat/dynamic_versioning
CI: Conventional commit and semantic release
2 parents 3376c95 + d364bce commit ce93440

File tree

11 files changed

+1109
-112
lines changed

11 files changed

+1109
-112
lines changed

.commitlintrc.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"extends": ["@commitlint/config-conventional"],
3+
"rules": {
4+
"type-enum": [
5+
2,
6+
"always",
7+
[
8+
"build",
9+
"chore",
10+
"ci",
11+
"docs",
12+
"feat",
13+
"fix",
14+
"perf",
15+
"refactor",
16+
"revert",
17+
"style",
18+
"test"
19+
]
20+
],
21+
"subject-case": [2, "never", ["upper-case", "pascal-case"]],
22+
"subject-empty": [2, "never"],
23+
"subject-full-stop": [2, "never", "."],
24+
"header-max-length": [2, "always", 72],
25+
"body-leading-blank": [2, "always"],
26+
"footer-leading-blank": [2, "always"]
27+
}
28+
}

.github/workflows/build-publish-pypi.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Semantic Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
9+
permissions:
10+
contents: write
11+
issues: write
12+
pull-requests: write
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
concurrency: release
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.10"
30+
31+
- name: Install Poetry
32+
uses: snok/install-poetry@v1
33+
with:
34+
version: latest
35+
virtualenvs-create: true
36+
virtualenvs-in-project: true
37+
38+
- name: Cache Poetry dependencies
39+
uses: actions/cache@v4
40+
with:
41+
path: .venv
42+
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
43+
44+
- name: Install dependencies
45+
run: |
46+
poetry install
47+
48+
- name: Python Semantic Release
49+
id: release
50+
uses: python-semantic-release/[email protected]
51+
with:
52+
github_token: ${{ secrets.GITHUB_TOKEN }}
53+
env:
54+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
55+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- name: Publish package distributions to GitHub Releases
58+
uses: python-semantic-release/upload-to-gh-release@main
59+
if: steps.release.outputs.released == 'true'
60+
with:
61+
github_token: ${{ secrets.GITHUB_TOKEN }}
62+
tag: ${{ steps.release.outputs.tag }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,5 @@ examples/lightning_logs
172172
docs/_build/doctrees/*
173173
docs/_build/html/*
174174

175-
175+
dev
176176
dev/*

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@ repos:
2929
- yaml
3030
- markdown
3131
- json
32+
33+
- repo: https://github.com/commitizen-tools/commitizen
34+
rev: v3.29.1
35+
hooks:
36+
- id: commitizen
37+
stages: [commit-msg]

README.md

Lines changed: 62 additions & 56 deletions
Large diffs are not rendered by default.

docs/contributing.md

Lines changed: 126 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
## Contribution Guidelines
32

43
Thank you for considering contributing to our Python package! We appreciate your time and effort in helping us improve our project. Please take a moment to review the following guidelines to ensure a smooth and efficient contribution process.
@@ -16,9 +15,9 @@ To set up the development environment for this Python package, follow these step
1615
1. Clone the repository to your local machine using the command:
1716

1817
```
19-
git clone https://github.com/basf/mamba-tabular
18+
git clone https://github.com/OpenTabular/DeepTab
2019
21-
cd mamba-tabular
20+
cd DeepTab
2221
```
2322

2423
2. Install tools required for setting up development environment:
@@ -45,7 +44,7 @@ just install
4544
In case you are not able to install `just`, you can follow the below steps to set up the development environment:
4645

4746
```
48-
cd mamaba-tabular
47+
cd DeepTab
4948
5049
poetry install
5150
@@ -60,26 +59,142 @@ pip install -r docs/requirements_docs.txt
6059

6160
**Note:** You can also set up a virtual environment to isolate your development environment.
6261

63-
6462
### How to Contribute
6563

6664
1. Create a new branch from the `develop` branch for your contributions. Please use descriptive and concise branch names.
6765
2. Make your desired changes or additions to the codebase.
6866
3. Ensure that your code adheres to [PEP8](https://peps.python.org/pep-0008/) coding style guidelines.
6967
4. Write appropriate tests for your changes, ensuring that they pass.
70-
- `make test`
68+
- `make test`
7169
5. Update the documentation and examples, if necessary.
7270
6. Build the html documentation and verify if it works as expected. We have used Sphinx for documentation, you could build the documents as follows:
73-
- `cd src/docs`
74-
- `make clean`
75-
- `make html`
71+
- `cd src/docs`
72+
- `make clean`
73+
- `make html`
7674
7. Verify the html documents created under `docs/_build/html` directory. `index.html` file is the main file which contains link to all other files and doctree.
7775

78-
8. Commit your changes with a clear and concise commit message.
76+
8. Commit your changes following the Conventional Commits specification (see below).
7977
9. Submit a pull request from your branch to the development branch of the original repository.
8078
10. Wait for the maintainers to review your pull request. Address any feedback or comments if required.
8179
11. Once approved, your changes will be merged into the main codebase.
8280

81+
### Release Workflow
82+
83+
This project uses automated semantic versioning and releases. Here's how releases work:
84+
85+
#### Automated Release Process
86+
87+
```
88+
1. Make Changes → 2. Conventional Commit → 3. Merge to Master → 4. Automated Release
89+
```
90+
91+
**Step-by-Step:**
92+
93+
1. **Development Phase**
94+
95+
- Create feature branch from `develop`
96+
- Make your changes
97+
- Commit using conventional commits (e.g., `feat:`, `fix:`)
98+
99+
2. **Merge to Develop**
100+
101+
- Create PR to `develop` branch
102+
- After review, merge to `develop`
103+
- ReadTheDocs dev documentation updates automatically
104+
105+
3. **Merge to Master** (Triggers Release)
106+
107+
- Merge `develop` to `master`
108+
- GitHub Actions semantic-release workflow runs automatically
109+
110+
4. **Automated Release (on Master)**
111+
- ✅ Analyzes conventional commits since last release
112+
- ✅ Determines version bump (major/minor/patch)
113+
- ✅ Updates version in `pyproject.toml` and `__version__.py`
114+
- ✅ Generates/updates `CHANGELOG.md`
115+
- ✅ Creates git tag (e.g., `v1.7.0`)
116+
- ✅ Builds package (`poetry build`)
117+
- ✅ Publishes to PyPI
118+
- ✅ Creates GitHub Release with notes
119+
120+
#### What Triggers a Release?
121+
122+
| Commit Type | Version Bump | PyPI Release |
123+
| -------------------------------------------------------- | ------------- | ------------ |
124+
| `feat:` | Minor (1.x.0) | ✅ Yes |
125+
| `fix:` | Patch (1.6.x) | ✅ Yes |
126+
| `perf:` | Patch (1.6.x) | ✅ Yes |
127+
| `feat!:` or `BREAKING CHANGE:` | Major (x.0.0) | ✅ Yes |
128+
| `docs:`, `style:`, `refactor:`, `test:`, `chore:`, `ci:` | None | ❌ No |
129+
130+
#### Example Scenarios
131+
132+
**Scenario 1: Documentation Update (No Release)**
133+
134+
```bash
135+
git commit -m "docs: update API reference"
136+
# Merge to master → No version bump, no PyPI release
137+
```
138+
139+
**Scenario 2: Bug Fix (Patch Release)**
140+
141+
```bash
142+
git commit -m "fix: resolve memory leak in dataloader"
143+
# Merge to master → Version 1.6.1 → 1.6.2 → PyPI release
144+
```
145+
146+
**Scenario 3: New Feature (Minor Release)**
147+
148+
```bash
149+
git commit -m "feat(models): add TabNet architecture"
150+
# Merge to master → Version 1.6.1 → 1.7.0 → PyPI release
151+
```
152+
153+
**Scenario 4: Breaking Change (Major Release)**
154+
155+
```bash
156+
git commit -m "feat!: remove Python 3.9 support
157+
158+
BREAKING CHANGE: Python 3.10 is now the minimum required version"
159+
# Merge to master → Version 1.6.1 → 2.0.0 → PyPI release
160+
```
161+
162+
#### Important Notes
163+
164+
- **Only master branch** triggers releases
165+
- **Semantic-release is fully automated** - no manual version bumping needed
166+
- **Never manually edit version numbers** in `pyproject.toml` or `deeptab/__version__.py` - they are automatically updated by semantic-release
167+
- **PyPI token** is configured in GitHub repository secrets
168+
- **Review commits carefully** before merging to master (they determine the version!)
169+
170+
#### Working with Updated Versions
171+
172+
**Q: What happens if I create a branch from `develop` after a release?**
173+
174+
After a release is merged to `master`, the version files are updated automatically. To get the latest version:
175+
176+
1. **Sync develop with master** (maintainers do this):
177+
178+
```bash
179+
git checkout develop
180+
git merge master
181+
git push origin develop
182+
```
183+
184+
2. **Update your local develop branch** (before creating new branches):
185+
186+
```bash
187+
git checkout develop
188+
git pull origin develop
189+
```
190+
191+
3. **Create your feature branch from updated develop**:
192+
```bash
193+
git checkout -b feature/my-new-feature
194+
```
195+
196+
This ensures your branch has the correct version number as a starting point. Don't worry if the version seems "old" in your branch - semantic-release will calculate the correct new version based on commits when merging to master.
197+
83198
### Submitting Contributions
84199

85200
When submitting your contributions, please ensure the following:
@@ -93,7 +208,7 @@ When submitting your contributions, please ensure the following:
93208

94209
### Issue Tracker
95210

96-
If you encounter any bugs, have feature requests, or need assistance, please visit our [Issue Tracker](https://github.com/basf/mamba-tabular/issues). Make sure to search for existing issues before creating a new one.
211+
If you encounter any bugs, have feature requests, or need assistance, please visit our [Issue Tracker](https://github.com/OpenTabular/DeepTab/issues). Make sure to search for existing issues before creating a new one.
97212

98213
### License
99214

justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ lint:
3232
format:
3333
poetry run docformatter --in-place --recursive --wrap-summaries 120 --wrap-descriptions 120 .
3434
poetry run ruff format .
35+
36+
# create a conventional commit using commitizen
37+
commit:
38+
poetry run cz commit

0 commit comments

Comments
 (0)