feat: add crucible image and sow-tools binary channel promote #27
@@ -69,21 +69,3 @@ jobs:
|
||||
"${api}/releases/${id}/assets?name=$(basename "$f")"
|
||||
done
|
||||
'
|
||||
|
||||
- name: Promote channel
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
||||
env:
|
||||
TAG: ${{ github.ref_name }}
|
||||
GITEA_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
|
||||
GITEA_SERVER: ${{ github.server_url }}
|
||||
GITEA_OWNER: ${{ github.repository_owner }}
|
||||
GITEA_REPO: ${{ github.repository }}
|
||||
run: |
|
||||
nix develop --command bash -c '
|
||||
set -euo pipefail
|
||||
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
bash scripts/promote-sow-tools.sh release "$TAG"
|
||||
else
|
||||
printf "unsupported tag for service tier: %s\n" "$TAG" >&2; exit 1
|
||||
fi
|
||||
'
|
||||
|
||||
@@ -50,22 +50,3 @@ jobs:
|
||||
bash scripts/emit-release-fragment.sh
|
||||
- uses: actions/upload-artifact@v3
|
||||
with: { name: release-fragment, path: release-fragment.json }
|
||||
|
||||
# Service tier: only vX.Y.Z → release; anything else rejects.
|
||||
# SHA is the 12-char git SHA from the "Resolve tag" step above.
|
||||
- name: Promote channel
|
||||
env:
|
||||
TAG: ${{ github.ref_name }}
|
||||
SHA: ${{ steps.tag.outputs.sha }}
|
||||
GITEA_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
|
||||
GITEA_SERVER: ${{ github.server_url }}
|
||||
GITEA_OWNER: ${{ github.repository_owner }}
|
||||
REGISTRY_HOST: ${{ env.REGISTRY }}
|
||||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
run: |
|
||||
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
nix shell nixpkgs#skopeo --command bash scripts/promote-crucible.sh release "$SHA"
|
||||
else
|
||||
printf 'unsupported tag for service tier: %s\n' "$TAG" >&2; exit 1
|
||||
fi
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# vendored from sow-platform/deploy/scripts/promote-gitea.sh — keep in sync
|
||||
# Channel pointer for crucible registry images (service tier).
|
||||
# channels.json values are the 12-char git SHAs used as image tags.
|
||||
set -euo pipefail
|
||||
|
||||
: "${GITEA_SERVER:?set GITEA_SERVER}"
|
||||
: "${GITEA_TOKEN:?set GITEA_TOKEN}"
|
||||
: "${GITEA_OWNER:?set GITEA_OWNER}"
|
||||
: "${REGISTRY_HOST:?set REGISTRY_HOST}"
|
||||
: "${REGISTRY_USER:?set REGISTRY_USER}"
|
||||
: "${REGISTRY_PASSWORD:?set REGISTRY_PASSWORD}"
|
||||
|
||||
STREAM_NAME=crucible
|
||||
STREAM_TIER=service
|
||||
DRY_RUN="${DRY_RUN:-0}"
|
||||
|
||||
need() { command -v "$1" >/dev/null 2>&1 || { printf 'need: %s not found\n' "$1" >&2; exit 1; }; }
|
||||
need jq curl skopeo
|
||||
die() { printf '[channels] ERROR: %s\n' "$*" >&2; exit 1; }
|
||||
log() { printf '[channels] %s\n' "$*" >&2; }
|
||||
|
||||
require_release() {
|
||||
local tag="$1"
|
||||
skopeo inspect \
|
||||
--creds "${REGISTRY_USER}:${REGISTRY_PASSWORD}" \
|
||||
"docker://${REGISTRY_HOST}/deployment/crucible:${tag}" \
|
||||
>/dev/null 2>&1 \
|
||||
|| die "no published image crucible:${tag}"
|
||||
}
|
||||
|
||||
# ---- promote-gitea.sh body (paste verbatim from sow-platform/deploy/scripts/promote-gitea.sh) ----
|
||||
_auth="Authorization: token ${GITEA_TOKEN}"
|
||||
_pkg_url="${GITEA_SERVER}/api/packages/${GITEA_OWNER}/generic/deployment-channels/${STREAM_NAME}/channels.json"
|
||||
_pkg_del="${GITEA_SERVER}/api/v1/packages/${GITEA_OWNER}/generic/deployment-channels/${STREAM_NAME}"
|
||||
|
||||
valid_channel() { case "$1" in current|previous) return 0 ;; *) return 1 ;; esac; }
|
||||
|
||||
read_channels() {
|
||||
local tmp status
|
||||
tmp="$(mktemp)"
|
||||
status="$(curl -fsS -o "$tmp" -w "%{http_code}" -H "$_auth" "$_pkg_url" 2>/dev/null || echo "000")"
|
||||
case "$status" in
|
||||
200) jq -e . "$tmp" >/dev/null 2>&1 || die "existing channels.json is invalid"; cat "$tmp" ;;
|
||||
404|000) printf '{}\n' ;;
|
||||
*) die "read channels.json: HTTP $status" ;;
|
||||
esac
|
||||
rm -f "$tmp"
|
||||
}
|
||||
|
||||
write_channels() {
|
||||
local json="$1" tmp
|
||||
jq -e . <<<"$json" >/dev/null 2>&1 || die "refusing to write invalid channels.json"
|
||||
tmp="$(mktemp)"; jq -S . <<<"$json" >"$tmp"
|
||||
if [[ "$DRY_RUN" == "1" ]]; then
|
||||
log "DRY_RUN: would write:"; jq -S . "$tmp" >&2; rm -f "$tmp"; return 0
|
||||
fi
|
||||
curl -fsS -X DELETE -H "$_auth" "$_pkg_del" >/dev/null 2>&1 || true
|
||||
curl -fsS -X PUT -H "$_auth" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary "@$tmp" \
|
||||
"$_pkg_url" >/dev/null || die "write channels.json failed"
|
||||
rm -f "$tmp"
|
||||
log "deployment-channels/crucible updated"
|
||||
jq -S . <<<"$json" >&2
|
||||
}
|
||||
|
||||
cmd="${1:-show}"
|
||||
case "$cmd" in
|
||||
show) read_channels | jq -S . ;;
|
||||
set)
|
||||
channel="${2:?usage: promote set <channel> <tag>}"
|
||||
tag="${3:?usage: promote set <channel> <tag>}"
|
||||
valid_channel "$channel" || die "unknown channel: $channel"
|
||||
require_release "$tag"
|
||||
write_channels "$(read_channels | jq --arg c "$channel" --arg t "$tag" '.[$c]=$t')"
|
||||
;;
|
||||
release)
|
||||
tag="${2:?usage: promote release <tag>}"
|
||||
require_release "$tag"
|
||||
write_channels "$(read_channels | jq --arg t "$tag" '
|
||||
(if .current then .previous = .current else . end) | .current = $t')"
|
||||
;;
|
||||
*) die "usage: promote show | set <channel> <tag> | release <tag>" ;;
|
||||
esac
|
||||
@@ -1,78 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# vendored from sow-platform/deploy/scripts/promote-gitea.sh — keep in sync
|
||||
# Channel pointer for sow-tools binary releases (service tier).
|
||||
# channels.json values are version tags (vX.Y.Z), not SHAs.
|
||||
set -euo pipefail
|
||||
|
||||
: "${GITEA_SERVER:?set GITEA_SERVER}"
|
||||
: "${GITEA_TOKEN:?set GITEA_TOKEN}"
|
||||
: "${GITEA_OWNER:?set GITEA_OWNER}"
|
||||
: "${GITEA_REPO:?set GITEA_REPO}"
|
||||
|
||||
STREAM_NAME=sow-tools
|
||||
STREAM_TIER=service
|
||||
DRY_RUN="${DRY_RUN:-0}"
|
||||
|
||||
need() { command -v "$1" >/dev/null 2>&1 || { printf 'need: %s not found\n' "$1" >&2; exit 1; }; }
|
||||
need jq curl
|
||||
die() { printf '[channels] ERROR: %s\n' "$*" >&2; exit 1; }
|
||||
log() { printf '[channels] %s\n' "$*" >&2; }
|
||||
|
||||
require_release() {
|
||||
local tag="$1" status
|
||||
status="$(curl -fsS -o /dev/null -w "%{http_code}" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${GITEA_SERVER}/api/v1/repos/${GITEA_REPO}/releases/tags/${tag}" \
|
||||
2>/dev/null || echo "000")"
|
||||
[[ "$status" == "200" ]] || die "no Gitea release for tag ${tag} (HTTP $status)"
|
||||
}
|
||||
|
||||
_auth="Authorization: token ${GITEA_TOKEN}"
|
||||
_pkg_url="${GITEA_SERVER}/api/packages/${GITEA_OWNER}/generic/deployment-channels/${STREAM_NAME}/channels.json"
|
||||
_pkg_del="${GITEA_SERVER}/api/v1/packages/${GITEA_OWNER}/generic/deployment-channels/${STREAM_NAME}"
|
||||
|
||||
valid_channel() { case "$1" in current|previous) return 0 ;; *) return 1 ;; esac; }
|
||||
|
||||
read_channels() {
|
||||
local tmp status
|
||||
tmp="$(mktemp)"
|
||||
status="$(curl -fsS -o "$tmp" -w "%{http_code}" -H "$_auth" "$_pkg_url" 2>/dev/null || echo "000")"
|
||||
case "$status" in
|
||||
200) jq -e . "$tmp" >/dev/null 2>&1 || die "invalid channels.json"; cat "$tmp" ;;
|
||||
404|000) printf '{}\n' ;;
|
||||
*) die "read channels.json: HTTP $status" ;;
|
||||
esac
|
||||
rm -f "$tmp"
|
||||
}
|
||||
|
||||
write_channels() {
|
||||
local json="$1" tmp
|
||||
jq -e . <<<"$json" >/dev/null 2>&1 || die "refusing to write invalid channels.json"
|
||||
tmp="$(mktemp)"; jq -S . <<<"$json" >"$tmp"
|
||||
if [[ "$DRY_RUN" == "1" ]]; then
|
||||
log "DRY_RUN: would write:"; jq -S . "$tmp" >&2; rm -f "$tmp"; return 0
|
||||
fi
|
||||
curl -fsS -X DELETE -H "$_auth" "$_pkg_del" >/dev/null 2>&1 || true
|
||||
curl -fsS -X PUT -H "$_auth" -H "Content-Type: application/octet-stream" \
|
||||
--data-binary "@$tmp" "$_pkg_url" >/dev/null || die "write failed"
|
||||
rm -f "$tmp"
|
||||
log "deployment-channels/sow-tools updated"; jq -S . <<<"$json" >&2
|
||||
}
|
||||
|
||||
cmd="${1:-show}"
|
||||
case "$cmd" in
|
||||
show) read_channels | jq -S . ;;
|
||||
set)
|
||||
channel="${2:?}"; tag="${3:?}"
|
||||
valid_channel "$channel" || die "unknown channel: $channel"
|
||||
require_release "$tag"
|
||||
write_channels "$(read_channels | jq --arg c "$channel" --arg t "$tag" '.[$c]=$t')"
|
||||
;;
|
||||
release)
|
||||
tag="${2:?}"
|
||||
require_release "$tag"
|
||||
write_channels "$(read_channels | jq --arg t "$tag" '
|
||||
(if .current then .previous = .current else . end) | .current = $t')"
|
||||
;;
|
||||
*) die "usage: promote show | set <channel> <tag> | release <tag>" ;;
|
||||
esac
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
fail() { echo "FAIL: $*" >&2; exit 1; }
|
||||
promote="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/scripts/promote-crucible.sh"
|
||||
[[ -f "$promote" ]] || fail "promote-crucible.sh missing"
|
||||
grep -q 'STREAM_NAME=crucible' "$promote" || fail "STREAM_NAME not crucible"
|
||||
grep -q 'STREAM_TIER=service' "$promote" || fail "STREAM_TIER not service"
|
||||
grep -q 'skopeo inspect' "$promote" || fail "require_release must use skopeo"
|
||||
grep -q 'deployment/crucible' "$promote" || fail "wrong image path in skopeo"
|
||||
echo "promote-crucible-contract: OK"
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
fail() { echo "FAIL: $*" >&2; exit 1; }
|
||||
promote="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/scripts/promote-sow-tools.sh"
|
||||
[[ -f "$promote" ]] || fail "promote-sow-tools.sh missing"
|
||||
grep -q 'STREAM_NAME=sow-tools' "$promote" || fail "STREAM_NAME not sow-tools"
|
||||
grep -q 'STREAM_TIER=service' "$promote" || fail "STREAM_TIER not service"
|
||||
grep -q 'api/v1/repos' "$promote" || fail "require_release must use Gitea releases API"
|
||||
grep -qv 'skopeo' "$promote" || fail "should not use skopeo (no registry images)"
|
||||
echo "promote-sow-tools-contract: OK"
|
||||
Reference in New Issue
Block a user