Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/workflow-update-version-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
default: master
type: string
version-file:
description: Path to the version file to overwrite
description: Path to the version file to overwrite; pass multiple paths one per line to update them in a single commit
required: false
default: public/version.txt
type: string
Expand Down Expand Up @@ -53,8 +53,11 @@ jobs:
echo "next-tag input is required" >&2
exit 1
fi
mkdir -p "$(dirname "$VERSION_FILE")"
printf '%s\n' "$NEXT_TAG" > "$VERSION_FILE"
while IFS= read -r version_file; do
[ -z "$version_file" ] && continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject empty version-file lists

When version-file is explicitly set to an empty string or to only blank lines, this continue skips every entry, so no file is written; the commit step then finds no staged diff and exits successfully while the workflow still reports new-tag as written. Previously an empty path failed during the write, so callers with a miswired optional input can now get a false-success release/update; track whether at least one non-empty path was processed and fail otherwise.

Useful? React with 馃憤聽/ 馃憥.

mkdir -p "$(dirname "$version_file")"
printf '%s\n' "$NEXT_TAG" > "$version_file"
done <<< "$VERSION_FILE"
echo "new_tag=${NEXT_TAG}" >> "$GITHUB_OUTPUT"

- name: Commit version marker
Expand All @@ -65,7 +68,10 @@ jobs:
set -euo pipefail
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add "$VERSION_FILE"
while IFS= read -r version_file; do
[ -z "$version_file" ] && continue
git add "$version_file"
done <<< "$VERSION_FILE"
if git diff --cached --quiet; then
echo "Version file already up to date."
exit 0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Writes the provided tag into a version file on a target branch and pushes the co

**Inputs**
- `target-branch` (default `master`): branch to check out before writing the version file.
- `version-file` (default `public/version.txt`): path to overwrite with the new tag.
- `version-file` (default `public/version.txt`): path to overwrite with the new tag; pass multiple paths one per line to update them all in a single commit.
- `next-tag` (required): tag value to write.

**Outputs**
Expand Down
Loading