Forgejo Action to create a semver tag since the latest tag based on conventional commits.
- TypeScript 100%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| .vscode | ||
| dist | ||
| src | ||
| .gitignore | ||
| action.yml | ||
| LICENSE | ||
| package.json | ||
| pnpm-lock.yaml | ||
| README.md | ||
| tsconfig.json | ||
create-semver-tag
A Forgejo/GitHub Action that inspects commits since the last tag, determines whether a SemVer bump is required using the Conventional Commits standard, and creates and pushes the new tag automatically.
How it works
-
Finds the most recent tag that matches the configured prefix (e.g.
v*). -
Collects every commit between that tag and
HEAD(or all commits when no tag exists yet). -
Classifies each commit message and picks the highest required bump:
Commit pattern Bump BREAKING CHANGE:footer, ortype!:major feat:minor fix:,perf:,revert:patch Anything else ( chore:,docs:, …)(none) -
If a bump is required, creates the new tag locally and pushes it to
origin.
Usage
Forgejo
- uses: jonasclaes/create-semver-tag@v1
GitHub Actions
- uses: jonasclaes/create-semver-tag@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
Note:
actions/checkoutmust run withfetch-depth: 0so that the full tag history is available.
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: jonasclaes/create-semver-tag@v1
Inputs
| Input | Description | Default |
|---|---|---|
token |
Token used to push the new tag. | forgejo.token || github.token |
tag_prefix |
Prefix prepended to every version tag. | v |
initial_version |
Version to use when no previous tag exists. | 0.1.0 |
default_bump |
Minimum bump when commits don't mandate one. major | minor | patch | none |
none |
dry_run |
When true, determines the bump and sets outputs but does not create or push a tag. |
false |
Outputs
| Output | Description |
|---|---|
tag |
The newly created tag (e.g. v1.3.0). Empty when no bump was needed. |
previous_tag |
The tag that existed before the bump. Empty when there was no previous tag. |
type |
The bump type applied: major, minor, or patch. Empty when no bump was needed. |
Advanced usage
Using the outputs in subsequent steps
- uses: jonasclaes/create-semver-tag@v1
id: semver
- if: steps.semver.outputs.tag != ''
run: echo "Released ${{ steps.semver.outputs.tag }} (was ${{ steps.semver.outputs.previous_tag }}, bump type: ${{ steps.semver.outputs.type }})"
Always bump at least patch
- uses: jonasclaes/create-semver-tag@v1
with:
default_bump: patch
Custom tag prefix
- uses: jonasclaes/create-semver-tag@v1
with:
tag_prefix: "release-" # produces e.g. release-1.2.3
Start from a specific version on first release
- uses: jonasclaes/create-semver-tag@v1
with:
initial_version: "1.0.0" # first tag will be v1.0.0 (or v1.1.0 / v2.0.0 depending on commits)