Implementation:Apache Airflow CustomBuild Hatch Plugin
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Build_System, Release_Engineering |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Concrete tool for building Airflow release artifacts provided by the CustomBuild hatch plugin, towncrier, and sign.sh.
Description
The CustomBuild class extends hatchling's BuilderInterface to compile UI assets and generate git version metadata during build. Towncrier generates RELEASE_NOTES.rst from newsfragment files. The sign.sh script creates GPG signatures and checksums.
Usage
Run hatch build for source distributions. Use towncrier for release notes. Sign with sign.sh.
Code Reference
Source Location
- Repository: Apache Airflow
- File: airflow-core/hatch_build.py (L36-120)
- File: airflow-core/newsfragments/config.toml (L1-52)
- File: dev/sign.sh (L1-32)
Signature
class CustomBuild(BuilderInterface[BuilderConfig, PluginManager]):
PLUGIN_NAME = "custom"
def get_git_version(self) -> str:
"""Extract version from git describe."""
...
def write_git_version(self) -> None:
"""Write git version to metadata file."""
...
def build_standard(self, directory: str, artifacts: Any, **build_data: Any) -> str:
"""Build source distribution with UI assets."""
...
# sign.sh
set -euo pipefail
SIGN_WITH="${SIGN_WITH:-apache.org}"
for name in "${@}"; do
gpg --yes --armor --local-user "$SIGN_WITH" --output "${name}.asc" --detach-sig "${name}"
shasum -a 512 "${name}" > "${name}.sha512"
done
Import
# Build source distribution
hatch build
# Generate release notes
towncrier build --yes
# Sign artifacts
./dev/sign.sh dist/*.tar.gz
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| Git-tagged source | Repository | Yes | Source code with release tag |
| Newsfragments | RST files | Yes | Change descriptions in newsfragments/ |
| GPG key | Key | Yes | Apache signing key identity |
Outputs
| Name | Type | Description |
|---|---|---|
| Source distribution | .tar.gz | Built source package |
| Release notes | RST | Generated RELEASE_NOTES.rst |
| Signatures | .asc files | GPG detached signatures |
| Checksums | .sha512 files | SHA512 checksums |
| Build metadata | YAML | reproducible_build.yaml |
Usage Examples
Build Release Candidate
# 1. Generate release notes
cd airflow-core
towncrier build --yes
# 2. Build source distribution
hatch build
# 3. Sign artifacts
cd ..
./dev/sign.sh dist/apache_airflow-3.1.0rc1.tar.gz
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment