From e9d92e729c005d6c56afad2dfda1a45870a99640 Mon Sep 17 00:00:00 2001 From: dilrukshax Date: Sun, 23 Aug 2026 20:39:26 +0530 Subject: [PATCH] ci: publish only after main validation --- .github/workflows/publish.yml | 23 +++++++++++++++++------ CONTRIBUTING.md | 9 +++++---- docs/releasing.md | 19 ++++++++++++++----- src/cli/tui/App.tsx | 10 ++-------- src/cli/tui/components/ModelDialog.tsx | 24 +++++++----------------- src/config/index.ts | 7 +------ 6 files changed, 46 insertions(+), 46 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9a76fd6..38b2f03 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,7 +1,11 @@ name: Publish package on: - push: + workflow_run: + workflows: + - CI + types: + - completed branches: - main workflow_dispatch: @@ -10,13 +14,17 @@ permissions: contents: read concurrency: - group: publish-${{ github.workflow }}-${{ github.ref }} + group: publish-${{ github.workflow }}-${{ github.event.workflow_run.head_sha || github.ref }} cancel-in-progress: false jobs: publish-main: name: Publish main release to npm - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + if: >- + ${{ github.event_name == 'workflow_run' && + github.event.workflow_run.event == 'push' && + github.event.workflow_run.head_branch == 'main' && + github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest environment: name: npm @@ -28,6 +36,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 + ref: ${{ github.event.workflow_run.head_sha }} - name: Install pnpm uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10 @@ -51,6 +60,8 @@ jobs: - name: Select the release version id: release shell: bash + env: + SOURCE_SHA: ${{ github.event.workflow_run.head_sha }} run: | set -euo pipefail @@ -69,8 +80,8 @@ jobs: candidate_parent="$(git rev-parse "${candidate_commit}^" 2>/dev/null || true)" candidate_subject="$(git log -1 --format=%s "${candidate_commit}")" - if [[ "${candidate_commit}" == "${GITHUB_SHA}" ]] || \ - [[ "${candidate_parent}" == "${GITHUB_SHA}" && \ + if [[ "${candidate_commit}" == "${SOURCE_SHA}" ]] || \ + [[ "${candidate_parent}" == "${SOURCE_SHA}" && \ "${candidate_subject}" == "chore(release): ${candidate_tag} [skip ci]" ]]; then release_tag="${candidate_tag}" release_commit="${candidate_commit}" @@ -98,7 +109,7 @@ jobs: if git show-ref --verify --quiet "refs/tags/${release_tag}"; then tag_commit="$(git rev-list -n 1 "${release_tag}")" - echo "${release_tag} already belongs to ${tag_commit}, not ${GITHUB_SHA}." >&2 + echo "${release_tag} already belongs to ${tag_commit}, not ${SOURCE_SHA}." >&2 exit 1 fi diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 563650b..6ddaf5d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -75,10 +75,11 @@ pnpm test ## Releases -Maintainers should follow the [release guide](docs/releasing.md). Every merge to -`main` automatically selects the next package version, verifies the artifact, -publishes it, and creates the matching tag and GitHub Release. Do not bump normal -beta versions or create GitHub Releases manually. +Maintainers should follow the [release guide](docs/releasing.md). After a merge +to `main` passes the complete main CI matrix, it automatically selects the next +package version, verifies and publishes the artifact, and creates the matching +tag and GitHub Release. Do not bump normal beta versions or create GitHub +Releases manually. ## Licensing diff --git a/docs/releasing.md b/docs/releasing.md index 63e4a6f..38d1b14 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -5,7 +5,7 @@ Parallax uses two release paths in | Branch | Trigger | npm dist-tag | Purpose | | ------------- | ------------------------ | ------------ | --------------------- | -| `main` | Every push or PR merge | `next` | Public beta releases | +| `main` | Successful main CI run | `next` | Public beta releases | | `development` | Manual workflow dispatch | `dev` | Development snapshots | Daily work belongs on `development`. Promote tested work to `main` with a pull @@ -25,8 +25,10 @@ GitHub Actions must be allowed to create the generated release commit. ## Automatic releases from `main` -Every new `main` push must either complete a release or fail visibly. A main run -no longer succeeds by silently skipping an already-published version. +Every new `main` push runs the complete CI matrix first. The publish workflow is +triggered only after that exact main commit passes CI; a failed or cancelled CI +run cannot publish an npm package. Once started, the release must complete or +fail visibly instead of silently skipping an already-published version. The version in `package.json` selects the release line: @@ -71,8 +73,9 @@ git push origin development ``` Open a pull request from `development` to `main`, wait for CI, review it, and -merge it. The resulting main push automatically creates the next npm release. -No manual version-bump commit is needed for a normal beta. +merge it. The merge runs CI again on the exact main commit. Its successful +completion automatically triggers the next npm release. No manual version-bump +commit is needed for a normal beta. Follow the release live: @@ -140,6 +143,12 @@ npx --yes @singularitycolabs/parallax@dev --version ## Failure handling +### Main CI fails + +The publish workflow does not start, so no version, tag, or npm package is +created. Fix the validation failure on `development`, wait for its CI to pass, +and promote the correction to `main`. + ### Verification fails No tag or npm package is created. Fix the source on `development`, promote it to diff --git a/src/cli/tui/App.tsx b/src/cli/tui/App.tsx index b91fe0c..4254ea5 100644 --- a/src/cli/tui/App.tsx +++ b/src/cli/tui/App.tsx @@ -1,11 +1,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { Box, Text, useApp, useInput } from 'ink'; import type { ApprovalDecision, PermissionMode, RuntimeEvent } from '../../protocol/index.ts'; -import { - applyModelSelection, - MissingApiKeyError, - type Agent, -} from '../../app/index.ts'; +import { applyModelSelection, MissingApiKeyError, type Agent } from '../../app/index.ts'; import { getProvider, listProviders, @@ -166,9 +162,7 @@ export function App(props: AppProps): React.ReactElement { if (err instanceof MissingApiKeyError) { // No key on this path — offer the dialog to enter one, preset to the // provider the user asked for. - pushSystem( - `${sel.provider} needs an API key. Opening /model to configure it…`, - ); + pushSystem(`${sel.provider} needs an API key. Opening /model to configure it…`); openDialog(sel.provider); return; } diff --git a/src/cli/tui/components/ModelDialog.tsx b/src/cli/tui/components/ModelDialog.tsx index 7b56d70..aba1177 100644 --- a/src/cli/tui/components/ModelDialog.tsx +++ b/src/cli/tui/components/ModelDialog.tsx @@ -92,9 +92,7 @@ export function ModelDialog({ : undefined; const presetNeedsKey = preset !== undefined && !hasKey(preset.id); - const [step, setStep] = useState( - preset ? (presetNeedsKey ? 'key' : 'model') : 'provider', - ); + const [step, setStep] = useState(preset ? (presetNeedsKey ? 'key' : 'model') : 'provider'); const [filter, setFilter] = useState(''); const [selected, setSelected] = useState(0); const [providerId, setProviderId] = useState(preset?.id ?? ''); @@ -103,7 +101,9 @@ export function ModelDialog({ const [hint, setHint] = useState(''); // The model chosen while we detour through the key step (its default when we // jumped straight to key entry for a preset provider). - const [pendingModel, setPendingModel] = useState(presetNeedsKey ? (preset?.defaultModel ?? '') : ''); + const [pendingModel, setPendingModel] = useState( + presetNeedsKey ? (preset?.defaultModel ?? '') : '', + ); const provider = useMemo( () => providers.find((p) => p.id === providerId), @@ -121,8 +121,7 @@ export function ModelDialog({ }, [provider, filter]); // On an OpenAI-/Anthropic-wire provider any model id is valid on the wire, so a // non-matching filter becomes an explicit "use what I typed" row. - const allowCustomModel = - filter.trim() !== '' && !modelRows.some((m) => m === filter.trim()); + const allowCustomModel = filter.trim() !== '' && !modelRows.some((m) => m === filter.trim()); const resetList = (): void => { setFilter(''); @@ -261,12 +260,7 @@ export function ModelDialog({ {step === 'provider' ? ( - + ) : ( {active ? '❯ ' : ' '} diff --git a/src/config/index.ts b/src/config/index.ts index 62105e5..feecfcf 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -16,12 +16,7 @@ export { credentialsPath, localConfigPaths, } from './paths.ts'; -export { - loadCredentials, - getCredential, - saveCredential, - type Credentials, -} from './credentials.ts'; +export { loadCredentials, getCredential, saveCredential, type Credentials } from './credentials.ts'; export { PROVIDERS, BASE_PROVIDERS,