Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Commit Message Check

on:
pull_request:
types: [opened, synchronize, edited]

jobs:
commit-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install commitizen
run: pip install commitizen

- name: Validate commit messages
run: |
cz check --rev-range origin/main..HEAD

39 changes: 39 additions & 0 deletions .github/workflows/semantic-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Semantic Release

on:
push:
branches:
- main

permissions:
contents: write
id-token: write

jobs:
release:
if: github.repository == 'aboutcode-org/scancode.io'
runs-on: ubuntu-latest
concurrency:
group: release
cancel-in-progress: false

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install release dependencies
run: |
python -m pip install --upgrade pip
pip install build python-semantic-release

- name: Run Semantic Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: semantic-release publish
66 changes: 37 additions & 29 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
# Release instructions for `ScanCode.io`

### Automated release workflow

- Create a new `release-x.x.x` branch
- Update the version in:
- `pyproject.toml`
- `scancodeio/__init__.py`
- `CHANGELOG.rst` (set date)
- Commit and push this branch
- Create a PR and merge once approved
- Tag and push that tag. This will trigger the `pypi-release.yml` GitHub workflow that
takes care of building the dist release files and upload those to pypi:
```
VERSION=vx.x.x # <- Set the new version here
git tag -a $VERSION -m ""
git push origin $VERSION
```
- Review the GitHub release created by the workflow at
https://github.com/aboutcode-org/scancode.io/releases

### Manual build

```
cd scancode.io
source .venv/bin/activate
python -m pip install build
python -m build --sdist --wheel --outdir dist/ .
```

The distribution files will be available in the local `dist/` directory.
## 🚀 Automated Release Workflow

Releases are fully automated using **python-semantic-release**.

When commits following the Conventional Commits specification are merged into the `main` branch:

- The next semantic version is computed automatically.
- `pyproject.toml` and `scancodeio/__init__.py` are updated.
- `CHANGELOG.rst` is generated/updated automatically.
- A Git tag is automatically created (vX.Y.Z).
- The tag triggers the existing PyPI publishing workflow.
- The PyPI workflow builds distributions and creates the GitHub Release.

No manual version bumping, branching, or tagging is required.

---

## 📌 Commit Message Requirements

Commits must follow the Conventional Commits format:

- `feat: add new feature`
- `fix: correct issue in pipeline`
- `feat!: introduce breaking change`
- `chore: maintenance update`

The commit type determines the version bump:

- `fix` → patch
- `feat` → minor
- `feat!` or `BREAKING CHANGE:` → major

---

## 🛠 Manual Build (Optional)

If you need to build distribution files locally:
26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ dev = [
"sphinx-rtd-theme==3.0.2",
"sphinx-rtd-dark-mode==1.3.0",
"sphinxcontrib-django==2.5",
# Commit convention enforcement
"commitizen==3.29.0",
]
android_analysis = [
"android_inspector==0.0.1"
Expand Down Expand Up @@ -201,3 +203,27 @@ max-complexity = 10
"**/test_spdx.py*" = ["S101"]
# Allow complexity in management commands
"scanpipe/management/commands/*" = ["C901"]

[tool.semantic_release]
commit_parser = "conventional"
build_command = "python3 -m build"
upload_to_pypi = false
upload_to_release = false
tag_format = "v{version}"
changelog_file = "CHANGELOG.rst"
changelog_style = "rst"
version_variable = [
"scancodeio/__init__.py:VERSION"
]
version_toml = [
"pyproject.toml:project.version"
]

[tool.commitizen]
name = "cz_conventional_commits"
version_provider = "scm"
version_files = [
"pyproject.toml:project.version",
"scancodeio/__init__.py:VERSION"
]
tag_format = "v$version"