Each release is now a Gitea release as well as an image: scripts/release.sh takes the binary (or the page's files) out of the deployed image, checks its version, and attaches it as a tarball with the changelog section as the notes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
2.3 KiB
Bash
Executable File
47 lines
2.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# Publish a Gitea release for one service's tag, with a tarball taken from the image that was
|
|
# deployed, so what is attached is what runs on Tower. Run after the release commit is tagged,
|
|
# pushed and its image built and pushed: sh scripts/release.sh ipx|directory|web
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
|
|
case "${1:-}" in
|
|
ipx) name=ipx; ver=$(sed -n 's/^version = "\(.*\)"/\1/p' crates/ipx/Cargo.toml | head -1)
|
|
tag=v$ver; log=crates/ipx/CHANGELOG.md; from=/usr/local/bin/ipx ;;
|
|
directory) name=ipx-directory; ver=$(sed -n 's/^version = "\(.*\)"/\1/p' crates/directory/Cargo.toml | head -1)
|
|
tag=directory-v$ver; log=crates/directory/CHANGELOG.md; from=/usr/local/bin/ipx-directory ;;
|
|
web) name=ipx-web; ver=$(node -p 'require("./package.json").version')
|
|
tag=web-v$ver; log=web/CHANGELOG.md; from=/srv ;;
|
|
*) echo "usage: $0 ipx|directory|web" >&2; exit 2 ;;
|
|
esac
|
|
|
|
case "$ver" in *-dev) echo "$name is at $ver: release it first" >&2; exit 1 ;; esac
|
|
git fetch -q --tags origin
|
|
git merge-base --is-ancestor "$tag" origin/main || { echo "$tag is not on origin/main" >&2; exit 1; }
|
|
|
|
out=$(mktemp -d); trap 'rm -rf "$out"' EXIT
|
|
dir=$out/$name-$ver; mkdir "$dir"
|
|
image=192.168.1.130:5000/$name:latest
|
|
c=$(docker create "$image"); trap 'docker rm -f "$c" >/dev/null; rm -rf "$out"' EXIT
|
|
if [ "$name" = ipx-web ]; then
|
|
docker cp -q "$c:$from/." "$dir/"
|
|
cp web/Caddyfile "$dir/"
|
|
# latest may be a later build than the tag: the page carries its version, so check it.
|
|
grep -qF "$ver" "$dir"/app.js || { echo "$image is not ipx-web $ver" >&2; exit 1; }
|
|
arch=any
|
|
else
|
|
docker cp -q "$c:$from" "$dir/"
|
|
"$dir/$name" --version | grep -qF " $ver" || { echo "$image is not $name $ver" >&2; exit 1; }
|
|
arch=linux-$(uname -m)
|
|
fi
|
|
cp LICENSE README.md "$dir/"; cp "$log" "$dir/CHANGELOG.md"
|
|
tarball=$out/$name-$ver-$arch.tar.gz
|
|
tar -C "$out" -czf "$tarball" "$name-$ver"
|
|
|
|
# The notes are this version's section of the changelog, without its heading.
|
|
awk -v h="## [$ver]" 'index($0, h) == 1 {p = 1; next} p && /^## \[/ {exit} p' "$log" > "$out/notes.md"
|
|
[ -s "$out/notes.md" ] || { echo "no [$ver] section in $log" >&2; exit 1; }
|
|
|
|
timeout 120 /src/tea releases create --login git.sdf1.net --repo rays/ipx --tag "$tag" \
|
|
--title "$name $ver" --note-file "$out/notes.md" --asset "$tarball" < /dev/null
|