#!/usr/bin/env bash # release-prev-rc.sh []: `sha:` of the previous rc, 0006:compat's requester (SWC_COMPAT_REQUESTER: the # previous rc's CLI), from the release account's public records (no credential): a version's manifest names its linux/amd64 # artifact as main//binaries/... (`sha:`), or, for the one rc rolled by hand (rc176, plan 0040 owner # decision 17), local//binaries/... (`local:`) # (no argument) the version channel rc points at: `test` runs before promote moves the channel (scripts/ci-test.sh staging) # promote's RELEASE_VERSION (vX.Y.Z-rcN), which channel rc already points at when scripts/promote.sh runs: # the rc numbered one below it (rc0: the version channel stable points at). That rc may be one a red promote # rolled back: release-workload gives the command no PREVIOUS_* (only its rollback job gets them) set -euo pipefail did=did:plc:gmlkrhimoueejcertevr4hl3 key=socialweb-computer pds=$(curl -fsSL --retry 3 "https://plc.directory/$did" | jq -r '.service[] | select(.id == "#atproto_pds") | .serviceEndpoint') get() { curl -fsSL --retry 3 "$pds/xrpc/com.atproto.repo.getRecord?repo=$did&collection=$1&rkey=$2"; } channel() { local v; v=$(get software.release.channel "$key:$1" | jq -r '.value.version.uri'); echo "${v##*/}"; } if [ $# = 0 ]; then v=$(channel rc) elif [[ $1 =~ ^(.+)-rc([0-9]+)$ ]]; then if [ "${BASH_REMATCH[2]}" -gt 0 ]; then v="$key:${BASH_REMATCH[1]}-rc$((BASH_REMATCH[2] - 1))"; else v=$(channel stable); fi else echo "usage: scripts/release-prev-rc.sh []" >&2 exit 2 fi m=$(get software.release.version "$v" | jq -r '.value.manifest.uri') u=$(get software.release.manifest "${m##*/}" | jq -r '[.value.artifacts[] | select(.name | test("linux-amd64$"))][0].url') [[ $u =~ /(main|local)/([0-9a-f]{40})/ ]] || { echo "release-prev-rc: $v names no main/ or local/ artifact: $u" >&2; exit 1; } case ${BASH_REMATCH[1]} in main) echo "sha:${BASH_REMATCH[2]}" ;; local) echo "local:${BASH_REMATCH[2]}" ;; esac