Conversation
Agent-Logs-Url: https://github.com/tikoci/make.d/sessions/6c70a7f7-fb28-494c-973d-f8d09c7ff53d Co-authored-by: mobileskyfi <45924209+mobileskyfi@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds automatic patch-version bumping to the manual build workflow so the repo’s VERSION (and corresponding README version line) are updated before building/publishing OCI images, keeping /VERSION and /etc/motd in the resulting images current.
Changes:
- Grant workflow
contents: writepermission to allow committing back to the repo. - Add a step to parse
VERSION, increment the patch component, and updateVERSION+ the matching line inREADME.md. - Add a commit-and-push step to persist the bumped version before exporting
VERSIONinto CI env vars and tagging images.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.github/workflows/build.yaml
Outdated
| git commit -m "build: bump version to $(awk '{print $2}' VERSION)" | ||
| git pull --rebase | ||
| git push |
There was a problem hiding this comment.
actions/checkout@v4 checks out a specific commit and typically leaves the repo in a detached HEAD state (and by default with fetch-depth: 1). In that state, git pull --rebase and especially git push can fail because there’s no local branch/upstream configured and history may be too shallow to rebase. Update the workflow to check out the triggering branch with full history (e.g., set ref and fetch-depth: 0) and push explicitly to that branch (or otherwise ensure a tracking branch exists) before relying on git pull/push.
| read -r name ver channel < VERSION || true | ||
| IFS='.' read -r major minor patch <<< "$ver" |
There was a problem hiding this comment.
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.
| 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 |
.github/workflows/build.yaml
Outdated
| patch=$((patch + 1)) | ||
| new_ver="${major}.${minor}.${patch}" | ||
| echo "${name} ${new_ver} ${channel}" > VERSION | ||
| sed -i "s/> ${name} ${ver} ${channel}/> ${name} ${new_ver} ${channel}/" README.md |
There was a problem hiding this comment.
The sed -i "s/> ${name} ${ver} ${channel}/.../" replacement is brittle: it treats name/ver/channel as a regex replacement pattern (so special characters can break matching) and it doesn’t verify that README was actually updated (a no-match will silently leave stale version text). Consider using a safer delimiter/escaping strategy or a small script that does an exact match and fails the step if the expected line isn’t found/updated.
| sed -i "s/> ${name} ${ver} ${channel}/> ${name} ${new_ver} ${channel}/" README.md | |
| old="> ${name} ${ver} ${channel}" | |
| new="> ${name} ${new_ver} ${channel}" | |
| python - "$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 |
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/tikoci/make.d/sessions/71b1a2b1-1f21-420f-8118-b78436b27d30 Co-authored-by: mobileskyfi <45924209+mobileskyfi@users.noreply.github.com>
Applied all three review comments in commit
|
VERSION file and README.md are never updated during builds, so OCI images get stale version info baked into
/VERSION(and thus/etc/motd).Changes to
.github/workflows/build.yamlcontents: writepermission — needed to push the version commit backref: ${{ github.ref }}andfetch-depth: 0to avoid detached HEAD issuesVERSION(name major.minor.patch channel), validates semver format with regex, increments patch, writes back toVERSIONand updates the matching line inREADME.mdusing Python for safer string replacementgithub-actions[bot], with guards for no-op changes and explicit push toorigin HEAD:${{ github.ref }}The bump runs before the existing "VERSION file to CI envvars" step, so Docker image tags and the container's
/VERSIONreflect the new version.