Skip to content

✨ Add semantic_release.yml for per-directory version lines - #129

Merged
kammce merged 1 commit into
mainfrom
semantic-release-lines
Oct 16, 2026
Merged

kammce merged 1 commit into
mainfrom
semantic-release-lines

Conversation

@kammce

@kammce kammce commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Adds a reusable workflow that releases each version line of a repository independently. A version line is one major version living in its own directory, e.g. v4/ and v5/ in libhal, or v5/ and v6/ in libhal-util.

Usage

concurrency:
  group: semantic-release
  cancel-in-progress: false
jobs:
  release:
    uses: libhal/ci/.github/workflows/[email protected]
    with:
      lines: '[{"major": 4, "dir": "v4"}, {"major": 5, "dir": "v5"}]'
    secrets:
      release_token: ${{ secrets.SEMANTIC_RELEASE }}

A single-directory repository uses one line with "dir": ".".

Rules

The version logic is in .github/scripts/semantic_release.py:

  • Scope: a line only sees its own tags (<major>.*) and only counts commits that change its directory since its last release. A commit that changes several directories counts for each of their lines.
  • Keywords: (minor) or (patch) in a commit subject asks for a release. The highest keyword since the last release wins, so several (patch) commits make one patch release. Commit bodies are ignored, so a squash merge's list of commits, or a message describing these rules (like this PR's own commit), doesn't count. Every intentional keyword in libhal, libhal-util, libhal-arm-mcu and ci history is in a subject line.
  • No (major): it fails the run. Major versions are started by hand: publish the line's first tag yourself and add the line to lines.
  • Pre-releases: a line whose only tags are <major>.0.0-alpha.K cuts <major>.0.0-alpha.K+1 on either keyword. Publishing <major>.0.0 by hand switches it to normal releases.

Because releases are computed from the last tag rather than from the commits in one push, a skipped or failed run is picked up by the next push.

Testing

  • test_semantic_release.py: 20 unit tests that build throwaway git repositories. Run them locally with python3 -m unittest discover -s .github/scripts -p "test_*.py".
  • Run against the real histories of libhal (4.x, 5.x), libhal-util (5.x, 6.x) and ci (5.x). Each reports nothing pending, and util's 6.x line reports that it isn't started yet.
  • Self Check runs the unit tests and a dry run against this repository.

Follow-ups

  • Move libhal and libhal-util to this workflow once 5.x.y includes it.
  • util's 6.x line needs its first tag, 6.0.0-alpha.1, published by hand.

@kammce kammce closed this Oct 15, 2026
@kammce kammce reopened this Oct 15, 2026
@kammce kammce closed this Oct 16, 2026
@kammce kammce reopened this Oct 16, 2026
@kammce
kammce force-pushed the semantic-release-lines branch 2 times, most recently from 82ef647 to 6bc9612 Compare October 16, 2026 23:22
A reusable workflow that releases each version line of a repository (one
major version per directory, e.g. v4/ and v5/) independently. Callers
pass the lines as JSON: [{"major": 4, "dir": "v4"}, ...].

The version logic lives in .github/scripts/semantic_release.py, with
unit tests that build throwaway git repositories:

- A line only sees its own tags and only counts commits that change its
  directory since its last release.
- (minor) and (patch) in a commit subject request a release. The highest
  keyword since the last release wins. Commit bodies are ignored.
- (major) fails the run. Major versions are started by hand.
- A line with only <major>.0.0-alpha.K tags cuts the next alpha.

Self Check runs the tests and a dry run against this repository.
@kammce
kammce force-pushed the semantic-release-lines branch from 6bc9612 to a27bf2d Compare October 16, 2026 23:25
@kammce
kammce merged commit 77d0b2c into main Oct 16, 2026
25 checks passed
@kammce
kammce deleted the semantic-release-lines branch October 16, 2026 23:30
kammce added a commit that referenced this pull request Oct 17, 2026
Adds a semantic-release workflow for this repository, so ci releases are
cut from commit subjects like every other libhal repository instead of
by hand. It calls this repository's semantic_release.yml at the pushed
commit, with one line for 5.x from the repository root.

Merging this releases 5.25.0, the first release with
semantic_release.yml (#129) and the reduced check runs (#130).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant