This commit is contained in:
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/bin/sh
|
||||
# Assemble the exact URL layout documented in .gitea/README.md from committed
|
||||
# Git revisions. Using git archive, rather than copying the working tree, keeps
|
||||
# uncommitted experiments and ignored pack exports out of published images.
|
||||
set -eu
|
||||
|
||||
repo_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
cd "$repo_root"
|
||||
|
||||
dev_ref=${1:-HEAD}
|
||||
build_root="$repo_root/.build"
|
||||
site_root="$build_root/site"
|
||||
work_root="$build_root/work"
|
||||
|
||||
rm -rf "$site_root" "$work_root"
|
||||
mkdir -p "$site_root/forever/releases" "$work_root"
|
||||
|
||||
export_pack() {
|
||||
revision=$1
|
||||
pack=$2
|
||||
destination=$3
|
||||
scratch="$work_root/export"
|
||||
|
||||
rm -rf "$scratch"
|
||||
mkdir -p "$scratch" "$(dirname -- "$destination")"
|
||||
|
||||
if ! git cat-file -e "$revision:$pack/pack.toml" 2>/dev/null; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
git archive "$revision" "$pack" | tar -x -C "$scratch"
|
||||
mv "$scratch/$pack" "$destination"
|
||||
}
|
||||
|
||||
# main is always the development source, including when this script runs for a
|
||||
# release-tag event whose checked-out commit is intentionally older than main.
|
||||
export_pack "$dev_ref" forever "$site_root/forever/dev"
|
||||
|
||||
# Playground is documented but intentionally incomplete today. Start serving
|
||||
# it automatically as soon as a committed playground/pack.toml exists.
|
||||
if export_pack "$dev_ref" playground "$site_root/playground/dev"; then
|
||||
echo "Published playground development pack from $dev_ref"
|
||||
else
|
||||
echo "Skipping playground: $dev_ref has no playground/pack.toml" >&2
|
||||
fi
|
||||
|
||||
# Each forever-vX.Y.Z tag becomes an immutable URL. Version-aware Git sorting
|
||||
# also identifies the newest release to copy to the stable channel.
|
||||
release_tags=$(git tag --list 'forever-v*' --sort=-version:refname \
|
||||
| grep -E '^forever-v[0-9]+\.[0-9]+\.[0-9]+$' || true)
|
||||
|
||||
for tag in $release_tags; do
|
||||
version=${tag#forever-}
|
||||
export_pack "$tag" forever "$site_root/forever/releases/$version"
|
||||
echo "Published Forever release $version"
|
||||
done
|
||||
|
||||
latest_tag=$(printf '%s\n' "$release_tags" | sed -n '/./{p;q;}')
|
||||
if [ -n "$latest_tag" ]; then
|
||||
export_pack "$latest_tag" forever "$site_root/forever/stable"
|
||||
echo "Promoted ${latest_tag#forever-} to Forever stable"
|
||||
else
|
||||
echo "No forever-vX.Y.Z tag exists; /forever/stable is not published yet" >&2
|
||||
fi
|
||||
|
||||
rm -rf "$work_root"
|
||||
Reference in New Issue
Block a user