cat / 012
clone

a spreadsheet for the terminal: lotus 1-2-3 looks, google sheets keys and formulas, one go binary

cat/module-path
012 / scripts / site-release.sh
site-release.sh 2.9K executable
1#!/usr/bin/env bash2# site-release.sh - what `make site-release` does after `make site`:3# puts a release's archives and SHA256SUMS in the built site under4# /releases/<version>/ and /releases/latest/, and the install scripts at5# its root. See docs/contributing/releasing.md.6#7# VERSION=v1.2.3 the release to serve; the newest version tag by default8# SITE_URL the site's address, which the install scripts download from9#10# The archives come from dist/ when it holds that version; otherwise11# `make dist` builds them in a temporary checkout of the tag, so the12# site can be published from a later commit, and they're kept in dist/.13set -euo pipefail1415root=$(cd "$(dirname "$0")/.." && pwd)16cd "$root"1718site="$root/website/build"19if [ ! -f "$site/index.html" ]; then20 echo "site-release: no site in website/build; run make site first" >&221 exit 122fi2324version=${VERSION:-$(git tag --list 'v[0-9]*' --sort=-v:refname | head -n 1)}25if [ -z "$version" ]; then26 echo "site-release: no version tag to serve; set VERSION" >&227 exit 128fi29if ! git rev-parse -q --verify "refs/tags/$version" >/dev/null; then30 echo "site-release: $version isn't a tag" >&231 exit 132fi3334# dist/ holds this version when every archive in SHA256SUMS is named for it.35holds() {36 [ -f "$1/SHA256SUMS" ] && [ -s "$1/SHA256SUMS" ] &&37 ! grep -qv " 012_${version#v}_" "$1/SHA256SUMS"38}3940dist="$root/dist"41if ! holds "$dist"; then42 tmp=$(mktemp -d)43 trap 'git -C "$root" worktree remove --force "$tmp/src" 2>/dev/null || true; rm -rf "$tmp"' EXIT44 echo "site-release: building $version in a checkout of the tag"45 git worktree add -q --detach "$tmp/src" "$version"46 make -C "$tmp/src" dist VERSION="$version"47 holds "$tmp/src/dist" || {48 echo "site-release: make dist left no archives for $version" >&249 exit 150 }51 rm -rf "$dist"52 cp -R "$tmp/src/dist" "$dist"53fi54(55 cd "$dist"56 if command -v sha256sum >/dev/null 2>&1; then57 sha256sum -c --quiet SHA256SUMS58 else59 shasum -a 256 -c --quiet SHA256SUMS60 fi61)6263# The scripts name https://012.dev.site; a site built for another SITE_URL64# serves scripts that download from itself.65url=${SITE_URL:-https://012.dev.site}66url=${url%/}6768rm -rf "$site/releases"69for dir in "$version" latest; do70 mkdir -p "$site/releases/$dir"71 (cd "$dist" && cp SHA256SUMS 012_* "$site/releases/$dir/")72 {73 printf '<!doctype html>\n<meta charset="utf-8">\n<title>012 %s</title>\n' "$version"74 printf '<h1>012 %s</h1>\n<p>Checksums: <a href="SHA256SUMS">SHA256SUMS</a>. ' "$version"75 printf 'Install with <code>curl -fsSL %s/install.sh | sh</code>.</p>\n<ul>\n' "$url"76 (cd "$dist" && for f in 012_*; do printf '<li><a href="%s">%s</a></li>\n' "$f" "$f"; done)77 printf '</ul>\n'78 } >"$site/releases/$dir/index.html"79done80for f in install.sh install.ps1; do81 sed "s|https://012\.dev\.site|$url|g" "scripts/install/$f" >"$site/$f"82done83echo "site-release: $version in website/build/releases/{$version,latest}, install.sh and install.ps1 at the root"