Skip to content

Commit 8b26dbc

Browse files
authored
Merge pull request #306 from OpenTabular/develop
feat: conventional commit and semantic release
2 parents 2d299d3 + 4f47485 commit 8b26dbc

12 files changed

Lines changed: 1319 additions & 112 deletions

.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/python-semantic-release@v9.12.0
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 }}

.github/workflows/sync-develop.yml

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
name: Sync Develop with Master
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Semantic Release"]
6+
types:
7+
- completed
8+
branches:
9+
- master
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
sync-develop:
17+
runs-on: ubuntu-latest
18+
# Only run if semantic release succeeded and actually released
19+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Configure Git
29+
run: |
30+
git config user.name "github-actions[bot]"
31+
git config user.email "github-actions[bot]@users.noreply.github.com"
32+
33+
- name: Fetch all branches
34+
run: |
35+
git fetch origin master:master
36+
git fetch origin develop:develop
37+
38+
- name: Check if develop is behind master
39+
id: check
40+
run: |
41+
git checkout develop
42+
BEHIND=$(git rev-list --count develop..master)
43+
echo "commits_behind=$BEHIND" >> $GITHUB_OUTPUT
44+
45+
if [ "$BEHIND" -eq "0" ]; then
46+
echo "Develop is already up to date with master"
47+
echo "needs_sync=false" >> $GITHUB_OUTPUT
48+
else
49+
echo "Develop is $BEHIND commits behind master"
50+
echo "needs_sync=true" >> $GITHUB_OUTPUT
51+
fi
52+
53+
- name: Attempt automatic merge
54+
id: merge
55+
if: steps.check.outputs.needs_sync == 'true'
56+
run: |
57+
git checkout develop
58+
59+
# Try to merge master into develop
60+
if git merge master --no-edit; then
61+
echo "Merge successful - no conflicts"
62+
echo "status=success" >> $GITHUB_OUTPUT
63+
echo "has_conflicts=false" >> $GITHUB_OUTPUT
64+
else
65+
echo "Merge has conflicts"
66+
git merge --abort
67+
echo "status=conflict" >> $GITHUB_OUTPUT
68+
echo "has_conflicts=true" >> $GITHUB_OUTPUT
69+
fi
70+
71+
- name: Push changes if no conflicts
72+
if: steps.merge.outputs.status == 'success'
73+
run: |
74+
git push origin develop
75+
echo "✅ Successfully synced develop with master"
76+
77+
- name: Get latest version tag
78+
id: version
79+
if: steps.merge.outputs.has_conflicts == 'true'
80+
run: |
81+
VERSION=$(git describe --tags --abbrev=0 master)
82+
echo "tag=$VERSION" >> $GITHUB_OUTPUT
83+
84+
- name: Create PR if conflicts exist
85+
if: steps.merge.outputs.has_conflicts == 'true'
86+
uses: peter-evans/create-pull-request@v6
87+
with:
88+
token: ${{ secrets.GITHUB_TOKEN }}
89+
branch: sync/master-to-develop-${{ steps.version.outputs.tag }}
90+
base: develop
91+
title: "chore: sync develop with master ${{ steps.version.outputs.tag }}"
92+
body: |
93+
## 🔄 Automatic Sync: Master → Develop
94+
95+
This PR syncs `develop` branch with the latest release from `master`.
96+
97+
**Release Version:** `${{ steps.version.outputs.tag }}`
98+
**Triggered by:** Semantic Release workflow completion
99+
100+
### ⚠️ Merge Conflicts Detected
101+
102+
Automatic merge failed due to conflicts. Please resolve conflicts manually:
103+
104+
```bash
105+
git checkout develop
106+
git pull origin develop
107+
git merge master
108+
# Resolve conflicts
109+
git add .
110+
git commit
111+
git push origin develop
112+
```
113+
114+
### Changes from Master:
115+
- Updated version files (`pyproject.toml`, `__version__.py`)
116+
- Updated `CHANGELOG.md`
117+
- New release tag: `${{ steps.version.outputs.tag }}`
118+
119+
---
120+
121+
🤖 This PR was created automatically by the sync-develop workflow.
122+
labels: |
123+
chore
124+
sync
125+
automated
126+
assignees: ${{ github.repository_owner }}
127+
128+
- name: Add comment with instructions
129+
if: steps.merge.outputs.has_conflicts == 'true'
130+
uses: peter-evans/create-or-update-comment@v4
131+
with:
132+
issue-number: ${{ steps.pr.outputs.pull-request-number }}
133+
body: |
134+
### 📋 Manual Merge Instructions
135+
136+
Since automatic merge failed, follow these steps:
137+
138+
1. **Checkout and update develop:**
139+
```bash
140+
git checkout develop
141+
git pull origin develop
142+
```
143+
144+
2. **Merge master:**
145+
```bash
146+
git merge master
147+
```
148+
149+
3. **Resolve conflicts** in:
150+
- `pyproject.toml` (keep master version)
151+
- `deeptab/__version__.py` (keep master version)
152+
- `CHANGELOG.md` (merge both)
153+
- Any other conflicting files
154+
155+
4. **Complete the merge:**
156+
```bash
157+
git add .
158+
git commit -m "chore: sync develop with master ${{ steps.version.outputs.tag }}"
159+
git push origin develop
160+
```
161+
162+
5. **Close this PR** (changes will be in develop)
163+
164+
💡 **Tip:** Version files should always use master's values after a release.
165+
166+
- name: Summary
167+
if: always()
168+
run: |
169+
echo "## Sync Develop Workflow Summary" >> $GITHUB_STEP_SUMMARY
170+
echo "" >> $GITHUB_STEP_SUMMARY
171+
172+
if [ "${{ steps.check.outputs.needs_sync }}" == "false" ]; then
173+
echo "✅ Develop is already up to date with master" >> $GITHUB_STEP_SUMMARY
174+
elif [ "${{ steps.merge.outputs.status }}" == "success" ]; then
175+
echo "✅ Successfully merged master into develop automatically" >> $GITHUB_STEP_SUMMARY
176+
echo "" >> $GITHUB_STEP_SUMMARY
177+
echo "**Commits synced:** ${{ steps.check.outputs.commits_behind }}" >> $GITHUB_STEP_SUMMARY
178+
elif [ "${{ steps.merge.outputs.has_conflicts }}" == "true" ]; then
179+
echo "⚠️ Merge conflicts detected - PR created for manual resolution" >> $GITHUB_STEP_SUMMARY
180+
echo "" >> $GITHUB_STEP_SUMMARY
181+
echo "**Action required:** Review and merge the auto-created PR" >> $GITHUB_STEP_SUMMARY
182+
fi

.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]

0 commit comments

Comments
 (0)