fallback to version in package json

This commit is contained in:
2026-03-14 18:15:33 +01:00
parent 69fe519f7a
commit c5cd0f0430
2 changed files with 10 additions and 10 deletions

View File

@@ -83,6 +83,8 @@ runs:
} }
resolve_release_line() { resolve_release_line() {
local package_version
if [[ -n "${INPUT_RELEASE_LINE}" ]]; then if [[ -n "${INPUT_RELEASE_LINE}" ]]; then
if ! validate_release_line "${INPUT_RELEASE_LINE}"; then if ! validate_release_line "${INPUT_RELEASE_LINE}"; then
echo "Invalid release_line input '${INPUT_RELEASE_LINE}'. Expected format: <major>.<minor>" >&2 echo "Invalid release_line input '${INPUT_RELEASE_LINE}'. Expected format: <major>.<minor>" >&2
@@ -102,16 +104,13 @@ runs:
return 0 return 0
fi fi
if [[ "${BRANCH}" == "develop" ]]; then package_version="$(read_package_version)"
local package_version if [[ "${package_version}" =~ ^([0-9]+)\.([0-9]+)\.[0-9]+([-.].*)?$ ]]; then
package_version="$(read_package_version)" echo "${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
if [[ "${package_version}" =~ ^([0-9]+)\.([0-9]+)\.[0-9]+([-.].*)?$ ]]; then return 0
echo "${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
return 0
fi
fi fi
echo "Unable to determine release line for branch '${BRANCH}'. Use release/<major>.<minor>, run in a PR targeting such a branch, or provide inputs.release_line." >&2 echo "Unable to determine release line for branch '${BRANCH}'. Use release/<major>.<minor>, provide inputs.release_line, or ensure package.json contains a semantic version." >&2
exit 1 exit 1
} }

View File

@@ -9,7 +9,7 @@ Creates or updates the version in `package.json`, commits it, creates a matching
Inputs: Inputs:
- `node_version`: Node.js version to use. Default: `24` - `node_version`: Node.js version to use. Default: `24`
- `release_line`: optional release line for dev builds when it cannot be derived from the branch or PR target. Format: `<major>.<minor>` - `release_line`: optional release line for dev builds. Format: `<major>.<minor>`. Overrides branch, PR target, and `package.json`.
- `gitea_token`: optional token used for checkout and push - `gitea_token`: optional token used for checkout and push
Branch and tag rules: Branch and tag rules:
@@ -23,7 +23,7 @@ Dev release line resolution order:
- `inputs.release_line` - `inputs.release_line`
- current branch if it matches `release/<major>.<minor>` - current branch if it matches `release/<major>.<minor>`
- PR target branch if it matches `release/<major>.<minor>` - PR target branch if it matches `release/<major>.<minor>`
- on `develop`, fallback to `major.minor` from `package.json` - `major.minor` from `package.json`
If no release line can be resolved for a dev build, the action fails intentionally. If no release line can be resolved for a dev build, the action fails intentionally.
@@ -39,6 +39,7 @@ Branch examples:
- `release/2.4` -> next `v2.4.0-beta.N` - `release/2.4` -> next `v2.4.0-beta.N`
- feature branch in a PR to `release/2.4` -> `v2.4.0-dev.<UTC_TIMESTAMP>` - feature branch in a PR to `release/2.4` -> `v2.4.0-dev.<UTC_TIMESTAMP>`
- feature branch outside a PR with `package.json` version `2.4.0` -> `v2.4.0-dev.<UTC_TIMESTAMP>`
- feature branch outside a PR with `release_line: 2.4` -> `v2.4.0-dev.<UTC_TIMESTAMP>` - feature branch outside a PR with `release_line: 2.4` -> `v2.4.0-dev.<UTC_TIMESTAMP>`
Example: Example: