sector-f-linux

Sector F Linux
git clone https://git.sectorflabs.com/sector-f-linux.git
Log | Files | Refs | README | LICENSE

publish.sh (1680B)


      1 #!/usr/bin/env bash
      2 # Pushes the real image to GitHub's container registry, where machines follow it with
      3 # `bootc switch` (or the updater app). It is the image `make build` made (SYSTEM_IMAGE, the
      4 # Containerfile's `system` stage), the same one `make iso` carries, so what was tried is what ships;
      5 # it is not rebuilt here. This is the only thing that pushes to a registry.
      6 #
      7 #   make build && make publish
      8 #
      9 # PUBLISH_REPO is where it goes (default ghcr.io/sector-f-labs/sector-f-linux). Logs in with the
     10 # token of `gh` (scope write:packages). Two tags are pushed: latest, and a UTC timestamp to go back to.
     11 #
     12 # The push goes through skopeo, from Docker's own daemon, and not `docker push`: Docker pushes an
     13 # OCI manifest whose own layers carry Docker's media type, which bootc rejects on an upgrade
     14 # ("Unhandled layer type"); skopeo writes every layer as OCI. See ADR-0009.
     15 source "$(dirname "$0")/vm/common.sh"
     16 
     17 STAMP=$(date -u +%Y%m%d-%H%M%S)
     18 docker image inspect "$SYSTEM_IMAGE" >/dev/null 2>&1 || die "no $SYSTEM_IMAGE; make build first"
     19 
     20 registry=${REPO%%/*}
     21 user=$(gh api user --jq .login)
     22 say "pushing $REPO:latest and $REPO:$STAMP, with OCI layers"
     23 # The token goes in on stdin, not on a command line.
     24 gh auth token | docker run --rm -i --network host -v /var/run/docker.sock:/var/run/docker.sock "$SYSTEM_IMAGE" \
     25   sh -euc 'skopeo login "$1" -u "$2" --password-stdin >/dev/null
     26            skopeo copy --format oci "docker-daemon:$3" "docker://$4:latest"
     27            skopeo copy "docker://$4:latest" "docker://$4:$5"' sh "$registry" "$user" "$SYSTEM_IMAGE" "$REPO" "$STAMP" >/dev/null
     28 
     29 say "done: $REPO:latest and $REPO:$STAMP (machines: bootc switch $REPO:latest)"