ITW Python Builder
Standardized Django and Angular deployment pipeline with Docker, testing, SonarQube integration, automatic changelog generation, GitLab issue creation, and code quality enforcement.
Features
- Automated deployment with semantic versioning
- Docker/Podman-based build and push pipeline (backend)
- Angular build, packaging and upload to the GitLab Package Registry (frontend)
- Angular SSR scaffolding and SSR builds
- Automated testing with coverage
- SonarQube static code analysis
- Pylint linting with SonarQube integration
- Quality gates - deploy only when tests pass
- Automatic changelog generation from commit trailers
- Automatic
CHANGELOG.mdcreation and propagation tostaging/develop - GitLab issue creation from a markdown file
- Cached GitLab authentication
- Support for local and production pipelines
- Global CLI tool
- Automatic venv detection per project
Installation
pip install itw-python-builder
Install globally (outside any project venv). The itw command becomes available system-wide.
Check the installed version:
itw --version
Quick Start
-
Navigate to your project directory (Django projects must have a
.venvorvenv): -
Authenticate with GitLab:
itw login
- Initialize versioning — run it on
stagingfirst, then onmaster:
git checkout staging && itw tag-init # creates v.0.0.1-rc1
git checkout master && itw tag-init # promotes the latest staging RC to -release
- Run local pipeline:
itw pipelinelocal
- Deploy to staging:
itw incrementrc
- Deploy to production:
itw incrementpatch
Available Commands
Deployment Commands
itw incrementpatch— Increment patch version and deployitw incrementminor— Increment minor version and deployitw incrementmajor— Increment major version and deployitw incrementrc— Increment release candidate (staging)itw release— Promote RC to stable release (master)
Authentication Commands
itw login— Capture and cache a GitLab token (backend also logs into the container registry)itw logout— Forget the cached token and log out of the container registry
GitLab Issue Commands
itw task-init— Create aTASK.mdtemplate in the current directoryitw task --file=TASK.md— Create GitLab issues from a markdown file
Local Development Commands
itw pipelinelocal— Run full local pipeline (lint → test → analyze → build)itw lintlocal— Run pylint with human-readable outputitw lint— Run pylint and generate SonarQube report filesitw buildlocal— Build Docker image locallyitw test— Run tests with coverageitw analyze— Run SonarQube analysisitw changelog— Generate changelog manuallyitw tag-init— Initialize version tagging (see below)itw ssr-init— Scaffold Angular SSR (one-time, frontend only)
Version Initialization
itw tag-init is branch-aware and must be run from staging or master:
- On staging it creates the first release candidate,
v.0.0.1-rc1. - On master it reads the latest
-rctag reachable fromstaging(local ororigin/staging, after fetching tags) and creates that same version as a release. For examplev.0.0.2-rc10on staging becomesv.0.0.2-releaseon master.
The VERSION file is written with the tag that was created. The command stops with a clear error when there is no staging branch, no release candidate to promote, or when the tag already exists.
Skip Pipeline
itw incrementpatch --skip-pipeline
Run a Subset of Tests
# Django: an app or a single test module
itw test --target=users
itw test --target=users.test_views
# Angular: a directory or a spec name
itw test --target=core
itw test --target=core.service
SSR Builds
Frontend projects scaffolded with itw ssr-init build through the SSR npm scripts when --ssr is passed:
itw incrementrc --ssr
itw incrementpatch --ssr
Virtual Environment Detection
itw is installed globally but automatically detects the project's virtual environment (.venv or venv) in the current directory. Tasks that need Python/Django dependencies (test, lint, analyze) activate the venv automatically — no need to manually activate it.
If no venv is found, those tasks will error with a clear message. Tasks that only use git (like changelog, tag-init, buildlocal) work without a venv.
Linting
The pipeline runs pylint automatically on every deployment and generates report files for SonarQube. The .pylintrc configuration is shipped with the package — no config files needed in your project.
# Review issues with human-readable output
itw lintlocal
# Generate report files for SonarQube
itw lint
# Use a custom pylint configuration
itw lint --pylintrc=.pylintrc
Add this to your sonar-project.properties:
sonar.python.pylint.reportPaths=pylint-report.txt
Changelog Generation
Changelog entries are generated automatically on every deployment based on commit messages. To categorize a commit, add a Changelog: trailer to the commit body:
add user authentication
Changelog: added
Available categories: added, fixed, changed, deprecated, removed, security, performance, tests, docs, refactor
Commits without a trailer appear under Other Changes. The CHANGELOG.md file is committed and pushed automatically with each deployment.
If CHANGELOG.md does not exist in the current directory it is created automatically — including when there are no new commits since the last tag, so the deployment never fails on a missing file.
Changelog Propagation
After a successful deployment the changelog is synced forward through a temporary git worktree:
- from
master→staginganddevelop - from
staging→develop
Propagation is skipped when the working tree is not clean or when there is nothing new to sync.
GitLab Issue Creation
Create GitLab issues from a markdown file instead of the web UI.
Generate the template:
itw task-init
Then fill it in and run:
itw task --file=TASK.md
task-init refuses to overwrite an existing TASK.md.
Template
<!-- OPTIONAL -->
/glab_host
/glab_username
/glab_token
<!-- REQUIRED -->
/title
<!-- OPTIONAL -->
/repo
/milestone
/milestone-start YYYY-MM-DD
/milestone-end YYYY-MM-DD
/assignee
/label
/estimate
/due YYYY-MM-DD
<!-- OPTIONAL -->
## Acceptance Criteria
- [ ]
- [ ]
## Acceptance Criteria
<!-- OPTIONAL -->
## Comment
## Comment
Every key except /title is optional. Leaving a key empty is allowed — empty keys are simply not sent to GitLab. The date keys keep the YYYY-MM-DD format in the template and are treated as empty until you replace them.
Any text outside the directives becomes the issue description. Create several issues from one file by separating the blocks with a line containing only ===.
Directives
| Directive | Description |
|---|---|
/glab_host |
GitLab host to authenticate against |
/glab_username |
GitLab username |
/glab_token |
GitLab personal access token |
/title |
Issue title (required) |
/repo |
Target project path |
/milestone |
Milestone title |
/milestone-start |
Milestone start date, used only when the milestone is created |
/milestone-end |
Milestone due date, used only when the milestone is created |
/assignee |
Username to assign the issue to |
/label |
Comma-separated labels |
/estimate |
Time estimate (e.g. 3h) |
/due |
Issue due date |
Authentication
Either provide all three of /glab_host, /glab_username and /glab_token, or none of them. Providing only some of them is an error.
When no credentials are given, itw uses the .git directory in the current folder to detect the GitLab host and project, and the token cached by itw login.
Target Repository
With no /repo, the target is resolved by walking the current repository's namespace upward looking for a _pm project. If several are found you are prompted to pick one.
With /repo, leading and trailing slashes are stripped automatically, and full URLs or SSH remotes are accepted:
/repo /tools/itw_python_builder/ → tools/itw_python_builder
/repo https://git.it-works.io/tools/x.git → tools/x
/repo git@git.it-works.io:tools/x.git → tools/x
Milestones, Labels and Duplicates
Milestones, labels and issue titles are matched with a shared fuzzy comparison at 95% similarity, so small differences in spacing or casing still count as a match. The threshold is a single constant (SIMILARITY_THRESHOLD in task_utils.py) if you need to tune it.
- Milestone — a similar existing milestone is reused; otherwise it is created (with the start/end dates when both are given).
- Label — a similar existing label is linked and logged in white; a new one is created and logged in green. An empty
/labelis never sent to GitLab. - Duplicate issues — before creating, the target project is checked for a similar title within the same milestone (or among issues with no milestone). If one exists the issue is not created and a white log line reports it.
Acceptance Criteria and Comments
The ## Acceptance Criteria section must be opened and closed with the same header. When omitted or left with empty checkboxes, a default checklist is applied.
The ## Comment section, opened and closed the same way, is posted as a note on the issue after it is created.
Requirements
- Python 3.10+
- Podman
- Git
- SonarQube server
- Node.js and npm (frontend projects)
Configuration
Environment Variables
Add to your project .env:
SONAR_HOST_URL=https://your-sonar-server
SONAR_TOKEN=your-token
GIT_DEPTH=0
Project Files Required
- Git repository with
develop,staging, andmasterbranches VERSIONfile in project root (backend) orpackage.json(frontend)Dockerfile(backend)sonar-project.properties
License
MIT
Metadata
Release files for itw-python-builder 0.2.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| itw_python_builder-0.2.14.tar.gz | 45.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| itw_python_builder-0.2.14-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 92.2 kB
Release files / itw_python_builder-0.2.14.tar.gz
| Download URL | itw_python_builder-0.2.14.tar.gz |
|---|---|
| Size | 45.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
784789b568b24f272a629aa7123b76452a149952e78b22fadc4db58a22e8ea7b
|
|
BLAKE2b-256 checksum How to use checksums |
59d18bd1facd29ae7a4283e156ba4edf30cda67fbc339322f4536245d29865c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / itw_python_builder-0.2.14-py3-none-any.whl
| Download URL | itw_python_builder-0.2.14-py3-none-any.whl |
|---|---|
| Size | 46.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1cec15b0423d65100d0257a68fafd3090eabca900bf50ffc0e4efed9800d43dd
|
|
BLAKE2b-256 checksum How to use checksums |
257034c858970336995d2e05f77e01358f2e140733d6bd51f6d4b1c4bce06833
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|