#!/usr/bin/env bash # publish-release.sh — put a built release on both mirrors. # # tools/publish-release.sh # build, then publish # tools/publish-release.sh --dry-run # say what would happen # # A Silent Mode release is not shipped until it exists in both places: # # silentmode.st over scp, served by nginx on the VPS # silentmode.bch on Sia, reached through any BCNR resolver # # Publishing to only one is the recurring mistake this script exists to # prevent. A release on silentmode.st alone is a release that disappears when # the VPS does, which rather undercuts the argument the project is making. set -euo pipefail here="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$here" SSH_HOST="${SIRIUS_SSH_HOST:-silentmode}" WEB_ROOT="${SIRIUS_WEB_ROOT:-/opt/silent-mode/site/sirius-press}" S3_ENDPOINT="${SIRIUS_S3_ENDPOINT:-https://s3.silentmode.st:8600}" S3_PREFIX="${SIRIUS_S3_PREFIX:-s3://bns/silentmode/sirius-press}" AWS_PROFILE_NAME="${SIRIUS_AWS_PROFILE:-sia-storage}" DRY=0 for arg in "$@"; do case "$arg" in --dry-run) DRY=1 ;; *) echo "unknown option: $arg" >&2; exit 2 ;; esac done say() { printf '\033[1m→\033[0m %s\n' "$*"; } warn() { printf '\033[33mwarning:\033[0m %s\n' "$*" >&2; } die() { printf '\033[31merror:\033[0m %s\n' "$*" >&2; exit 1; } run() { if [ "$DRY" -eq 1 ]; then printf ' would run: %s\n' "$*"; else "$@"; fi; } VERSION="$(grep -m1 "^ \* Version:" plugins/sirius-press-core/sirius-press-core.php | awk '{print $3}')" [ -n "$VERSION" ] || die "could not read the version out of sirius-press-core.php" ARCHIVE="dist/sirius-press-${VERSION}.zip" # ------------------------------------------------------------------- build if [ ! -f "$ARCHIVE" ]; then say "building $VERSION" [ "$DRY" -eq 1 ] && { echo " would run: tools/build.sh --zip"; } || tools/build.sh --zip fi [ "$DRY" -eq 1 ] || [ -f "$ARCHIVE" ] || die "$ARCHIVE was not produced" if [ -f "$ARCHIVE" ]; then SHA="$(cat "${ARCHIVE}.sha256" 2>/dev/null || sha256sum "$ARCHIVE" | cut -d' ' -f1)" say "$(basename "$ARCHIVE") — $(du -h "$ARCHIVE" | cut -f1), sha256 ${SHA}" else SHA="(not built)" fi # ---------------------------------------------------------------- manifest MANIFEST="dist/releases.json" say "writing $(basename "$MANIFEST")" if [ "$DRY" -eq 0 ]; then cat > "$MANIFEST" </dev/null || echo 000)" [ "$st_code" = "200" ] \ && echo " ok silentmode.st" \ || warn "silentmode.st returned ${st_code} for the archive" if command -v aws >/dev/null; then aws --profile "$AWS_PROFILE_NAME" --endpoint-url "$S3_ENDPOINT" \ s3 ls "${S3_PREFIX}/$(basename "$ARCHIVE")" >/dev/null 2>&1 \ && echo " ok silentmode.bch" \ || warn "the archive is not listed on the Sia mirror" fi fi cat <