#!/usr/bin/env bash # Publishes a Cobble release to GitHub. # # scripts/publish-github.sh # # Runs the release gate from RELEASING.md (clean tree, typecheck, tests, # installer syntax), tags HEAD with the package.json version, pushes main and # the tag to the `origin` remote, then creates the GitHub release. Publishing # that release is what fires .github/workflows/release.yml, which builds the # multi-arch image and pushes it to GHCR, the registry the installer defaults # to. It never pushes to Gitea: that registry is on the VPN, out of a # runner's reach, so scripts/mirror-gitea.sh copies the image separately. # # Run scripts/publish-gitea.sh afterwards for the source mirror's own release # object, and scripts/mirror-gitea.sh once the image build has finished. set -Eeuo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=lib/publish-common.sh . "$SCRIPT_DIR/lib/publish-common.sh" # shellcheck source=lib/publish-release.sh . "$SCRIPT_DIR/lib/publish-release.sh" REMOTE="origin" usage() { cat </dev/null 2>&1 || fail "The GitHub CLI is not logged in. Run: gh auth login" ok "gh is logged in." fi run_release_checks prepare_tag write_notes_file "$COMPARE_URL" step "Publishing $TAG to GitHub ($REMOTE_OWNER/$REMOTE_REPO)" printf ' %sremote%s %s\n' "$C_DIM" "$C_RESET" "$remote_url" printf ' %snotes%s %s\n' "$C_DIM" "$C_RESET" "$NOTES_FILE" confirm "Publish $TAG to GitHub and start the image build?" push_branch_and_tag "$REMOTE" if gh release view "$TAG" -R "$REMOTE_OWNER/$REMOTE_REPO" >/dev/null 2>&1; then release_already_exists "The GitHub release" else # Publishing the release is what starts the image build. run gh release create "$TAG" \ --repo "$REMOTE_OWNER/$REMOTE_REPO" \ --title "$TAG" \ --notes-file "$NOTES_FILE" \ --target "$BRANCH" \ --latest ok "Created the GitHub release; the release workflow is building the images." fi print_release_summary "$REMOTE" "$BRANCH" "https://github.com/${REMOTE_OWNER}/${REMOTE_REPO}/releases/tag/$TAG" printf '\nThe release workflow builds and pushes the images; follow it with:\n gh run watch\n'