Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ long form of everything below), `doc/api-surface.md`, `doc/verification.md` (dev
- **Feedback package**: separate (PLAN.md D4), a workspace member, lock-step version, hosted constraint `>=<core> <next minor>` (never exact, never a
path or an override); the core must never mention it; its own Pigeon bridge; native pins are literals compared by
`test/feedback_package_drift_test.dart`; it adds no Android provider; publish only through `scripts/publish_feedback.sh`, core first.
Releases: only `.github/workflows/release.yml` publishes (tag `v<version>`, OIDC, `environment: pub.dev`, after its gate; guarded in `test/native_versions_test.dart`); `workflow_dispatch` there is a dry run (pub.dev refuses non-tag publishing).
- **Device harness** (`scripts/device/`, not in CI): its guards are on by default and must stay so; a new check goes through `Run.guard` / `Run.expect`, a
new parser in `scripts/device/core/` with a test that shows it failing (`test/device_harness_test.dart`). A NOT POSSIBLE scenario exits 2.
- **Docs**: a doc claim about code (a name, default, limit, command, path) is checked against the code; `README.md`, `CHANGELOG.md` (the newest entry is
Expand Down
37 changes: 33 additions & 4 deletions .github/CI.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# CI/CD

Nothing here publishes, tags or deploys. Releases to pub.dev are a separate, human-run
step (PLAN.md, "Release checklist"). All workflows except `claude-review.yml` (owned by the org's shared workflow, which needs
`pull-requests`/`issues` write, `id-token` write and a secret) use `permissions: contents: read`
and checkout with `persist-credentials: false`.
Only `release.yml` publishes (pub.dev, on a pushed version tag; see "Releases" below). Nothing else here publishes, tags or
deploys. All workflows except `claude-review.yml` (owned by the org's shared workflow, which needs
`pull-requests`/`issues` write, `id-token` write and a secret) use top-level `permissions: contents: read`
and checkout with `persist-credentials: false`; the one other permission is `id-token: write` on the two publishing jobs of `release.yml`.

## Workflows

| Workflow | Trigger | What it does |
|---|---|---|
| `ci.yml` | PR, push to `main` | Format, bridge and option codegen, analyze + test + iOS build, Android APK build, `pub publish --dry-run`, and the aggregate `ci-ok` |
| `native-pins.yml` | weekly (Mon 06:17 UTC), manual | Verifies the pins in `native-versions.json` still exist upstream, and that the vendored option manifests are still the SDKs' published ones (`dart scripts/sync_option_manifests.dart --check`). Network checks live only here, never in PR CI |
| `release.yml` | push of a tag `v<version>`, manual (always a dry run) | The release: gate, then publish `bugsee_flutter`, then `bugsee_flutter_feedback`, to pub.dev with OIDC. See "Releases" |
| `claude-review.yml` | PR opened / updated | Calls the shared org review workflow. Advisory; do not require it (needs an org secret, unavailable to fork PRs). Do not edit it here |

### `ci.yml` jobs and check names
Expand Down Expand Up @@ -142,6 +143,34 @@ for its CI (see `bugsee/bugsee-android` `.github/CI.md`); this repo does not, so
neither competes for that slot nor inherits its dirty workspace. Moving the iOS leg there
is possible later, but only after SwiftPM and Xcode availability on it are confirmed.

## Releases

`release.yml` publishes BOTH packages from one tag, in lock-step (the same version in both pubspecs). The tag form is `v<version>`
(`v10.0.0`, `v10.0.0-beta.1`; the form the 9.x tags use). pub.dev needs a tag pattern with `{{version}}`: `v{{version}}` for each package, and the
workflow's `on.push.tags` matches it. Authentication is pub.dev's automated publishing (GitHub OIDC, [dart.dev docs](https://dart.dev/tools/pub/automated-publishing)):
no secret exists. pub.dev accepts it only from a run triggered by a TAG PUSH, so `workflow_dispatch` (input `dryRun`, default true; false is refused
in the first step) runs the `gate` only (it includes the dry runs of both packages and prints what pub.dev has); the publish jobs do not run, so the environment's tag rule never sees a branch.

| Job | Needs | Permissions | What it does |
|---|---|---|---|
| `gate` | | `contents: read`, `checks: read` | The tag's commit is reachable from `origin/main`; `scripts/check_release.sh` (tag == both pubspec versions == both CHANGELOG top entries; the wrapper identity, the feedback lower bound and the pins are compared by the `flutter test` below); a successful `ci-ok` check run exists on the commit (so the iOS and Android builds were green); then on the floor Flutter: format, both Pigeon checks, the option registry check, `flutter analyze` and `flutter test` (root and feedback package), `flutter pub publish --dry-run`, the core archive through `scripts/check_pub_archive.sh`, and `scripts/publish_feedback.sh` (dry run). Holds no token and no environment |
| `publish-core` | `gate`; tag push only | `contents: read`, `id-token: write`; `environment: pub.dev` | `dart-lang/setup-dart` (it exchanges the runner's OIDC token for the pub.dev credential, `PUB_TOKEN`; `subosito/flutter-action` does not), then `flutter pub publish --force` of `bugsee_flutter` (skipped when that version is already live: a re-run is safe) |
| `publish-feedback` | `gate`, `publish-core`; tag push only | the same; same environment | Waits (`scripts/pub_dev_status.sh wait`, 20 minutes) until the core version is live on pub.dev, then `dart-lang/setup-dart` (the credential is short-lived, so it is minted after the wait), then `scripts/publish_feedback.sh --publish --yes`: it refuses a dirty tree and publishes from a copy of the TRACKED files (see its header). Skipped with a warning and a step summary when the package does not exist on pub.dev yet (below); skipped when that version is live |

- **Concurrency.** Tag pushes share the group `release`, never cancelled: a running release finishes first. GitHub keeps one running and ONE pending run per group, so a third tag push replaces the pending one (re-push it). A rehearsal has a group of its own (`release-dry-<run id>`) and cannot displace a release.
- **The checked commit is the published one.** The publish jobs check out `github.sha`, not the tag's current target, so a tag moved after the gate publishes nothing unchecked.
- **First version of the feedback package.** pub.dev can enable automated publishing only for a package that already exists, so the very first version
of `bugsee_flutter_feedback` is published by hand once (PLAN.md, release checklist). Until then `publish-feedback` publishes nothing and says so
(the core is already out by then). After the manual publish and enabling automated publishing, the next tag publishes it.
- **Guards.** `test/native_versions_test.dart` ("workflows"): only `release.yml` publishes; a publishing job is under `environment: pub.dev`,
holds `id-token: write`, needs `gate`, and publishes in a step that runs on a tag push only; `id-token: write` appears nowhere else (mutation
tests show each break failing); the gate repeats `ci.yml`'s format and codegen commands. `test/release_scripts_test.dart` runs both scripts
(the pub.dev one against a local server). `scripts/pub_dev_status.sh` treats anything but 200/404 as an error, never as "not there".
- **Manual fallback.** From a clean checkout of the tag on the floor Flutter: `flutter pub publish` for the core, wait until it is live, then
`scripts/publish_feedback.sh --publish`. Never from an agent.

Maintainer setup (nothing here applies it): see the PR description of the release pipeline and PLAN.md, release checklist step 7.

## Default branch

The rewrite lives on `main`, the default branch (it was `nextgen` until 2026-11-23; that branch is kept as the
Expand Down
221 changes: 221 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
name: release

# The only workflow that publishes. Pushing a tag `v<version>` releases BOTH packages from that
# commit, in lock-step: `bugsee_flutter` first, then (once it is live on pub.dev)
# `bugsee_flutter_feedback`. Authentication is pub.dev's automated publishing (GitHub OIDC): there
# is no secret and no stored credential. pub.dev accepts it only from a run triggered by a tag push,
# so a manual run (`workflow_dispatch`) is always a dry run: it runs the whole gate (which includes
# the dry runs of both packages) and the publish jobs do not run. See .github/CI.md ("Releases") and PLAN.md ("Release checklist").
#
# Safety, in the order a run meets it:
# gate read-only; tag is on main, tag == both pubspecs and both CHANGELOG tops, ci-ok was
# green on the commit, format / codegen / analyze / test / pub dry-run / archive checks
# publish-core needs gate; `environment: pub.dev` (reviewers); the only job with id-token (core)
# publish-feedback needs gate + publish-core; same environment; waits for the core to be live
# test/native_versions_test.dart ("release workflow") fails if any of that is weakened.
on:
push:
tags: ['v[0-9]*.[0-9]*.[0-9]*']
workflow_dispatch:
inputs:
dryRun:
description: 'Dry run (the only mode pub.dev accepts outside a tag push: leave true)'
type: boolean
default: true

permissions:
contents: read

# Two releases never overlap, and a running release is never cancelled half way. GitHub keeps one
# running and ONE pending run per group: a third tag push replaces the pending one (re-push it).
# A manual rehearsal has a group of its own, so it can neither wait behind nor displace a release.
concurrency:
group: ${{ github.event_name == 'push' && 'release' || format('release-dry-{0}', github.run_id) }}
cancel-in-progress: false

jobs:
gate:
name: release gate
runs-on: ubuntu-latest
timeout-minutes: 45
# checks: read, only to ask whether ci-ok passed on this commit.
permissions:
contents: read
checks: read
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: A manual run is a dry run
if: github.event_name == 'workflow_dispatch' && !inputs.dryRun
run: |
echo "::error::pub.dev accepts automated publishing only from a tag push; a manual run is a dry run. Push the tag instead."
exit 1
- uses: actions/checkout@v7
with:
persist-credentials: false
# The whole history: the tag's commit must be shown to be on main.
fetch-depth: 0
- name: The tagged commit is on main
if: github.event_name == 'push'
run: |
if ! git merge-base --is-ancestor "$GITHUB_SHA" refs/remotes/origin/main; then
echo "::error::$GITHUB_REF_NAME ($GITHUB_SHA) is not reachable from main; releases are cut from main only"
exit 1
fi
- name: The tag names the version of both packages
id: version
env:
REF_NAME: ${{ github.ref_name }}
EVENT: ${{ github.event_name }}
run: |
if [ "$EVENT" = push ]; then
tag="$REF_NAME"
else
# Rehearsal: the tag a release of the checked-out version would carry.
tag="v$(sed -n -E 's/^version:[[:space:]]*([^[:space:]#]+).*$/\1/p' pubspec.yaml | head -n 1)"
fi
version="$(scripts/check_release.sh "$tag")"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "release $version (tag $tag)" >> "$GITHUB_STEP_SUMMARY"
- name: ci-ok passed on this commit
if: github.event_name == 'push'
env:
GH_TOKEN: ${{ github.token }}
run: |
ok="$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/check-runs?per_page=100" \
--jq '[.check_runs[] | select(.name == "ci-ok")] | length > 0 and all(.conclusion == "success")')"
if [ "$ok" != true ]; then
echo "::error::no successful ci-ok check run on $GITHUB_SHA: wait for ci to finish on main, or fix it"
exit 1
fi
# The floor, like the checks that depend on formatter output (see ci.yml).
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: '3.50.0'
cache: true
- run: flutter config --enable-swift-package-manager
- run: flutter pub get --enforce-lockfile
- run: dart format --output=none --set-exit-if-changed lib test example/lib example/integration_test scripts pigeons packages
- run: dart scripts/generate_pigeon.dart --check
- run: dart scripts/generate_pigeon.dart --package packages/bugsee_flutter_feedback --check
- run: dart scripts/generate_options.dart --check
- run: flutter analyze
- run: flutter test
- run: cd packages/bugsee_flutter_feedback && flutter analyze
- run: cd packages/bugsee_flutter_feedback && flutter test
- run: flutter pub publish --dry-run
- run: |
flutter pub publish --to-archive="$RUNNER_TEMP/core.tar.gz"
scripts/check_pub_archive.sh "$RUNNER_TEMP/core.tar.gz"
# Dry run of the sibling (and its archive check), from a copy of the tracked files.
- run: scripts/publish_feedback.sh
# Read-only: what the release would do (a rehearsal shows it without publishing).
- name: What pub.dev has now
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
for p in bugsee_flutter bugsee_flutter_feedback; do
echo "$p $VERSION on pub.dev: $(scripts/pub_dev_status.sh status "$p" "$VERSION" || echo unknown)" | tee -a "$GITHUB_STEP_SUMMARY"
done

publish-core:
name: publish bugsee_flutter
needs: [gate]
# A manual run is the gate only: pub.dev refuses it, and the environment's tag rule would too.
if: github.event_name == 'push'
runs-on: ubuntu-latest
timeout-minutes: 20
# The reviewers of this environment approve the release; pub.dev can require it by name.
environment: pub.dev

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Low: the documented rehearsal conflicts with the documented environment restriction

Problem: The checklist says to limit the pub.dev environment's deployment to v* tags, and also to rehearse with workflow_dispatch from the default branch. Both publish jobs declare environment: pub.dev unconditionally, so a dispatch run on main is evaluated against the environment's deployment rules.

Impact: With a tags-only rule, GitHub rejects the dispatch run at the deployment-protection check ("Branch main is not allowed to deploy to pub.dev"), so the rehearsal fails at the publish jobs. If instead the rule is relaxed to allow main, reviewers must approve a dry run, and the "tags only" protection no longer holds for runs from branches.

Fix: Say so explicitly in PLAN.md and CI.md: the rehearsal covers only the gate, or the publish jobs' dry runs need main allowed on the environment. Alternatively, give the publish jobs' dry-run path a separate job without environment and id-token.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the publish jobs are tag-push only (job-level if), so a manual run never reaches the environment; the rehearsal is the gate, which dry-runs both packages. PLAN.md and CI.md say so.

permissions:
contents: read
id-token: write
steps:
# The commit the gate checked, never the tag's current target: a tag moved after the gate
# must not publish unchecked code.
- uses: actions/checkout@v7
with:
persist-credentials: false
ref: ${{ github.sha }}
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: '3.50.0'
cache: true
- run: flutter config --enable-swift-package-manager
- run: flutter pub get --enforce-lockfile
- name: Is this version already live?
id: live
env:
VERSION: ${{ needs.gate.outputs.version }}
# Assigned first: inside `echo "$(...)"` a failing call would be lost and the state left empty.
run: |
state="$(scripts/pub_dev_status.sh status bugsee_flutter "$VERSION")"
echo "state=$state" >> "$GITHUB_OUTPUT"
# Exchanges the runner's OIDC token for the pub.dev credential (PUB_TOKEN); the Flutter action
# does not. Right before the upload: the token is short-lived.
- uses: dart-lang/setup-dart@v1
if: github.event_name == 'push' && steps.live.outputs.state != 'live'
with:
sdk: '3.14.0' # what Flutter 3.50.0 bundles; native-versions.json flutter.dart
- name: Publish bugsee_flutter
if: github.event_name == 'push' && steps.live.outputs.state != 'live'
run: flutter pub publish --force
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
- name: Already live, nothing to do
if: steps.live.outputs.state == 'live'
run: echo "::notice::bugsee_flutter ${{ needs.gate.outputs.version }} is already on pub.dev; not published again"

publish-feedback:
name: publish bugsee_flutter_feedback
needs: [gate, publish-core]
if: github.event_name == 'push'
runs-on: ubuntu-latest
timeout-minutes: 45
environment: pub.dev
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
ref: ${{ github.sha }}
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: '3.50.0'
cache: true
- run: flutter config --enable-swift-package-manager
# The feedback package depends on the core at this version: it must resolve from pub.dev
# (indexing can lag the upload by a minute or two).
- name: Wait until the core is live
env:
VERSION: ${{ needs.gate.outputs.version }}
run: scripts/pub_dev_status.sh wait bugsee_flutter "$VERSION" 1200 15
- name: Is this version already live?
id: live
env:
VERSION: ${{ needs.gate.outputs.version }}
run: |
state="$(scripts/pub_dev_status.sh status bugsee_flutter_feedback "$VERSION")"
echo "state=$state" >> "$GITHUB_OUTPUT"
# pub.dev: automated publishing exists only for a package that already exists, so the very
# first version of the sibling is published by hand once (PLAN.md, release checklist).
- name: The package does not exist on pub.dev yet
if: steps.live.outputs.state == 'missing-package'
run: |
msg="bugsee_flutter_feedback is not on pub.dev yet: automated publishing needs an existing package. Publish the first version by hand (PLAN.md, release checklist), then enable automated publishing for it. SKIPPED."
echo "::warning::$msg"
echo "$msg" >> "$GITHUB_STEP_SUMMARY"
# The pub.dev credential, minted after the wait above (it is short-lived).
- uses: dart-lang/setup-dart@v1
if: github.event_name == 'push' && steps.live.outputs.state == 'missing-version'
with:
sdk: '3.14.0'
- name: Publish bugsee_flutter_feedback
if: github.event_name == 'push' && steps.live.outputs.state == 'missing-version'
run: scripts/publish_feedback.sh --publish --yes
- name: Already live, nothing to do
if: steps.live.outputs.state == 'live'
run: echo "::notice::bugsee_flutter_feedback ${{ needs.gate.outputs.version }} is already on pub.dev; not published again"
Loading
Loading