GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lumen/tag.sh at main · DataGrout/lumen

Expand file tree

/

tag.sh

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
134 lines (109 loc) · 4.88 KB
/

tag.sh

Copy path

File metadata and controls

executable file
·
134 lines (109 loc) · 4.88 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env bash
set -euo pipefail
# Usage: ./tag.sh <version>
# Brings every version surface to <version>, runs tests, then tags and pushes.
#
# There are three surfaces, and for a long time this script owned only the
# first — which is why shipped 0.2.2 and 0.2.3 builds both reported 0.2.1 in
# the app, and why released work stayed filed under "Unreleased" in the
# changelog:
#
# 1. lumen-core/Cargo.toml — the daemon's version (/health, sync)
# 2. Lumen/Sources/Info.plist — what the app itself reports
# 3. CHANGELOG.md — the [Unreleased] heading
#
# Re-running for a version the tree is already at is fine: each step is a
# no-op and the bump commit is skipped rather than failing on an empty commit.
VERSION="${1:-}"
if [[ -z "$VERSION" ]]; then
echo "Usage: $0 <version> (e.g. 0.1.2)" >&2
exit 1
fi
# Require semver-ish: digits and dots only (e.g. 1.2.3 or 1.2.3-rc.1)
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][a-zA-Z0-9.]+)?$ ]]; then
echo "error: version must be semver (e.g. 1.2.3 or 1.2.3-rc.1)" >&2
exit 1
fi
TAG="v${VERSION}"
CARGO_TOML="lumen-core/Cargo.toml"
INFO_PLIST="Lumen/Sources/Info.plist"
CHANGELOG="CHANGELOG.md"
RELEASE_DATE=$(date +%Y-%m-%d)
# -- Sanity checks -------------------------------------------------------------
if ! git diff-index --quiet HEAD --; then
echo "error: uncommitted changes present -- commit or stash before tagging" >&2
exit 1
fi
if git rev-parse "$TAG" &>/dev/null; then
echo "error: tag $TAG already exists" >&2
exit 1
fi
# Everything below is restored by `git checkout --` if the tests fail, which is
# only safe because the tree is known clean at this point.
TOUCHED=("$CARGO_TOML" "$INFO_PLIST" "$CHANGELOG" "lumen-core/Cargo.lock")
# -- 1. Daemon version ---------------------------------------------------------
CURRENT=$(grep '^version' "$CARGO_TOML" | head -1 | sed 's/version = "\(.*\)"/\1/')
if [[ "$CURRENT" == "$VERSION" ]]; then
echo "$CARGO_TOML already at $VERSION"
else
echo "Bumping $CARGO_TOML: $CURRENT -> $VERSION"
sed -i '' "s/^version = \"$CURRENT\"/version = \"$VERSION\"/" "$CARGO_TOML"
fi
# Refresh only our own entry in Cargo.lock. `generate-lockfile` re-resolved every
# dependency, so each release quietly upgraded whatever had a newer semver match.
(cd lumen-core && cargo update --workspace 2>/dev/null) || true
# -- 2. App version ------------------------------------------------------------
#
# The value sits on the line *after* its <key>, hence `n` before substituting.
# CFBundleShortVersionString is the human version; CFBundleVersion is a build
# counter that must increase for each build macOS sees.
PLIST_CURRENT=$(sed -n "/<key>CFBundleShortVersionString<\/key>/{n;s|.*<string>\(.*\)</string>.*|\1|p;}" "$INFO_PLIST")
if [[ "$PLIST_CURRENT" == "$VERSION" ]]; then
echo "$INFO_PLIST already at $VERSION"
else
echo "Bumping $INFO_PLIST: ${PLIST_CURRENT:-unset} -> $VERSION"
sed -i '' "/<key>CFBundleShortVersionString<\/key>/{n;s|<string>.*</string>|<string>$VERSION</string>|;}" "$INFO_PLIST"
BUILD_CURRENT=$(sed -n "/<key>CFBundleVersion<\/key>/{n;s|.*<string>\(.*\)</string>.*|\1|p;}" "$INFO_PLIST")
if [[ "$BUILD_CURRENT" =~ ^[0-9]+$ ]]; then
BUILD_NEXT=$((BUILD_CURRENT + 1))
echo "Bumping CFBundleVersion: $BUILD_CURRENT -> $BUILD_NEXT"
sed -i '' "/<key>CFBundleVersion<\/key>/{n;s|<string>.*</string>|<string>$BUILD_NEXT</string>|;}" "$INFO_PLIST"
else
echo "warning: CFBundleVersion is not a plain integer -- left alone" >&2
fi
fi
# -- 3. Changelog --------------------------------------------------------------
if grep -q '^## \[Unreleased\]' "$CHANGELOG"; then
echo "Closing [Unreleased] as [$VERSION] — $RELEASE_DATE"
sed -i '' "s|^## \[Unreleased\]|## [$VERSION] — $RELEASE_DATE|" "$CHANGELOG"
else
echo "warning: no [Unreleased] section in $CHANGELOG -- nothing to close" >&2
fi
# -- Run tests -----------------------------------------------------------------
echo ""
echo "Running tests..."
if ! (cd lumen-core && cargo test --all 2>&1); then
echo ""
echo "error: tests failed -- reverting version changes" >&2
git checkout -- "${TOUCHED[@]}" 2>/dev/null || true
exit 1
fi
# -- Commit the version bump ---------------------------------------------------
echo ""
git add "${TOUCHED[@]}"
if git diff --cached --quiet; then
echo "No version changes to commit -- tree was already at $VERSION."
else
echo "Committing version bump..."
git commit -m "chore: bump version to $VERSION"
fi
# -- Tag and push --------------------------------------------------------------
# Annotated, with its message given here: with `tag.gpgsign` set, a bare
# `git tag` becomes a signed tag and stops to ask for a message.
echo "Creating tag $TAG..."
git tag -a "$TAG" -m "Lumen $VERSION"
echo "Pushing commit and tag..."
git push
git push origin "$TAG"
echo ""
echo "Released $TAG"
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.