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
106 changes: 102 additions & 4 deletions .justfiles/release.just
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@

[private]
default:
@just --list --unsorted --justfile {{source_file()}}
#!/usr/bin/env bash
echo "camp-graph release commands"
echo ""
echo "Primary:"
echo " just release stable [patch|minor|major]"
echo ""
echo "Support:"
echo " just release current"
echo " just release check"
echo " just release snapshot"
echo " just release tag v0.1.0"

goreleaser := "go run github.com/goreleaser/goreleaser/v2@v2.15.2"
repo := "Obedience-Corp/camp-graph"

# Validate GoReleaser configuration
[no-cd]
Expand All @@ -21,7 +32,86 @@ snapshot:
version:
@go run ./cmd/camp-graph version

# Tag a release (usage: just release tag v0.1.0)
# Show current stable release tag
[no-cd]
current:
#!/usr/bin/env bash
set -euo pipefail
git fetch --prune --prune-tags origin '+refs/tags/*:refs/tags/*' >/dev/null 2>&1 || true
latest=$(git tag -l --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1 || true)
echo "${latest:-none}"

# Create and push the next stable release tag (usage: just release stable [patch|minor|major])
[no-cd]
stable level="patch":
#!/usr/bin/env bash
set -euo pipefail

level="{{level}}"
case "$level" in
patch|minor|major) ;;
*)
echo "Unknown level: $level (use patch, minor, or major)"
exit 1
;;
esac

if [ -n "$(git status --porcelain)" ]; then
echo "ERROR: repo has uncommitted changes"
git status --short
exit 1
fi

branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$branch" != "main" ]; then
echo "ERROR: releases must be cut from main (current: $branch)"
exit 1
fi

git fetch --prune --prune-tags origin '+refs/tags/*:refs/tags/*' '+refs/heads/main:refs/remotes/origin/main'

if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]; then
echo "ERROR: local main is not in sync with origin/main"
echo "Run: git pull --ff-only origin main"
exit 1
fi

just --justfile {{source_file()}} check

latest=$(git tag -l --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1 || true)

if [ -z "$latest" ]; then
next="v0.1.0"
else
nums="${latest#v}"
IFS='.' read -r major minor patch <<< "$nums"

case "$level" in
major) major=$((major + 1)); minor=0; patch=0 ;;
minor) minor=$((minor + 1)); patch=0 ;;
patch) patch=$((patch + 1)) ;;
esac

next="v${major}.${minor}.${patch}"
fi

if git tag -l "$next" | grep -q .; then
echo "ERROR: tag $next already exists locally"
exit 1
fi

if [ -n "$(git ls-remote --tags origin "refs/tags/${next}")" ]; then
echo "ERROR: tag $next already exists on origin"
exit 1
fi

echo "Creating stable release: $next"
git tag -a "$next" -m "Release $next"
git push origin "$next"
echo "Pushed $next"
echo "Release workflow should now start on GitHub."

# Create and push an explicit release tag (usage: just release tag v0.1.0)
[no-cd]
tag VERSION:
#!/usr/bin/env bash
Expand All @@ -30,6 +120,14 @@ tag VERSION:
echo "Version must start with 'v' (e.g., v0.1.0)"
exit 1
fi
echo "Tagging {{VERSION}}..."
if [ -n "$(git status --porcelain)" ]; then
echo "ERROR: repo has uncommitted changes"
git status --short
exit 1
fi
just --justfile {{source_file()}} check
echo "Creating release tag {{VERSION}}..."
git tag -a "{{VERSION}}" -m "Release {{VERSION}}"
echo "Tagged {{VERSION}}. Push with: git push origin {{VERSION}}"
git push origin "{{VERSION}}"
echo "Pushed {{VERSION}}"
echo "Release workflow should now start on GitHub."
10 changes: 7 additions & 3 deletions docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ The release workflow fails early if either secret is missing.
## Release steps

```bash
just test unit
just release tag v0.1.0
git push origin v0.1.0
just release stable
```

GitHub Actions then:
Expand All @@ -34,6 +32,12 @@ GitHub Actions then:
4. updates `Obedience-Corp/homebrew-tap`
5. updates the AUR package repo

If you need an explicit version instead of the next computed stable tag:

```bash
just release tag v0.1.0
```

## Reuse for future `camp-*` plugins

Copy this file set into the new plugin repo:
Expand Down
Loading