Skip to content

Commit fba2e42

Browse files
committed
fix(tool): push the tag, wait for a real answer, and number every build
Three defects, each of which let a release look like it had worked. `--follow-tags` carries annotated tags only, and every release tag here is lightweight, so it skipped the tag without a word: the branch landed, the tag stayed local, and the workflow that triggers on it never fired. v0.8.97-pre.1 was published that way. The tag is pushed by name now, which works for either kind. The manual sequence in .agents/commands.md had the same hole and is corrected with it. The confirmation treated an empty answer as No, and rendering the preview takes seconds, so a Return pressed while waiting sat in the terminal buffer until the prompt consumed it and appeared to answer itself. It reads from /dev/tty and re-asks instead. The bash that ships with macOS is 3.2, which has neither a fractional read timeout nor a way to flush stdin, so re-asking is the portable fix rather than draining what is already buffered. Declining is no longer reported as an error. The build number was refreshed only when the app version changed, so every prerelease after the first in a cycle reused its predecessor's. It feeds Android's versionCode, and two builds carrying the same one cannot be told apart once installed. Only the build number moves: the app version has to hold across a cycle because `build --unreleased` keys its commit range off it, and a prerelease that advanced it would collect the wrong range. Changelog: skip
1 parent 4a028ba commit fba2e42

2 files changed

Lines changed: 25 additions & 33 deletions

File tree

‎.agents/commands.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,13 @@ Releasing a stable version, in order:
167167
tool/bump_version.sh all
168168
dart run tool/changelog.dart release --version 0.8.96
169169
git commit -am "chore(release): v0.8.96"
170-
git tag v0.8.96 && git push --follow-tags
170+
git tag v0.8.96
171+
git push origin main && git push origin v0.8.96
171172
```
172173

174+
Push the tag by name. Every release tag here is lightweight, and `--follow-tags` carries annotated tags only: it skips a
175+
lightweight one silently, so the branch lands, the tag does not, and the release workflow never fires.
176+
173177
`tool/release.sh` drives both paths so the ordering below cannot be got wrong by hand. It resolves the version (bumping
174178
the patch when pubspec still names an already tagged one), prints the notes the tag would ship, and only pushes with
175179
`--push`:

‎tool/release.sh‎

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
# Drives the two release paths documented in .agents/commands.md.
5-
#
6-
# pre Tag vX.Y.Z-pre.N. CI renders the notes on the fly with
7-
# `build --unreleased`, so nothing is written back to the repository
8-
# and no release commit is made. Publishes no GitHub release.
9-
# stable Regenerate CHANGELOG.md and changelog.json, commit them, then tag
10-
# vX.Y.Z. The commit comes before the tag on purpose: the generated
11-
# wording is reviewable in the diff, and `render release` reads the
12-
# committed changelog.json for a stable tag.
13-
#
14-
# Both paths need `v<pubspec version>` to be untagged: `build --unreleased`
15-
# refuses to run once it is, and a stable release cannot reuse the tag either.
16-
174
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
185
root="$(cd "$script_dir/.." && pwd)"
196
cd "$root"
@@ -89,7 +76,6 @@ pubspec_version() {
8976
sed -n 's/^version: \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p' pubspec.yaml
9077
}
9178

92-
# Tracked files only: an untracked scratch file should not block a release.
9379
if ! git diff --quiet || ! git diff --cached --quiet; then
9480
die "working tree has uncommitted changes; commit or stash them first"
9581
fi
@@ -104,13 +90,10 @@ fi
10490
current="$(pubspec_version)"
10591
[[ -n "$current" ]] || die "could not read the version from pubspec.yaml"
10692

107-
# Resolving the version is the same question in both modes: which vX.Y.Z is this
108-
# release, and is pubspec already pointing at it?
10993
bumped=0
11094
if [[ -n "$want_version" ]]; then
11195
version="$want_version"
11296
elif git rev-parse -q --verify "refs/tags/v$current" >/dev/null; then
113-
# pubspec still names the last release. Take the next patch.
11497
IFS='.' read -r vmaj vmin vpat <<<"$current"
11598
version="$vmaj.$vmin.$((vpat + 1))"
11699
echo "pubspec is at $current, which is already tagged; targeting $version"
@@ -148,11 +131,6 @@ fi
148131
echo "push : $([[ $do_push == 1 ]] && echo yes || echo 'no (printed at the end)')"
149132
echo
150133

151-
# The bump has to happen before the preview: `build --unreleased` reads the
152-
# pubspec version, and refuses to collect anything while that version is still
153-
# tagged. Everything from here to the commit is undone on any exit that is not
154-
# a completed release -- an abort, an error, or a SIGPIPE from a paged preview
155-
# would otherwise leave pubspec.yaml rewritten for a release that never ran.
156134
committed=0
157135
restore() {
158136
((committed)) && return 0
@@ -163,13 +141,9 @@ trap restore EXIT
163141
if ((bumped)); then
164142
sed -i.bak "s/^version: [0-9]*\.[0-9]*\.[0-9]*/version: $version/" pubspec.yaml
165143
rm -f pubspec.yaml.bak
166-
# bump_version.sh owns the YYYYMMDDNN build number; let it mint today's.
167-
tool/bump_version.sh minor
168144
fi
145+
tool/bump_version.sh minor
169146

170-
# The notes come from the same v<previous>..HEAD range in both modes, so this
171-
# preview is what ships either way. `build` writes changelog.json, which a
172-
# prerelease must not carry, so the file is restored either way.
173147
echo "--- release notes for $tag ---"
174148
if dart run tool/changelog.dart build --unreleased >/dev/null 2>&1; then
175149
dart run tool/changelog.dart render release 2>/dev/null |
@@ -187,8 +161,21 @@ if ((dry_run)); then
187161
fi
188162

189163
if ((assume_yes == 0)); then
190-
read -r -p "Proceed with $tag? [y/N] " reply
191-
[[ "$reply" == [yY] ]] || die "aborted"
164+
if [[ ! -r /dev/tty ]]; then
165+
die "no terminal to confirm on; pass --yes to run unattended"
166+
fi
167+
while true; do
168+
read -r -p "Proceed with $tag? [y/n] " reply </dev/tty ||
169+
die "no answer read; pass --yes to run unattended"
170+
case "$reply" in
171+
[yY] | [yY][eE][sS]) break ;;
172+
[nN] | [nN][oO])
173+
echo "Cancelled. Nothing was changed."
174+
exit 0
175+
;;
176+
*) echo "Please answer y or n." ;;
177+
esac
178+
done
192179
fi
193180

194181
if [[ "$mode" == "stable" ]]; then
@@ -200,7 +187,7 @@ if [[ "$mode" == "stable" ]]; then
200187
git commit -m "chore(release): v$version"
201188
committed=1
202189
dart run tool/changelog.dart verify
203-
elif ((bumped)); then
190+
elif ! git diff --quiet -- pubspec.yaml; then
204191
git add pubspec.yaml
205192
git commit -m "chore: bump version to $(sed -n 's/^version: //p' pubspec.yaml)"
206193
committed=1
@@ -212,10 +199,11 @@ git tag "$tag"
212199
echo "tagged $tag at $(git rev-parse --short HEAD)"
213200

214201
if ((do_push)); then
215-
git push origin "$branch" --follow-tags
202+
git push origin "$branch"
203+
git push origin "$tag"
216204
echo "pushed $branch and $tag"
217205
else
218206
echo
219207
echo "Nothing was pushed. To publish:"
220-
echo " git push origin $branch --follow-tags"
208+
echo " git push origin $branch && git push origin $tag"
221209
fi

0 commit comments

Comments
 (0)