Skip to content

Finish the DevKitCIoT Republish: Archive, Delete the History Repository, Then Audit #3940

Done

Description

@ptr727

Finish the DevKitCIoT Republish

On 2026-11-08, ptr727/DevKitCIoT was republished without its history, then made public. It holds one signed commit of the old main tree, and the trees are byte-identical. The recreate script's verify phase passed, configure.sh check matches, and the test workflow is green on the new main. The merge-bot secrets were restored separately. The maintainer chose to keep the repository live, not archived, for now. The old repository is private at ptr727/DevKitCIoT-history, kept for now. Its handoff chain (DevKitCIoT-history#27, track archive) is closed and points here.

Remaining steps, in order

Each needs the maintainer's explicit go-ahead at the time.

  1. Archive ptr727/DevKitCIoT, when the maintainer decides it is done being live: gh repo archive ptr727/DevKitCIoT --yes.
  2. Delete ptr727/DevKitCIoT-history, once the maintainer has looked at the new repository. This needs the delete_repo scope (gh auth refresh -h github.com -s delete_repo). Deleting it also deletes the old handoff chain and the copy of the recreate script on it. The script below is the copy to keep.
  3. Hub follow-up, after the archive, so the report measures the final state:
    • Run a fresh audit and commit reports/DevKitCIoT/audit.md.
    • Update docs/eol-lf-rollout.md, docs/pre-commit-hooks-rollout.md, and docs/reusable-workflows.md.
    • Set the registry entry to status: archived.

If the repository stays live long-term instead, step 3's registry change does not apply. The audit and checklists then measure a live repository.

Manual step for the live repository

Where the merge-bot (codegen) App, CodeRabbit, or Qodo is installed for selected repositories only, add the new ptr727/DevKitCIoT to it. The rename moved the old repository's access to DevKitCIoT-history. An agent's gh token cannot list App installations, so this was not checked.

Learned in the run

The recreate script, as run

This is the copy for the EspDinIoT run. Change REPO, ARCHIVE_NAME, TOPICS, and RELEASE_TAG for that repository, and move configure after publishing, per the first learning above. It is a dry run by default, and --execute runs the writes. Run it from a hub checkout at fresh main.

recreate-repo.sh
#!/usr/bin/env bash
# Recreate a fleet repository with no history: rename the old repository aside,
# create a fresh one under the original name holding one signed commit of the
# old main branch's tree, then restore its configuration.
#
# Dry run by default: every write is printed, not run. Pass --execute to run.
# Run from a hub checkout of ptr727/ProjectTemplate at a freshly fetched main,
# since the configure step uses its repo-config/configure.sh.

set -Eeuo pipefail

OWNER="ptr727"
REPO="DevKitCIoT"
ARCHIVE_NAME="DevKitCIoT-history"
MODEL="release"
TOPICS="kicad,esp32,esphome"
RELEASE_TAG="v0.2-alpha"
EXECUTE=0
PHASES="preflight,rename,create,push,configure,extras,release,verify"
WORK="${TMPDIR:-/tmp}/recreate-${REPO}"
HUB="$(pwd)"

usage() {
  cat <<'EOF'
Usage: recreate-repo.sh [--execute] [--phases LIST] [--work DIR]

Phases, in order: preflight, rename, create, push, configure, extras, release, verify.
  preflight  read-only checks and an inventory of the current repository
  rename     rename the current repository to the archive name (stays private)
  create     create the new private repository under the original name
  push       push one signed commit of the old main tree as main and develop
  configure  run the hub's configure.sh apply, then check
  extras     topics, workflow permissions, and the merge-bot secrets
  release    re-create the v0.2-alpha pre-release with its original asset
  verify     compare the new repository with the inventory and the old tree

Secrets are read from the environment when present, never from the old repository,
since GitHub does not return secret values:
  CODEGEN_APP_CLIENT_ID          the merge-bot App's client id
  CODEGEN_APP_PRIVATE_KEY_FILE   path to the merge-bot App's private key file

Options:
  --execute      run the writes instead of printing them
  --phases LIST  comma-separated subset of the phases above
  --work DIR     scratch directory for the inventory, tree export, and asset
  -h, --help     show this help
EOF
}

while (($#)); do
  case "$1" in
    --execute) EXECUTE=1 ;;
    --phases) PHASES="$2"; shift ;;
    --work) WORK="$2"; shift ;;
    -h | --help) usage; exit 0 ;;
    *) echo "unknown argument: $1" >&2; usage >&2; exit 64 ;;
  esac
  shift
done

has_phase() { [[ ",${PHASES}," == *",$1,"* ]]; }
log() { printf '\n== %s\n' "$*"; }

# Print a write in dry-run mode; run it, unsuppressed, with --execute.
write() {
  if ((EXECUTE)); then
    printf '+ %s\n' "$*"
    "$@"
  else
    printf 'DRY-RUN: %s\n' "$*"
  fi
}

die() { echo "error: $*" >&2; exit 1; }

mkdir -p "${WORK}"
OLD="${OWNER}/${REPO}"
ARCHIVED="${OWNER}/${ARCHIVE_NAME}"
NEW="${OWNER}/${REPO}"

if has_phase preflight; then
  log "preflight"
  [[ -x "${HUB}/repo-config/configure.sh" ]] || die "run from a hub checkout; ${HUB}/repo-config/configure.sh not found"
  gh auth status >/dev/null || die "gh is not authenticated"
  [[ "$(gh repo view "${OLD}" --json visibility --jq .visibility)" == "PRIVATE" ]] || die "${OLD} is not private"
  if gh repo view "${ARCHIVED}" --json name >/dev/null 2>&1; then die "${ARCHIVED} already exists"; fi
  open_prs="$(gh pr list --repo "${OLD}" --state open --json number --jq length)"
  [[ "${open_prs}" == "0" ]] || die "${OLD} has ${open_prs} open pull request(s)"
  main_tree="$(gh api "repos/${OLD}/commits/main" --jq .commit.tree.sha)"
  develop_tree="$(gh api "repos/${OLD}/commits/develop" --jq .commit.tree.sha)"
  [[ "${main_tree}" == "${develop_tree}" ]] || die "main and develop trees differ; promote develop first"
  echo "main tree ${main_tree} equals develop tree"
  gh api "repos/${OLD}" --jq '{description,homepage,has_issues,has_projects,has_wiki,allow_squash_merge,allow_merge_commit,allow_rebase_merge,allow_auto_merge,allow_update_branch,delete_branch_on_merge}' >"${WORK}/settings.json"
  gh api "repos/${OLD}/topics" --jq '.names' >"${WORK}/topics.json"
  gh api "repos/${OLD}/actions/permissions/workflow" >"${WORK}/workflow-permissions.json"
  gh api "repos/${OLD}/actions/secrets" --jq '[.secrets[].name]' >"${WORK}/secrets-actions.json"
  gh api "repos/${OLD}/dependabot/secrets" --jq '[.secrets[].name]' >"${WORK}/secrets-dependabot.json"
  gh release view "${RELEASE_TAG}" --repo "${OLD}" --json name,body,isPrerelease,assets >"${WORK}/release.json"
  rm -rf "${WORK}/asset"; mkdir -p "${WORK}/asset"
  gh release download "${RELEASE_TAG}" --repo "${OLD}" --dir "${WORK}/asset"
  echo "inventory written to ${WORK}"
  ls "${WORK}" "${WORK}/asset"
fi

if has_phase rename; then
  log "rename ${OLD} -> ${ARCHIVED} (stays private)"
  write gh repo rename "${ARCHIVE_NAME}" --repo "${OLD}" --yes
fi

if has_phase create; then
  log "create ${NEW} (private)"
  desc="$(python3 -c 'import json,sys;print(json.load(open(sys.argv[1]))["description"] or "")' "${WORK}/settings.json")"
  write gh repo create "${NEW}" --private --description "${desc}" --disable-wiki
fi

if has_phase push; then
  log "push one signed commit of ${ARCHIVED} main as ${NEW} main and develop"
  src="${WORK}/source"; dst="${WORK}/fresh"
  rm -rf "${src}" "${dst}"
  # After the rename, the old main lives at the archive name; before it, at the original.
  from="${OLD}"
  if ((EXECUTE)); then from="${ARCHIVED}"; fi
  git clone --quiet --branch main --single-branch "https://github.com/${from}.git" "${src}"
  src_tree="$(git -C "${src}" rev-parse 'HEAD^{tree}')"
  git init --quiet --initial-branch=main "${dst}"
  git -C "${src}" archive --format=tar HEAD | tar -x -C "${dst}"
  git -C "${dst}" add --all
  dst_tree="$(git -C "${dst}" write-tree)"
  [[ "${src_tree}" == "${dst_tree}" ]] || die "exported tree ${dst_tree} differs from source tree ${src_tree}"
  echo "exported tree ${dst_tree} is byte-identical to the source main tree"
  git -C "${dst}" commit --quiet -m "Publish the DevKitCIoT design

The board was designed in 2021 and revamped for KiCad 10. This repository
starts from the finished design, without the private development history."
  sig="$(git -C "${dst}" log -1 --format='%G? %ae')"
  [[ "${sig}" == G\ * || "${sig}" == U\ * ]] || die "the commit is not signed: ${sig}"
  [[ "${sig}" == *"@users.noreply.github.com" ]] || die "the commit identity is not a noreply address: ${sig}"
  echo "commit $(git -C "${dst}" rev-parse --short HEAD) signed, ${sig}"
  git -C "${dst}" remote add origin "https://github.com/${NEW}.git"
  write git -C "${dst}" push origin main
  write git -C "${dst}" push origin main:develop
fi

if has_phase configure; then
  log "configure ${NEW} from the hub payloads"
  write bash "${HUB}/repo-config/configure.sh" apply "${NEW}" "${MODEL}"
  if ((EXECUTE)); then bash "${HUB}/repo-config/configure.sh" check "${NEW}" "${MODEL}"; fi
fi

if has_phase extras; then
  log "topics, workflow permissions, and secrets"
  args=()
  IFS=',' read -r -a topic_list <<<"${TOPICS}"
  for t in "${topic_list[@]}"; do args+=(--add-topic "${t}"); done
  write gh repo edit "${NEW}" "${args[@]}"
  perm="$(python3 -c 'import json,sys;print(json.load(open(sys.argv[1]))["default_workflow_permissions"])' "${WORK}/workflow-permissions.json")"
  approve="$(python3 -c 'import json,sys;print(str(json.load(open(sys.argv[1]))["can_approve_pull_request_reviews"]).lower())' "${WORK}/workflow-permissions.json")"
  write gh api -X PUT "repos/${NEW}/actions/permissions/workflow" -f "default_workflow_permissions=${perm}" -F "can_approve_pull_request_reviews=${approve}"
  if [[ -n "${CODEGEN_APP_CLIENT_ID:-}" && -n "${CODEGEN_APP_PRIVATE_KEY_FILE:-}" ]]; then
    for app in actions dependabot; do
      write gh secret set CODEGEN_APP_CLIENT_ID --repo "${NEW}" --app "${app}" --body "${CODEGEN_APP_CLIENT_ID}"
      if ((EXECUTE)); then
        printf '+ gh secret set CODEGEN_APP_PRIVATE_KEY --repo %s --app %s < (key file)\n' "${NEW}" "${app}"
        gh secret set CODEGEN_APP_PRIVATE_KEY --repo "${NEW}" --app "${app}" <"${CODEGEN_APP_PRIVATE_KEY_FILE}"
      else
        printf 'DRY-RUN: gh secret set CODEGEN_APP_PRIVATE_KEY --repo %s --app %s < (key file)\n' "${NEW}" "${app}"
      fi
    done
  else
    echo "WARNING: CODEGEN_APP_CLIENT_ID or CODEGEN_APP_PRIVATE_KEY_FILE is not set, so the merge-bot secrets were not restored." >&2
  fi
fi

if has_phase release; then
  log "re-create ${RELEASE_TAG} on ${NEW}"
  notes="${WORK}/release-notes.md"
  python3 -c 'import json,sys;print(json.load(open(sys.argv[1]))["body"])' "${WORK}/release.json" >"${notes}"
  printf '\nThe attached archive is the original 2021 JLCPCB order. This repository was republished without its development history, so this tag marks its first commit rather than the 2021 one.\n' >>"${notes}"
  write gh release create "${RELEASE_TAG}" --repo "${NEW}" --target main --prerelease --title "${RELEASE_TAG}" --notes-file "${notes}" "${WORK}"/asset/*
fi

if has_phase verify && ((EXECUTE)); then
  log "verify ${NEW}"
  new_tree="$(gh api "repos/${NEW}/commits/main" --jq .commit.tree.sha)"
  old_tree="$(gh api "repos/${ARCHIVED}/commits/main" --jq .commit.tree.sha)"
  [[ "${new_tree}" == "${old_tree}" ]] || die "new main tree ${new_tree} differs from ${ARCHIVED} main ${old_tree}"
  echo "main tree matches ${ARCHIVED}: ${new_tree}"
  [[ "$(gh api "repos/${NEW}/commits?sha=main" --jq length)" == "1" ]] || die "new main has more than one commit"
  gh api "repos/${NEW}/topics" --jq '.names'
  gh api "repos/${NEW}/actions/permissions/workflow"
  gh api "repos/${NEW}/actions/secrets" --jq '[.secrets[].name]'
  gh api "repos/${NEW}/dependabot/secrets" --jq '[.secrets[].name]'
  gh release view "${RELEASE_TAG}" --repo "${NEW}" --json tagName,isPrerelease,assets --jq '{tagName,isPrerelease,assets:[.assets[]|{name,size}]}'
  bash "${HUB}/repo-config/configure.sh" check "${NEW}" "${MODEL}"
fi

log "manual steps no API call here can do"
cat <<EOF
- GitHub App access: where an App is installed for selected repositories only, add ${NEW} to it
  (Settings > Applications > Configure): the merge-bot (codegen) App, CodeRabbit, and Qodo.
- Copilot code review needs no step: the main ruleset's copilot_code_review rule turns it on.
- Hub registry: the entry keeps its name, so nothing changes until the archive sets status archived.
- Publishing, archiving, and deleting the history repository stay separate steps, each with its own go-ahead:
  gh repo edit ${NEW} --visibility public --accept-visibility-change-consequences
  gh repo archive ${NEW} --yes
  gh repo delete ${ARCHIVED} --yes   # after verify; needs gh auth refresh -s delete_repo
EOF

Activity

  1. added
    chore
    on Nov 8, 2026
  2. ptr727 commented on Nov 9, 2026

    @ptr727
    OwnerAuthor

    Steps 1 and 2 Done, Hub Follow-Up Ready (2026-11-08)

    • Archived: ptr727/DevKitCIoT is public and archived. The maintainer chose to archive after all, so step 3's registry change applies.
    • Deleted: ptr727/DevKitCIoT-history is gone (the API returns 404). The old handoff chain went with it, and the recreate script above is the surviving copy.
    • Releases: before the archive, two releases were added so both README release shields render.
      • 0.3.1, the latest full release from main.
      • 0.3.1-g3066c393ad, a pre-release from develop tagged with NBGV's SemVer2 version, which is what the filter=*-g* pre-release shield matches.
      • v0.2-alpha remains as the 2021 pre-release.
    • App access: the Apps are installed for all repositories, so the manual App step does not apply.

    What remains is step 3, for the hub:

    • Run a fresh audit and commit reports/DevKitCIoT/audit.md.
    • Update docs/eol-lf-rollout.md, docs/pre-commit-hooks-rollout.md, and docs/reusable-workflows.md.
    • Set the registry entry to status: archived.

    The lessons from the run are also recorded on ptr727/EspDinIoT#23 for the EspDinIoT republish.

  3. ptr727 commented on Nov 24, 2026

    @ptr727
    OwnerAuthor

    Released (2026-11-24): PR #4422 merged to develop at cfce192; branch and worktree cleaned up, so this claim holds no files. #3940 stays open for docs/reusable-workflows.md and decision #4421.

    Backlog burndown claim (away run 2026-11-24, round 4, refill group D): branch burndown/devkitciot-archive-rollout-docs, issue #3940, step 3's checklist half for two of its three rollout docs only.

    ptr727/DevKitCIoT is archived on GitHub, and its registry entry already reads status: archived, so step 3's registry change needs no edit. AUDIT.md section 2 says no further conformance work applies to an archived entry, and docs/pre-commit-hooks-rollout.md already says "Archived repos are not tracked."

    Predicted files:

    • docs/pre-commit-hooks-rollout.md, the DevKitCIoT checklist bullet removed.
    • docs/eol-lf-rollout.md, the DevKitCIoT checklist bullet removed.

    Not in this claim: docs/reusable-workflows.md, held by the parked #4377 group, and the fresh audit report, split into decision #4421. So #3940 stays open after this branch merges, and its pull request carries no Closes on promotion: line for it.

    Any other group needing one of these files waits for this branch to merge.

  4. ptr727 commented on Nov 24, 2026

    @ptr727
    OwnerAuthor

    Released (2026-11-24): PR #4425 merged to develop at 178064d; branch and worktree cleaned up, so this claim holds no files (docs/reusable-workflows.md is free).

    Backlog burndown claim (away run 2026-11-24, round 4, refill group F): branch burndown/reuse-checklist-fidelity-docstring, issues #3940 (the docs/reusable-workflows.md half of step 3 only) and #1613 (an item 4 class sibling only).

    Predicted files:

    Not in this claim: #3940's closing audit report, which waits on decision #4421, and #1613 item 9's GOVERNANCE.md surface, held by the parked #1727 group. So both issues stay open after this branch merges, and its pull request carries no Closes on promotion: line.

    Any other group needing one of these files waits for this branch to merge.

  5. ptr727 commented on Nov 25, 2026

    @ptr727
    OwnerAuthor

    Closing on decision #4421 (2026-11-25). Every step of the republish is done:

    The maintainer decided that the closing audit report is not owed, because AUDIT.md section 2 stops at an archived entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    chore

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions