Publish images under the git version tag too
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+14
-5
@@ -5,6 +5,9 @@
|
||||
# ./publish.sh # builds HEAD
|
||||
# ./publish.sh v1.2 # builds a tag/branch/commit
|
||||
#
|
||||
# The image is tagged with the commit and `latest`, plus the version when the commit has a git tag
|
||||
# like v1.2. To release a new version: git tag v1.2 && ./publish.sh v1.2
|
||||
#
|
||||
# One-time setup: docker login git.goyban.com (password = a Gitea token with package write access)
|
||||
set -euo pipefail
|
||||
|
||||
@@ -15,9 +18,15 @@ REF="${1:-HEAD}"
|
||||
cd "$(dirname "$0")"
|
||||
SHA="$(git rev-parse --short "$REF^{commit}")"
|
||||
|
||||
echo "Building $IMAGE from $REF ($SHA)"
|
||||
git archive --format=tar "$REF" | docker build --target runtime -t "$IMAGE:$SHA" -t "$IMAGE:latest" -
|
||||
# Newest version tag (v1.2, v1.2.3) on this commit, if any.
|
||||
VERSION="$(git tag --points-at "$SHA" --list 'v[0-9]*' --sort=-v:refname | head -n 1)"
|
||||
TAGS=("$SHA" latest)
|
||||
if [ -n "$VERSION" ]; then TAGS+=("$VERSION"); fi
|
||||
|
||||
docker push "$IMAGE:$SHA"
|
||||
docker push "$IMAGE:latest"
|
||||
echo "Pushed $IMAGE:$SHA and $IMAGE:latest"
|
||||
echo "Building $IMAGE from $REF ($SHA${VERSION:+, $VERSION})"
|
||||
BUILD_TAGS=()
|
||||
for t in "${TAGS[@]}"; do BUILD_TAGS+=(-t "$IMAGE:$t"); done
|
||||
git archive --format=tar "$REF" | docker build --target runtime "${BUILD_TAGS[@]}" -
|
||||
|
||||
for t in "${TAGS[@]}"; do docker push "$IMAGE:$t"; done
|
||||
echo "Pushed $IMAGE with tags: ${TAGS[*]}"
|
||||
|
||||
Reference in New Issue
Block a user