Skip to content
Merged
Show file tree
Hide file tree
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
33 changes: 6 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,35 +79,14 @@ jobs:
echo "Package was not visible on npm in time."
exit 1

- name: Verify npx install path
- name: Verify registry install paths
run: |
VERSION="$(node -p "require('./package.json').version")"
EXPECTED="TTDash v${VERSION}"
for attempt in 1 2 3 4 5 6; do
OUTPUT="$(npm exec --yes --package "@roastcodes/ttdash@${VERSION}" -- ttdash --help 2>&1)" && {
printf '%s\n' "$OUTPUT"
printf '%s\n' "$OUTPUT" | grep -F "$EXPECTED" >/dev/null
exit 0
}
sleep 10
done
echo "npm exec install path did not become ready in time."
exit 1

- name: Verify bunx install path
run: |
VERSION="$(node -p "require('./package.json').version")"
EXPECTED="TTDash v${VERSION}"
for attempt in 1 2 3 4 5 6; do
OUTPUT="$(bunx "@roastcodes/ttdash@${VERSION}" --help 2>&1)" && {
printf '%s\n' "$OUTPUT"
printf '%s\n' "$OUTPUT" | grep -F "$EXPECTED" >/dev/null
exit 0
}
sleep 10
done
echo "bunx install path did not become ready in time."
exit 1
node scripts/verify-registry-install.js \
--package @roastcodes/ttdash \
--version "${VERSION}" \
--retries 6 \
--retry-delay-ms 10000

- name: Create GitHub release
env:
Expand Down
16 changes: 13 additions & 3 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,19 @@ PLAYWRIGHT_TEST_PORT=3016 npm_config_cache=/tmp/ttdash-npm-cache npm run test:e2
Example:

```bash
VERSION=$(node -p "require('./package.json').version")
git tag "v$VERSION"
git push origin "v$VERSION"
bash scripts/tag-main-release.sh
```

Optional explicit version:

```bash
bash scripts/tag-main-release.sh 6.1.3
```

Dry-run preview:

```bash
bash scripts/tag-main-release.sh --dry-run
```

## What the Release Workflow Does
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@roastcodes/ttdash",
"version": "6.1.2",
"version": "6.1.3",
"description": "Local-first dashboard and CLI for toktrack usage data",
"main": "server.js",
"repository": {
Expand Down Expand Up @@ -28,7 +28,9 @@
"test:e2e:ci": "playwright test",
"test:all": "npm run test:unit && npm run test:e2e",
"pack:dry-run": "npm pack --dry-run",
"tag:main-release": "bash scripts/tag-main-release.sh",
"verify:package": "node scripts/verify-package.js",
"verify:registry-install": "node scripts/verify-registry-install.js",
"verify:release": "npm run test:unit:coverage && npm run build && npm run verify:package",
"prepare": "npm run build"
},
Expand Down
104 changes: 104 additions & 0 deletions scripts/tag-main-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env bash

set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"

usage() {
cat <<'EOF'
Usage:
bash scripts/tag-main-release.sh [version] [--dry-run]

Behavior:
- must be run from a clean local main branch
- fetches origin
- fast-forwards local main to origin/main
- creates annotated tag v<version>
- pushes the tag to origin

Defaults:
- if version is omitted, package.json version is used

Examples:
bash scripts/tag-main-release.sh
bash scripts/tag-main-release.sh 6.1.3
bash scripts/tag-main-release.sh --dry-run
EOF
}

VERSION=""
DRY_RUN=0

for arg in "$@"; do
case "$arg" in
-h|--help)
usage
exit 0
;;
--dry-run)
DRY_RUN=1
;;
*)
if [[ -n "$VERSION" ]]; then
echo "Only one version argument is allowed."
usage
exit 1
fi
VERSION="$arg"
;;
esac
done

CURRENT_BRANCH="$(git branch --show-current)"
if [[ "$CURRENT_BRANCH" != "main" ]]; then
echo "This script must be run from the local main branch. Current branch: $CURRENT_BRANCH"
exit 1
fi

if [[ -n "$(git status --porcelain)" ]]; then
echo "Working tree is not clean. Commit or stash changes before tagging a release."
exit 1
fi

run() {
echo "+ $*"
if [[ "$DRY_RUN" -eq 0 ]]; then
"$@"
fi
}

run git fetch origin
run git pull --ff-only origin main

PACKAGE_VERSION="$(node -p "require('./package.json').version")"

if [[ -z "$VERSION" ]]; then
VERSION="$PACKAGE_VERSION"
fi

if [[ "$VERSION" != "$PACKAGE_VERSION" ]]; then
echo "Version mismatch after sync: package.json is $PACKAGE_VERSION but requested version is $VERSION."
exit 1
fi

TAG_NAME="v$VERSION"

if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "Tag already exists locally: $TAG_NAME"
exit 1
fi

if git ls-remote --tags origin "refs/tags/$TAG_NAME" | grep -q .; then
echo "Tag already exists on origin: $TAG_NAME"
exit 1
fi

run git tag -a "$TAG_NAME" -m "$TAG_NAME"
run git push origin "$TAG_NAME"

if [[ "$DRY_RUN" -eq 1 ]]; then
echo "Dry run complete."
else
echo "Release tag pushed: $TAG_NAME"
fi
Loading
Loading