Add version-based Docker cache invalidation for uv/opencode

Alternative approach to PR #37 - instead of busting cache on every build,
use git ls-remote to fetch latest version tags and pass them as build args.
Docker layer only rebuilds when tool versions actually change.

- Move uv install from base to runner stage alongside opencode
- Add UV_VERSION and OPENCODE_VERSION build args as cache keys
- Fetch versions via git ls-remote (no API rate limits)
- Log installed versions in build output for debugging

Ref: #37
This commit is contained in:
Chris Scott committed 2026-01-11 15:51:34 -05:00
1 parent f8ba8f1850
commit 9851ec06e0
2 files changed
+21 -6

No files matched your search

+12
View File
@@ -15,6 +15,15 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Get latest tool versions
id: versions
run: |
UV_VERSION=$(git ls-remote --tags --sort=-v:refname https://github.com/astral-sh/uv.git 'refs/tags/[0-9]*' | head -1 | sed 's/.*refs\/tags\///')
OPENCODE_VERSION=$(git ls-remote --tags --sort=-v:refname https://github.com/opencode-ai/opencode.git 'refs/tags/v*' | head -1 | sed 's/.*refs\/tags\///')
echo "uv=${UV_VERSION}" >> $GITHUB_OUTPUT
echo "opencode=${OPENCODE_VERSION}" >> $GITHUB_OUTPUT
echo "Detected versions: uv=${UV_VERSION}, opencode=${OPENCODE_VERSION}"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
@@ -47,6 +56,9 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
UV_VERSION=${{ steps.versions.outputs.uv }}
OPENCODE_VERSION=${{ steps.versions.outputs.opencode }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: runner