Skip to content
Merged
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
54 changes: 53 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ env:

permissions:
packages: write
contents: read
contents: write

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Set up QEMU need for cross-platform building
uses: docker/setup-qemu-action@v3
with:
Expand All @@ -39,6 +42,55 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Bump patch version in VERSION and README.md
run: |
# read returns non-zero when file lacks trailing newline, so check content instead
read -r name ver channel < VERSION || true

if [ -z "$name" ] || [ -z "$ver" ] || [ -z "$channel" ]; then
echo "Error: VERSION must be in the format: <name> <major.minor.patch> <channel>" >&2
echo "Got: name='${name}', ver='${ver}', channel='${channel}'" >&2
exit 1
fi

if ! [[ "$ver" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: version '${ver}' is not a valid semantic version (expected major.minor.patch)" >&2
exit 1
fi

IFS='.' read -r major minor patch <<< "$ver"
Comment on lines +48 to +61
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

read -r name ver channel < VERSION || true suppresses failures and allows empty/invalid values to flow into version math. If VERSION is missing or malformed, this can write an invalid version (e.g., ..1) or bump the wrong thing. Prefer failing fast when parsing doesn’t match the expected name major.minor.patch channel format, and validate that major/minor/patch are numeric before incrementing.

Suggested change
read -r name ver channel < VERSION || true
IFS='.' read -r major minor patch <<< "$ver"
if ! read -r name ver channel < VERSION; then
echo "Error: failed to read VERSION file or file is missing" >&2
exit 1
fi
if [ -z "$name" ] || [ -z "$ver" ] || [ -z "$channel" ]; then
echo "Error: VERSION must be in the format: <name> <major.minor.patch> <channel>" >&2
echo "Got: name='${name}', ver='${ver}', channel='${channel}'" >&2
exit 1
fi
if ! [[ "$ver" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: version '${ver}' is not a valid semantic version (expected major.minor.patch)" >&2
exit 1
fi
IFS='.' read -r major minor patch <<< "$ver"
if [ -z "$major" ] || [ -z "$minor" ] || [ -z "$patch" ]; then
echo "Error: failed to parse version components from '${ver}'" >&2
exit 1
fi

Copilot uses AI. Check for mistakes.
if [ -z "$major" ] || [ -z "$minor" ] || [ -z "$patch" ]; then
echo "Error: failed to parse version components from '${ver}'" >&2
exit 1
fi
patch=$((patch + 1))
new_ver="${major}.${minor}.${patch}"
echo "${name} ${new_ver} ${channel}" > VERSION
old="> ${name} ${ver} ${channel}"
new="> ${name} ${new_ver} ${channel}"
python3 - "$old" "$new" << 'PY'
import sys
from pathlib import Path

old, new = sys.argv[1], sys.argv[2]
path = Path("README.md")
text = path.read_text(encoding="utf-8")
if old not in text:
raise SystemExit(f"Old version string not found in README.md: {old!r}")
text = text.replace(old, new, 1)
path.write_text(text, encoding="utf-8")
PY
- name: Commit updated version
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add VERSION README.md
if git diff --cached --quiet; then
echo "No version changes to commit"
else
git commit -m "build: bump version to $(awk '{print $2}' VERSION)"
git push origin HEAD:${{ github.ref }}
fi
- name: VERSION file to CI envvars
run: |
cat VERSION | awk '{ print "MAKED_NAME=" $1 }' >> $GITHUB_ENV
Expand Down
Loading