ESI Releases
Note that relevant info on USGS code distribution and repository metadata can be found at <https://www.usgs.gov/products/software/software-management/distribution-usgs-code>
Description
This repository provides a CLI release tool, releases, for use in the repositories of the USGS Engineering Seismology and Impacts GitLab group.
A release increments the major, minor, or patch version and updates the project metadata in code.json and the notes in CHANGELOG.md to match. In code.json, a copy of the latest entry is added at the top of the file, with:
versionset to the new version tag, e.g.v1.2.4date.metadataLastUpdatedset to today- these URLs changed to point at the new tag:
downloadURL, the archive of the tagged sourcedisclaimerURL- the
URLof each license underpermissions
The URLs are updated by replacing the current version in them. A URL without the current version is pointed at the new tag if it is empty or a GitLab file link (such as -/tree/main/LICENSE.md); otherwise it is left unchanged with a warning.
This tool assumes that version tags have the form `v#.#.#`.
Installation
It can be installed directly from source by calling pip in the cloned repository base directory:
pip install .
Developers or advanced users may wish to include optional dependencies and install in editable mode:
pip install -e .[dev,test,build]
The package is also available on PyPI and can be installed with:
pip install esi-releases
Usage
This CLI tool supports three levels of version increment, depending on the scope of changes to a repository's code, following the conventions of Semantic Versioning:
<Major>.<Minor>.<Patch>
- Major version increments are used when new features that are backwards incompatible are introduced
- Minor version increments are used when new features that retain backwards compatibility are introduced
- Patch increments are used for bugfixes that do not introduce new features
| Command | Example |
|---|---|
releases patch |
v1.0.0 → v1.0.1 |
releases minor |
v1.0.1 → v1.1.0 |
releases major |
v1.1.0 → v2.0.0 |
Run these commands from the repository root. Useful options:
--dry-runshows what would change without changing anything.--commitcreates a release branch and commits the changes to it. The branch is namedv<version>.rc<N>, using the first unusedN, unless you pass--branch NAME. The working tree must be clean.--code-json PATHand--changelog PATHuse files other thancode.jsonandCHANGELOG.md.--no-changelogleaves the changelog alone.
A release stops, without changing anything, if the new version is already tagged in git, which usually means a release was made without updating code.json.
Changelog
Notes for unreleased changes are collected under a # main (or ## main) heading at the top of CHANGELOG.md. A release moves them under a new ## <version> / <date> heading:
# main
## 1.0.1 / 2026-11-19
- Fix a bug (!12)
## 1.0.0 / 2026-10-01
...
The release stops, without changing any files, if there are no notes under main or they only contain the template placeholder. If there is no CHANGELOG.md, only code.json is updated.
Other commands
-
releases tagtags a merged release. It checks that:mainis checked out, clean, and neither ahead of nor behind its upstream branch (as of your last fetch, so rungit pull --tagsfirst);code.jsonand the changelog agree on the version and passreleases check;- the version is newer than every existing tag.
It then creates the annotated tag (e.g.
git tag -a v1.0.1 -m "Version 1.0.1") and prints thegit pushthat starts the release pipeline. It never pushes. -
releases changelog [VERSION]prints the changelog notes for a release (default: the latest), for example to paste into a GitLab release. -
releases checkreports problems withcode.json,CHANGELOG.mdand the git tags. Examples: the latest entry's URLs don't reference its version, versions are out of order, the changelog doesn't matchcode.json, or a tag is newer thancode.json. It exits with status 1 if it finds any, so it can run in CI. -
releases currentprints the current version tag, for use in scripts.
Help for any command is available with --help, e.g. releases patch --help.
Release workflow
git checkout main && git pull --tags
releases minor --dry-run # review the changes
releases minor --commit # creates branch v<version>.rc0 with the release commit
git push -u origin <branch> # then open a merge request into main and merge it
git checkout main && git pull --tags
releases tag # prints the push that starts the release pipeline
Creating the GitLab release automatically
The notes for a GitLab release can come from the changelog in the tag pipeline, instead of being pasted in by hand. These jobs are a starting point for the shared CI templates. They have not been tested in the ESI pipelines, and the release-cli image may need to come from the internal registry.
Release Notes:
stage: deploy
rules:
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
script:
- pip install esi-releases
- releases changelog "$CI_COMMIT_TAG" > release_notes.md
artifacts:
paths:
- release_notes.md
Create GitLab Release:
stage: deploy
needs:
- Release Notes
image: registry.gitlab.com/gitlab-org/release-cli:latest
before_script: []
rules:
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
script:
- echo "Creating release $CI_COMMIT_TAG"
release:
tag_name: $CI_COMMIT_TAG
name: $CI_COMMIT_TAG
description: release_notes.md
Metadata
Release files for esi-releases 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| esi_releases-0.2.0.tar.gz | 35.8 kB | Without provenance | Details for esi_releases-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| esi_releases-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for esi_releases-0.2.0-py3-none-any.whl |
Total release size: 62.7 kB
Release files / esi_releases-0.2.0.tar.gz
| Download URL | esi_releases-0.2.0.tar.gz |
|---|---|
| Size | 35.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
598b0bb7a5022efa5edf644c931bc78c23ffe33bed58e668f5f99383ee6ab433
|
|
BLAKE2b-256 checksum How to use checksums |
9d8960025a965a35e89256fcd89618409853a02bb5ee6187e66cd5aa9718bdc4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / esi_releases-0.2.0-py3-none-any.whl
| Download URL | esi_releases-0.2.0-py3-none-any.whl |
|---|---|
| Size | 26.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b6ecb77048ca2c9eaf46574a28e310c27d93d202e1eb103e4d6582eb5253fb0
|
|
BLAKE2b-256 checksum How to use checksums |
11d0435b9ecf550dcb34447b9e6cc2567ac5e39d56346103ded05203b1952669
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for esi-releases 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.