Skip to content

Commit fe5986b

Browse files
committed
build(just): add 'bump' task for one-command version updates
Manually bumping a version requires touching 3+ files: * mix.exs (the canonical version) * github-page/index.html (the curl example) * README.md (the Publishing section's release flow + examples) It's easy to forget one — this v0.2.0 -> v0.2.1 bump missed github-page/index.html (caught in a follow-up commit). Add a 'just bump <version>' recipe that: 1. Reads the current version from mix.exs 2. Validates the new version is a semver string and != current 3. sed-updates all 3 files 4. Prints reminders for files that need a human (CHANGELOG, AGENTS.md coverage stat, the skills' own version field) 5. Prints the resulting diff for review The task is local-only (the maintainer runs it on their laptop before committing). It uses BSD sed -i '' syntax (macOS). On Linux the maintainer would need to swap to 'sed -i' (no empty arg) — left as-is since the task isn't run in CI. Verified: * just bump 9.9.9 — works, leaves correct diff * just bump 0.2.1 — refuses (same as current) * just bump foo — refuses (not a semver) * just bump — refuses (no arg, just shows usage)
1 parent 017926c commit fe5986b

1 file changed

Lines changed: 98 additions & 0 deletions

File tree

justfile

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,101 @@ check: ci test
148148
# Full build + test + release
149149
all: ci test release
150150
@echo "✅ All checks passed, release built"
151+
152+
# ── Version Bumping ────────────────────────────────────────────────────
153+
# Bump the version across every source file that references it.
154+
# Usage: just bump 0.2.2
155+
#
156+
# Updates:
157+
# * mix.exs — the canonical version
158+
# * github-page/index.html — the "Download binary" curl example
159+
# * README.md — the Publishing section's release flow
160+
# (tag, push, npm-publish.sh, etc.)
161+
#
162+
# Reminds you (but does NOT auto-update):
163+
# * CHANGELOG.md — needs a human-written entry
164+
# * AGENTS.md — has a coverage stat quoted per-version
165+
# * priv/skills/* — the `version:` frontmatter is the SKILL's
166+
# own version, not the binary's; leave
167+
# alone unless you also bump the skills
168+
#
169+
# Files the bump task leaves alone (intentionally):
170+
# * npm/*/package.json — template files at the previous version;
171+
# scripts/npm-publish.sh bumps at runtime
172+
# * npm/@gilbertwong1996-ado-{platform}/bin/ado{,.exe} — downloaded
173+
# from the GitHub Release by the publish
174+
# script
175+
# * lib/ado_cli/version.ex — the AdoCli.Version module reads the
176+
# version dynamically from mix.exs;
177+
# there's no hard-coded string
178+
#
179+
# The task is idempotent: running it twice with the same arg is a
180+
# no-op (the second pass sees nothing to change).
181+
bump new_version:
182+
#!/usr/bin/env bash
183+
set -euo pipefail
184+
NEW="{{new_version}}"
185+
186+
# Current version from mix.exs
187+
OLD=$(grep -E '^\s*version:\s*"' mix.exs | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
188+
if [[ -z "$OLD" ]]; then
189+
echo "ERROR: couldn't read current version from mix.exs" >&2
190+
exit 1
191+
fi
192+
if [[ -z "$NEW" ]]; then
193+
echo "Usage: just bump <new-version> (e.g. just bump 0.2.2)" >&2
194+
exit 1
195+
fi
196+
if [[ "$OLD" == "$NEW" ]]; then
197+
echo "ERROR: new version ($NEW) is the same as current version ($OLD)" >&2
198+
exit 1
199+
fi
200+
# Sanity-check the new version looks like a semver string. We
201+
# only need to be loose here — `mix version` would do a stricter
202+
# check, but we don't depend on Mix at the just layer.
203+
if ! [[ "$NEW" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.-]+)?$ ]]; then
204+
echo "ERROR: '$NEW' doesn't look like a semver version (e.g. 0.2.2 or 1.0.0-rc.1)" >&2
205+
exit 1
206+
fi
207+
208+
echo "Bumping $OLD$NEW"
209+
echo ""
210+
211+
# 1. mix.exs — the canonical version string
212+
sed -i '' "s/version: \"$OLD\"/version: \"$NEW\"/" mix.exs
213+
echo " ✓ mix.exs"
214+
215+
# 2. github-page/index.html — the curl example
216+
sed -i '' "s/ado-${OLD}-macos-aarch64/ado-${NEW}-macos-aarch64/g" github-page/index.html
217+
echo " ✓ github-page/index.html (Download binary curl example)"
218+
219+
# 3. README.md — the Publishing section's release flow + examples
220+
# (lines ~688–788, the publishing cheat-sheet). We replace
221+
# $OLD with $NEW; the rest of README shouldn't reference the
222+
# version, but if it does, the diff at the end will show it.
223+
if [[ -f README.md ]]; then
224+
sed -i '' "s/$OLD/$NEW/g" README.md
225+
echo " ✓ README.md (Publishing section)"
226+
fi
227+
228+
echo ""
229+
echo "Done. You still need to:"
230+
echo ""
231+
echo " 1. Add a CHANGELOG.md entry under '## [$NEW]'"
232+
echo " (see the [0.2.1] section as a template)"
233+
echo " 2. Bump the 'Total project coverage is X% as of v$OLD' line in AGENTS.md"
234+
echo " if the coverage number has changed (only on v0.X.0 releases)"
235+
echo " 3. Run \`mix format\` to normalize the diff"
236+
echo " 4. Run \`just check\` to confirm CI is still green"
237+
echo " 5. Commit, push, tag:"
238+
echo " git add -u && git commit -m 'release: v$NEW'"
239+
echo " git tag -a v$NEW -m 'Release $NEW'"
240+
echo " git push github main v$NEW"
241+
echo " (CI will build the binaries and create the GitHub Release)"
242+
echo " 6. Run \`./scripts/npm-publish.sh $NEW\` locally to publish the npm packages"
243+
echo ""
244+
echo "Diff (review before committing):"
245+
echo "─────────────────────────────────────────────────────────"
246+
git --no-pager diff --stat
247+
echo "─────────────────────────────────────────────────────────"
248+
git --no-pager diff mix.exs github-page/index.html README.md | head -60

0 commit comments

Comments
 (0)