369 lines
15 KiB
YAML
369 lines
15 KiB
YAML
name: Verify Release Candidate
|
|
run-name: >-
|
|
${{ github.event_name == 'schedule' && vars.NANOBOT_DAILY_CANDIDATES_ENABLED != 'true' &&
|
|
'Disabled daily candidate' || format('Candidate {0} {1} from {2}',
|
|
inputs.channel || 'preview', inputs.next_stable || vars.NANOBOT_PREVIEW_BASE, github.sha) }}
|
|
|
|
# Preparation only: no tags, GitHub Releases, PyPI or channel-feed writes.
|
|
# Daily preparation is opt-in and remains disabled until maintainers enable the variable.
|
|
on:
|
|
schedule:
|
|
- cron: '17 0 * * *'
|
|
workflow_dispatch:
|
|
inputs:
|
|
next_stable:
|
|
description: Stable version/base (for example 0.4.0); must not have a stable tag
|
|
required: true
|
|
type: string
|
|
channel:
|
|
description: Preview makes a version-only commit; stable keeps the ref's exact final version
|
|
required: true
|
|
default: preview
|
|
type: choice
|
|
options:
|
|
- preview
|
|
- stable
|
|
retain_installable:
|
|
description: Retain this exact installable candidate and source for 1 day (~400 MB); not publication
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
# A daily tick must not replace a maintainer's pending manual run.
|
|
group: release-candidate-${{ github.event_name }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
plan:
|
|
if: >-
|
|
github.event_name == 'workflow_dispatch' ||
|
|
(github.repository == 'HKUDS/nanobot' && github.ref == 'refs/heads/main' &&
|
|
vars.NANOBOT_DAILY_CANDIDATES_ENABLED == 'true')
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
permissions:
|
|
contents: read
|
|
actions: read
|
|
outputs:
|
|
prepare: ${{ steps.plan.outputs.prepare }}
|
|
base: ${{ steps.plan.outputs.base }}
|
|
channel: ${{ steps.plan.outputs.channel }}
|
|
notes_artifact_id: ${{ steps.notes.outputs.artifact-id }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
- name: Install planning tools
|
|
run: python -m pip install 'pydantic>=2,<3' packaging
|
|
- name: Select an exact candidate and generate draft notes
|
|
id: plan
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
SOURCE_COMMIT: ${{ github.sha }}
|
|
NEXT_STABLE: ${{ inputs.next_stable || vars.NANOBOT_PREVIEW_BASE }}
|
|
CANDIDATE_CHANNEL: ${{ inputs.channel || 'preview' }}
|
|
PREVIEW_SEQUENCE: ${{ github.run_number }}
|
|
run: |
|
|
args=()
|
|
if [ "$GITHUB_EVENT_NAME" = schedule ]; then args+=(--scheduled); fi
|
|
python -m scripts.release_plan --source-commit "$SOURCE_COMMIT" \
|
|
--base "$NEXT_STABLE" --channel "$CANDIDATE_CHANNEL" \
|
|
--sequence "$PREVIEW_SEQUENCE" --output "$RUNNER_TEMP/release-plan" \
|
|
--github-output "$GITHUB_OUTPUT" "${args[@]}"
|
|
- name: Retain draft notes for the same candidate
|
|
id: notes
|
|
if: steps.plan.outputs.prepare == 'true'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: candidate-notes-${{ github.run_number }}-${{ github.run_attempt }}
|
|
path: ${{ runner.temp }}/release-plan
|
|
if-no-files-found: error
|
|
retention-days: 3
|
|
- name: Report unchanged source
|
|
if: steps.plan.outputs.prepare == 'false'
|
|
run: echo 'This source and Preview base already passed candidate acceptance. No new build or publication.' >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
candidate:
|
|
needs: plan
|
|
if: needs.plan.outputs.prepare == 'true'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 45
|
|
outputs:
|
|
candidate_commit: ${{ steps.identity.outputs.candidate_commit }}
|
|
manifest_sha256: ${{ steps.identity.outputs.manifest_sha256 }}
|
|
candidate_artifact_id: ${{ steps.native_input.outputs.artifact-id }}
|
|
prepared_artifact_id: ${{ steps.prepared.outputs.artifact-id }}
|
|
env:
|
|
SOURCE_COMMIT: ${{ github.sha }}
|
|
NEXT_STABLE: ${{ needs.plan.outputs.base }}
|
|
PREVIEW_SEQUENCE: ${{ github.run_number }}
|
|
CANDIDATE_CHANNEL: ${{ needs.plan.outputs.channel }}
|
|
|
|
steps:
|
|
- name: Set candidate directory
|
|
run: echo "CANDIDATE_DIR=$RUNNER_TEMP/candidate" >> "$GITHUB_ENV"
|
|
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- uses: astral-sh/setup-uv@v4
|
|
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: 1.3.13
|
|
|
|
- name: Restore the planned notes by producer ID
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
artifact-ids: ${{ needs.plan.outputs.notes_artifact_id }}
|
|
merge-multiple: true
|
|
path: ${{ runner.temp }}/release-plan
|
|
|
|
- name: Install isolated build and verification tools
|
|
run: |
|
|
uv venv "$RUNNER_TEMP/release-tools"
|
|
uv pip install --python "$RUNNER_TEMP/release-tools/bin/python" -e '.[dev]' build twine
|
|
echo "$RUNNER_TEMP/release-tools/bin" >> "$GITHUB_PATH"
|
|
|
|
- name: Prepare an exact, separate candidate
|
|
run: |
|
|
case "$CANDIDATE_CHANNEL" in
|
|
stable)
|
|
python -m scripts.release_candidate prepare-stable \
|
|
--source-commit "$SOURCE_COMMIT" --version "$NEXT_STABLE" \
|
|
--output "$CANDIDATE_DIR" > "$RUNNER_TEMP/candidate.json"
|
|
;;
|
|
preview)
|
|
python -m scripts.release_candidate prepare \
|
|
--source-commit "$SOURCE_COMMIT" --base "$NEXT_STABLE" \
|
|
--sequence "$PREVIEW_SEQUENCE" --output "$CANDIDATE_DIR" \
|
|
> "$RUNNER_TEMP/candidate.json"
|
|
;;
|
|
*) exit 1 ;;
|
|
esac
|
|
python -c 'import json, os; print("CANDIDATE_VERSION=" + json.load(open(os.environ["RUNNER_TEMP"] + "/candidate.json"))["version"])' >> "$GITHUB_ENV"
|
|
|
|
- name: Verify packaging and selection contracts
|
|
working-directory: ${{ env.CANDIDATE_DIR }}
|
|
run: |
|
|
python -m pytest tests/test_release_candidate.py tests/test_releases.py \
|
|
tests/test_release_install_guide.py tests/test_installed_release_probe.py tests/cli/test_tui_wheels.py \
|
|
tests/cli/test_tui_release_packaging.py -q
|
|
|
|
- name: Check WebUI and build Python distributions
|
|
working-directory: ${{ env.CANDIDATE_DIR }}
|
|
run: |
|
|
cd webui
|
|
bun install --frozen-lockfile
|
|
bun run lint
|
|
bun run test
|
|
cd ..
|
|
uv build --out-dir "$RUNNER_TEMP/python-dist"
|
|
|
|
- name: Check and cross-build the five native targets
|
|
working-directory: ${{ env.CANDIDATE_DIR }}/tui
|
|
run: |
|
|
bun install --frozen-lockfile
|
|
bun run check
|
|
bun run test
|
|
for target in darwin-arm64 darwin-x64 linux-arm64 linux-x64 win32-x64; do
|
|
bun scripts/prepare-target.ts "$target"
|
|
bun run build -- "$target"
|
|
done
|
|
|
|
- name: Ad-hoc sign macOS arm64
|
|
uses: indygreg/apple-code-sign-action@44d0985b7f4363198e80b6fea63ac3e9dd3e9957
|
|
with:
|
|
input_path: ${{ env.CANDIDATE_DIR }}/tui/dist/nanobot-tui-darwin-arm64
|
|
rcodesign_version: 0.29.0
|
|
|
|
- name: Ad-hoc sign macOS x64
|
|
uses: indygreg/apple-code-sign-action@44d0985b7f4363198e80b6fea63ac3e9dd3e9957
|
|
with:
|
|
input_path: ${{ env.CANDIDATE_DIR }}/tui/dist/nanobot-tui-darwin-x64
|
|
rcodesign_version: 0.29.0
|
|
|
|
- name: Package licensed native archives
|
|
working-directory: ${{ env.CANDIDATE_DIR }}/tui
|
|
run: |
|
|
for target in darwin-arm64 darwin-x64 linux-arm64 linux-x64 win32-x64; do
|
|
bun scripts/prepare-target.ts "$target"
|
|
bun scripts/release-notices.ts "$target"
|
|
python scripts/package-release.py "$target"
|
|
done
|
|
|
|
- name: Assemble and verify the complete candidate
|
|
working-directory: ${{ env.CANDIDATE_DIR }}
|
|
run: |
|
|
version="$CANDIDATE_VERSION"
|
|
python -m scripts.release_candidate assemble --source-commit "$SOURCE_COMMIT" \
|
|
--wheel "$RUNNER_TEMP/python-dist/nanobot_ai-${version}-py3-none-any.whl" \
|
|
--sdist "$RUNNER_TEMP/python-dist/nanobot_ai-${version}.tar.gz" \
|
|
--tui-dir tui/dist --output "$RUNNER_TEMP/release-artifacts"
|
|
python -m twine check "$RUNNER_TEMP/release-artifacts/"*.whl \
|
|
"$RUNNER_TEMP/release-artifacts/"*.tar.gz
|
|
|
|
- name: Record exact acceptance identity
|
|
id: identity
|
|
env:
|
|
MANIFEST: ${{ runner.temp }}/release-artifacts/release-manifest.json
|
|
run: |
|
|
python - <<'PY'
|
|
import hashlib, json, os
|
|
from pathlib import Path
|
|
payload = Path(os.environ['MANIFEST']).read_bytes()
|
|
manifest = json.loads(payload)
|
|
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
|
|
output.write(f"candidate_commit={manifest['candidate_commit']}\n")
|
|
output.write(f"manifest_sha256={hashlib.sha256(payload).hexdigest()}\n")
|
|
PY
|
|
|
|
# Temporary same-run inputs, not approved release handoffs. Do not rebuild on consumers.
|
|
- name: Transfer exact native acceptance inputs
|
|
id: native_input
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: candidate-native-wheels-${{ github.run_number }}-${{ github.run_attempt }}
|
|
path: |
|
|
${{ runner.temp }}/release-artifacts/*.whl
|
|
${{ runner.temp }}/release-artifacts/release-manifest.json
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
compression-level: 0
|
|
|
|
- name: Generate the exact candidate installation handoff
|
|
working-directory: ${{ env.CANDIDATE_DIR }}
|
|
run: |
|
|
python -m scripts.release_candidate instructions --source-commit "$SOURCE_COMMIT" \
|
|
--artifacts "$RUNNER_TEMP/release-artifacts" \
|
|
--output "$RUNNER_TEMP/install-candidate.md"
|
|
|
|
# These reports are neither native acceptance nor publication approval.
|
|
- name: Retain candidate identity and structural reports
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: candidate-report-${{ github.run_number }}-${{ github.run_attempt }}
|
|
path: |
|
|
${{ runner.temp }}/candidate.json
|
|
${{ runner.temp }}/release-artifacts/release-manifest.json
|
|
${{ runner.temp }}/install-candidate.md
|
|
${{ runner.temp }}/release-plan/release-notes.md
|
|
if-no-files-found: error
|
|
retention-days: 3
|
|
|
|
# Explicit, short-lived release handoff only. This is the documented
|
|
# exception to report-only preflight. Schedules do not retain installable files.
|
|
- name: Preserve the verified bytes and independent candidate source
|
|
if: ${{ inputs.retain_installable }}
|
|
working-directory: ${{ env.CANDIDATE_DIR }}
|
|
run: |
|
|
python -m scripts.release_candidate retain --source-commit "$SOURCE_COMMIT" \
|
|
--artifacts "$RUNNER_TEMP/release-artifacts" \
|
|
--output "$RUNNER_TEMP/retained-candidate"
|
|
cp "$RUNNER_TEMP/release-plan/release-notes.md" "$RUNNER_TEMP/retained-candidate/release-notes.md"
|
|
|
|
- name: Transfer prepared candidate pending native acceptance
|
|
id: prepared
|
|
if: ${{ inputs.retain_installable }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: prepared-candidate-${{ github.run_number }}-${{ github.run_attempt }}
|
|
path: ${{ runner.temp }}/retained-candidate
|
|
if-no-files-found: error
|
|
compression-level: 0
|
|
retention-days: 1
|
|
|
|
native:
|
|
name: Candidate native acceptance
|
|
needs: candidate
|
|
uses: ./.github/workflows/native-acceptance.yml
|
|
with:
|
|
candidate: true
|
|
candidate_commit: ${{ needs.candidate.outputs.candidate_commit }}
|
|
manifest_sha256: ${{ needs.candidate.outputs.manifest_sha256 }}
|
|
candidate_artifact_id: ${{ needs.candidate.outputs.candidate_artifact_id }}
|
|
platforms: >-
|
|
[{"os":"ubuntu-latest","target":"linux-x64","wheel_tag":"manylinux_2_17_x86_64"},
|
|
{"os":"ubuntu-24.04-arm","target":"linux-arm64","wheel_tag":"manylinux_2_17_aarch64"},
|
|
{"os":"windows-latest","target":"win32-x64","wheel_tag":"win_amd64"},
|
|
{"os":"macos-15","target":"darwin-arm64","wheel_tag":"macosx_13_0_arm64"},
|
|
{"os":"macos-15-intel","target":"darwin-x64","wheel_tag":"macosx_13_0_x86_64"}]
|
|
|
|
verified:
|
|
name: Candidate required
|
|
needs: [plan, candidate, native]
|
|
if: always() && needs.plan.result == 'success' && needs.plan.outputs.prepare == 'true'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
steps:
|
|
- name: Require build and every native acceptance job
|
|
env:
|
|
BUILD_RESULT: ${{ needs.candidate.result }}
|
|
NATIVE_RESULT: ${{ needs.native.result }}
|
|
run: test "$BUILD_RESULT" = success && test "$NATIVE_RESULT" = success
|
|
|
|
- name: Restore the exact retained candidate after acceptance
|
|
if: inputs.retain_installable
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
artifact-ids: ${{ needs.candidate.outputs.prepared_artifact_id }}
|
|
merge-multiple: true
|
|
path: ${{ runner.temp }}/retained-candidate
|
|
|
|
- name: Verify the downloaded handoff before retaining accepted bytes
|
|
if: inputs.retain_installable
|
|
env:
|
|
HANDOFF: ${{ runner.temp }}/retained-candidate
|
|
CANDIDATE_COMMIT: ${{ needs.candidate.outputs.candidate_commit }}
|
|
MANIFEST_SHA256: ${{ needs.candidate.outputs.manifest_sha256 }}
|
|
run: |
|
|
git --git-dir="$HANDOFF/source.git" fsck --full
|
|
test "$(git --git-dir="$HANDOFF/source.git" rev-parse HEAD)" = "$CANDIDATE_COMMIT"
|
|
python - <<'PY'
|
|
import hashlib, json, os
|
|
from pathlib import Path
|
|
|
|
root = Path(os.environ["HANDOFF"])
|
|
manifest = (root / "artifacts/release-manifest.json").read_bytes()
|
|
assert hashlib.sha256(manifest).hexdigest() == os.environ["MANIFEST_SHA256"]
|
|
handoff = json.loads((root / "handoff.json").read_text())
|
|
assert handoff["candidate_commit"] == os.environ["CANDIDATE_COMMIT"]
|
|
assert handoff["manifest_sha256"] == os.environ["MANIFEST_SHA256"]
|
|
for artifact in json.loads(manifest)["artifacts"]:
|
|
payload = (root / "artifacts" / artifact["filename"]).read_bytes()
|
|
assert len(payload) == artifact["size"]
|
|
assert hashlib.sha256(payload).hexdigest() == artifact["sha256"]
|
|
PY
|
|
|
|
- name: Retain accepted installable candidate for separate approval
|
|
if: inputs.retain_installable
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: installable-candidate-${{ github.run_number }}-${{ github.run_attempt }}
|
|
path: ${{ runner.temp }}/retained-candidate
|
|
if-no-files-found: error
|
|
compression-level: 0
|
|
retention-days: 1
|
|
|
|
- name: Record accepted identity
|
|
env:
|
|
CANDIDATE_COMMIT: ${{ needs.candidate.outputs.candidate_commit }}
|
|
MANIFEST_SHA256: ${{ needs.candidate.outputs.manifest_sha256 }}
|
|
run: |
|
|
printf 'Candidate: `%s`\n\nManifest SHA-256: `%s`\n\nAll five native targets passed installation and update/recovery acceptance. Publication requires separate approval.\n' \
|
|
"$CANDIDATE_COMMIT" "$MANIFEST_SHA256" >> "$GITHUB_STEP_SUMMARY"
|