|
| 1 | +repo := "cashapp/hermit" |
| 2 | +root := justfile_directory() |
| 3 | +build_dir := root / "build" |
| 4 | +version := `git describe --tags --dirty --always` |
| 5 | +goos := `go env GOOS` |
| 6 | +goarch := `go env GOARCH` |
| 7 | +export HERMIT_EXE := "" |
| 8 | + |
| 9 | +_help: |
| 10 | + @just --list |
| 11 | + |
| 12 | +# Run lint, test, and build |
| 13 | +all: lint test build |
| 14 | + |
| 15 | +# Run golangci-lint |
| 16 | +lint: |
| 17 | + golangci-lint run |
| 18 | + |
| 19 | +# Run tests |
| 20 | +test: |
| 21 | + go test ./... |
| 22 | + |
| 23 | +# Run integration tests |
| 24 | +test-integration: |
| 25 | + go test -count=1 -tags integration -v ./integration |
| 26 | + |
| 27 | +# Build binary and gzip it |
| 28 | +build channel="canary" os=goos arch=goarch: (build-binary channel os arch) |
| 29 | + gzip -f9 {{ build_dir / ("hermit-" + os + "-" + arch) }} |
| 30 | + |
| 31 | +# Build binary |
| 32 | +build-binary channel="canary" os=goos arch=goarch: |
| 33 | + mkdir -p {{ build_dir }} |
| 34 | + CGO_ENABLED=0 GOOS={{ os }} GOARCH={{ arch }} go build -ldflags "-X main.version={{ version }} -X main.channel={{ channel }}" -o {{ build_dir / ("hermit-" + os + "-" + arch) }} {{ root / "cmd/hermit" }} |
| 35 | + |
| 36 | +# Create a new patch release (e.g. v0.49.1 -> v0.49.2) |
| 37 | +release: (_release "patch") |
| 38 | + |
| 39 | +# Create a new minor release (e.g. v0.49.1 -> v0.50.0) |
| 40 | +release-minor: (_release "minor") |
| 41 | + |
| 42 | +_release bump: |
| 43 | + #!/usr/bin/env bash |
| 44 | + set -euo pipefail |
| 45 | + git fetch --tags --quiet |
| 46 | + latest=$(git tag --sort=-v:refname | head -1) |
| 47 | + major=$(echo "$latest" | sed 's/^v//' | cut -d. -f1) |
| 48 | + minor=$(echo "$latest" | sed 's/^v//' | cut -d. -f2) |
| 49 | + patch=$(echo "$latest" | sed 's/^v//' | cut -d. -f3) |
| 50 | + if [ "{{ bump }}" = "minor" ]; then |
| 51 | + next="v${major}.$((minor + 1)).0" |
| 52 | + else |
| 53 | + next="v${major}.${minor}.$((patch + 1))" |
| 54 | + fi |
| 55 | + echo "Latest release: $latest" |
| 56 | + echo "{{ bump }} release: $next" |
| 57 | + if [ "{{ bump }}" = "patch" ]; then |
| 58 | + echo "(Run 'just release-minor' to bump the minor version instead)" |
| 59 | + fi |
| 60 | + read -p "Proceed? [y/N] " confirm |
| 61 | + if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then |
| 62 | + echo "Aborted." |
| 63 | + exit 1 |
| 64 | + fi |
| 65 | + gh release create "$next" \ |
| 66 | + --repo "{{ repo }}" \ |
| 67 | + --target master \ |
| 68 | + --generate-notes |
| 69 | + |
| 70 | +# Check the status of the most recent release workflow run |
| 71 | +release-status: |
| 72 | + gh run list \ |
| 73 | + --repo "{{ repo }}" \ |
| 74 | + --workflow release.yml \ |
| 75 | + --limit 5 |
| 76 | + |
| 77 | +# Watch the latest release workflow run |
| 78 | +release-watch: |
| 79 | + gh run watch \ |
| 80 | + --repo "{{ repo }}" \ |
| 81 | + $(gh run list --repo "{{ repo }}" --workflow release.yml --limit 1 --json databaseId --jq '.[0].databaseId') |
| 82 | + |
| 83 | +# List recent releases |
| 84 | +release-list: |
| 85 | + gh release list --repo "{{ repo }}" --limit 10 |
| 86 | + |
| 87 | +# Generate docs schema |
| 88 | +docs-schema: |
| 89 | + go run ./cmd/gendocs ./docs/docs/packaging/schema/ |
| 90 | + go run ./cmd/hermit dump-user-config-schema | sed 's,//,#,g' > docs/docs/usage/user-config-schema.hcl |
0 commit comments