Skip to content

fix: allow manual set version in non-action repos#47

Merged
ChristophShyper merged 2 commits intomasterfrom
bugfix/manual-version-set-non-action
Mar 27, 2026
Merged

fix: allow manual set version in non-action repos#47
ChristophShyper merged 2 commits intomasterfrom
bugfix/manual-version-set-non-action

Conversation

@ChristophShyper
Copy link
Copy Markdown
Member

@ChristophShyper ChristophShyper commented Mar 27, 2026

Summary

  • fix reusable manual update workflow so non-action profiles (other, static, dockerized) do not require a pre-existing current version when bump type is set
  • keep current-version requirement only for patch, minor, and major modes
  • prevent .github meta repository release workflow from failing with Current version not found during manual set

Why

The meta repo does not always have a pre-existing .version at runtime, so set mode should initialize version state directly instead of depending on current-version discovery.

@ChristophShyper ChristophShyper requested a review from a team as a code owner March 27, 2026 23:17
Copilot AI review requested due to automatic review settings March 27, 2026 23:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the reusable manual version-bump workflow so repos using non-actions profiles can run in set mode without requiring an existing “current version” (e.g., missing .version).

Changes:

  • Moves “current version required” logic to only the patch/minor/major bump paths for non-actions profiles.
  • Allows set to directly write the requested version to .version for non-actions profiles.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +108 to +115
current=$(task version:get 2>/dev/null || true)
if [ -z "${current}" ] && [ -f .version ]; then
current=$(tr -d '\n' < .version)
fi
if [ -z "${current}" ]; then
echo "Current version not found"
exit 1
fi
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current-version discovery + parsing block is duplicated in the patch, minor, and major branches. This makes future changes (e.g., supporting prerelease versions or improving validation) error-prone since it must be updated in 3 places. Consider extracting this into a small helper (shell function) or doing the current-version lookup/parsing once before the case (guarded so it only runs for patch/minor/major).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Refactored this block to remove duplication: added helper functions normalize_and_validate_version and get_current_version, and consolidated patch|minor|major into a single path that computes parsed version components once.

Comment on lines 116 to 124
no_v=${current#v}
major=$(echo "${no_v}" | awk -F. '{print $1}')
minor=$(echo "${no_v}" | awk -F. '{print $2}')
patch=$(echo "${no_v}" | awk -F. '{print $3}')
if [ -z "${major}" ] || [ -z "${minor}" ] || [ -z "${patch}" ]; then
echo "Invalid current version: ${current}"
exit 1
fi
next="v${major}.${minor}.$((patch + 1))"
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version parsing here uses awk -F. which relies on awk field-splitting behavior for .; in other parts of the repo the dot is escaped (-F\.), which is more explicit/portable. Also, the validation only checks for non-empty fields; if patch/minor are non-numeric (e.g., v1.2.3-alpha) the later arithmetic expansion will fail. Recommend validating the full version format (e.g., ^v?[0-9]+\.[0-9]+\.[0-9]+$) and/or splitting using shell (IFS=. / read) instead of multiple echo|awk calls.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented. Replaced repeated awk parsing with explicit validation and shell split:

  • validate versions with regex (^v?[0-9]+\.[0-9]+\.[0-9]+$)
  • normalize to vX.Y.Z
  • parse once via IFS=. read -r major minor patch
    This now rejects prerelease/non-numeric formats before arithmetic expansion.

@ChristophShyper ChristophShyper merged commit 9d747f3 into master Mar 27, 2026
3 checks passed
@ChristophShyper ChristophShyper deleted the bugfix/manual-version-set-non-action branch March 27, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants