@@ -43,15 +43,90 @@ Wrap this in a `just setup` recipe for consistent developer experience.
4343### Example justfile
4444
4545``` just
46- # First-time setup: init submodule + download FFmpeg libraries
46+ # Check ffmpeg-statigo submodule is present
47+ _check-submodule:
48+ #!/usr/bin/env bash
49+ if [ ! -f "third_party/ffmpeg-statigo/go.mod" ]; then
50+ echo "Error: ffmpeg-statigo submodule not initialised. Run 'just setup' first."
51+ exit 1
52+ fi
53+ if [ ! -f "third_party/ffmpeg-statigo/lib/$(go env GOOS)_$(go env GOARCH)/libffmpeg.a" ]; then
54+ echo "Error: ffmpeg-statigo library not downloaded. Run 'just setup' first."
55+ exit 1
56+ fi
57+
58+ # Get latest stable ffmpeg-statigo release tag from GitHub
59+ _get-latest-tag:
60+ #!/usr/bin/env bash
61+ if command -v jq &> /dev/null; then
62+ curl -s https://api.github.com/repos/linuxmatters/ffmpeg-statigo/releases | \
63+ jq -r '[.[] | select(.prerelease == false and .draft == false and (.tag_name | startswith("v")))][0].tag_name'
64+ else
65+ curl -s https://api.github.com/repos/linuxmatters/ffmpeg-statigo/releases | \
66+ grep -B5 '"prerelease": false' | grep '"tag_name"' | grep -v 'lib-' | head -1 | cut -d'"' -f4
67+ fi
68+
69+ # Setup or update ffmpeg-statigo submodule and library
4770setup:
71+ #!/usr/bin/env bash
72+ set -e
73+ echo "Configuring git for submodule-friendly pulls..."
4874 git config pull.ff only
4975 git config submodule.recurse true
50- git submodule update --init --recursive
76+
77+ # Get latest stable release tag
78+ TAG=$(just _get-latest-tag)
79+ if [ -z "$TAG" ] || [ "$TAG" = "null" ]; then
80+ echo "Error: Could not fetch latest release tag"
81+ exit 1
82+ fi
83+
84+ # Initialise submodule if not already present
85+ if [ ! -f "third_party/ffmpeg-statigo/go.mod" ]; then
86+ echo "Initialising ffmpeg-statigo submodule..."
87+ git submodule update --init --recursive
88+ fi
89+
90+ # Check current version
91+ cd third_party/ffmpeg-statigo
92+ git fetch --tags
93+ CURRENT=$(git describe --tags --exact-match 2>/dev/null || echo "")
94+
95+ if [ "$CURRENT" = "$TAG" ]; then
96+ echo "ffmpeg-statigo already at latest version ($TAG)"
97+ cd ../..
98+ else
99+ if [ -n "$CURRENT" ]; then
100+ echo "Updating ffmpeg-statigo from $CURRENT to $TAG..."
101+ else
102+ echo "Setting up ffmpeg-statigo $TAG..."
103+ fi
104+ git checkout "$TAG"
105+ cd ../..
106+
107+ # Remove old library to force re-download
108+ rm -f third_party/ffmpeg-statigo/lib/*/libffmpeg.a
109+
110+ # Stage the submodule change
111+ git add third_party/ffmpeg-statigo
112+ fi
113+
114+ # Download libraries (will skip if correct version already exists)
115+ echo "Checking ffmpeg-statigo libraries..."
51116 cd third_party/ffmpeg-statigo && go run ./cmd/download-lib
117+ cd ../..
118+
119+ # Check if there are staged changes to commit
120+ if git diff --cached --quiet third_party/ffmpeg-statigo; then
121+ echo "Setup complete!"
122+ else
123+ echo ""
124+ echo "Setup complete! Submodule updated to $TAG"
125+ echo "Don't forget to commit: git commit -m 'chore: update ffmpeg-statigo to $TAG'"
126+ fi
52127
53128# Build the project
54- build:
129+ build: _check-submodule
55130 CGO_ENABLED=1 go build -o myapp ./cmd/myapp
56131```
57132
0 commit comments