diff --git a/.github/prompts/release-notes.prompt.yml b/.github/prompts/release-notes.prompt.yml index d4928cd3..a059273c 100644 --- a/.github/prompts/release-notes.prompt.yml +++ b/.github/prompts/release-notes.prompt.yml @@ -1,7 +1,7 @@ messages: - role: system content: |- - You are an expert technical writer tasked with generating comprehensive release notes for Donut Browser, a powerful anti-detect browser desktop app built with Tauri + Next.js that helps users manage multiple browser profiles with proxy support. + You are an expert technical writer tasked with generating comprehensive release notes for Donut Browser, a powerful anti-detect browser desktop app that helps users manage multiple browser profiles with proxy support. Guidelines: - Use clear, user-friendly language diff --git a/.github/prompts/telegram-release-summary.prompt.yml b/.github/prompts/telegram-release-summary.prompt.yml index 8567f51d..ab420ad4 100644 --- a/.github/prompts/telegram-release-summary.prompt.yml +++ b/.github/prompts/telegram-release-summary.prompt.yml @@ -1,7 +1,7 @@ messages: - role: system content: |- - You write short, friendly release summaries for Donut Browser, an anti-detect browser desktop app built with Tauri and Next.js. + You write short, friendly release summaries for Donut Browser, an anti-detect browser desktop app. Rules: - Keep it minimal and friendly. No marketing voice, no filler, no superlatives. diff --git a/.github/scripts/release-checksums.sh b/.github/scripts/release-checksums.sh index 28d32e5a..85db1e0c 100755 --- a/.github/scripts/release-checksums.sh +++ b/.github/scripts/release-checksums.sh @@ -4,7 +4,9 @@ # against this file, so release.yml runs it as soon as the builds are up, and # again once the Flatpak and the Snap are attached. # -# bash .github/scripts/release-checksums.sh TAG +# bash .github/scripts/release-checksums.sh TAG [COPY_TO] +# +# COPY_TO gets a copy of the file, for the attestation step. # # Needs GH_TOKEN and GITHUB_REPOSITORY. set -euo pipefail @@ -18,3 +20,6 @@ cd "$assets_dir" sha256sum Donut* > SHA256SUMS.txt cat SHA256SUMS.txt gh release upload "$tag" SHA256SUMS.txt --clobber --repo "$GITHUB_REPOSITORY" +if [ -n "${2:-}" ]; then + cp SHA256SUMS.txt "$2" +fi diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7ee5f735..94464f3d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,9 +1,9 @@ name: "CodeQL" +# Pushes to main reach this through rolling-release.yml and tags through +# release.yml. A push trigger of its own analyzed each push to main twice. on: workflow_call: {} - push: - branches: ["main"] pull_request: branches: ["main"] paths-ignore: @@ -21,7 +21,7 @@ concurrency: # A called workflow sees its caller's `github.workflow`, so the literal # prefix keeps this group apart from the caller's own. group: codeql-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main') }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: analyze: diff --git a/.github/workflows/docker-sync.yml b/.github/workflows/docker-sync.yml index b9f3c683..df9e9c9c 100644 --- a/.github/workflows/docker-sync.yml +++ b/.github/workflows/docker-sync.yml @@ -26,6 +26,11 @@ on: permissions: contents: read +# Two pushes of the same tag never race for `latest` or `nightly`. +concurrency: + group: docker-sync-${{ inputs.tag || github.ref }} + cancel-in-progress: false + env: REGISTRY: docker.io IMAGE_NAME: donutbrowser/donut-sync @@ -91,6 +96,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 + with: + persist-credentials: false - name: Set up Docker Buildx uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 #v4.4.1 diff --git a/.github/workflows/i18n-review.yml b/.github/workflows/i18n-review.yml index 869b773a..e9f8de1d 100644 --- a/.github/workflows/i18n-review.yml +++ b/.github/workflows/i18n-review.yml @@ -66,13 +66,10 @@ jobs: persist-credentials: false sparse-checkout: .github - # RUNNER_TEMP belongs to this job alone; a fixed /tmp path does not. - - name: Use a private work directory - run: echo "I18N_REVIEW_DIR=$RUNNER_TEMP/i18n-review" >> "$GITHUB_ENV" - - name: Collect changed strings id: collect env: + I18N_REVIEW_DIR: ${{ runner.temp }}/i18n-review GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} EVENT_NAME: ${{ github.event_name }} BEFORE_SHA: ${{ github.event.before }} @@ -89,12 +86,14 @@ jobs: continue-on-error: true timeout-minutes: 10 env: + I18N_REVIEW_DIR: ${{ runner.temp }}/i18n-review AI_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} run: node .github/scripts/i18n-review.mjs review - name: Report if: always() && steps.collect.outcome == 'success' env: + I18N_REVIEW_DIR: ${{ runner.temp }}/i18n-review GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} EVENT_NAME: ${{ github.event_name }} PR_NUMBER: ${{ github.event.pull_request.number }} @@ -102,6 +101,8 @@ jobs: - name: Warn about strings the model did not review if: always() + env: + I18N_REVIEW_DIR: ${{ runner.temp }}/i18n-review run: | if [ -f "$I18N_REVIEW_DIR/ai-degraded" ]; then while IFS= read -r line; do diff --git a/.github/workflows/lint-js.yml b/.github/workflows/lint-js.yml index 55e0d23f..87685523 100644 --- a/.github/workflows/lint-js.yml +++ b/.github/workflows/lint-js.yml @@ -2,24 +2,15 @@ name: Lint Node.js -# Pull requests reach this through pr-checks.yml and tags through release.yml. -# Both used to trigger it directly as well, so it ran twice for each of them. +# Called only: pr-checks.yml runs it for pull requests and merge groups, +# rolling-release.yml for pushes to main and release.yml for tags. A push +# trigger of its own ran every job a second time for each push to main. on: workflow_call: {} - push: - branches: - - main permissions: contents: read -concurrency: - # A called workflow sees its caller's `github.workflow`, so the literal - # prefix keeps this group apart from the caller's own. Only the standalone - # push to main cancels a superseded run; Rolling Release runs one at a time. - group: lint-js-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - jobs: build: # biome and tsrs do not depend on the host. Linux starts faster than macOS diff --git a/.github/workflows/lint-rs.yml b/.github/workflows/lint-rs.yml index 0d2f9a99..1fd5230d 100644 --- a/.github/workflows/lint-rs.yml +++ b/.github/workflows/lint-rs.yml @@ -2,24 +2,15 @@ name: Lint Rust -# Pull requests reach this through pr-checks.yml and tags through release.yml. -# Both used to trigger it directly as well, so it ran twice for each of them. +# Called only: pr-checks.yml runs it for pull requests and merge groups, +# rolling-release.yml for pushes to main and release.yml for tags. A push +# trigger of its own ran every job a second time for each push to main. on: workflow_call: {} - push: - branches: - - main permissions: contents: read -concurrency: - # A called workflow sees its caller's `github.workflow`, so the literal - # prefix keeps this group apart from the caller's own. Only the standalone - # push to main cancels a superseded run; Rolling Release runs one at a time. - group: lint-rs-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - env: CARGO_TERM_COLOR: always # Clippy and the tests never need debug info. Without it the target diff --git a/.github/workflows/lint-workflows.yml b/.github/workflows/lint-workflows.yml new file mode 100644 index 00000000..36a23c1c --- /dev/null +++ b/.github/workflows/lint-workflows.yml @@ -0,0 +1,65 @@ +name: Lint Workflows + +# Checks the CI itself: workflow syntax and embedded shell (actionlint), +# workflow security (zizmor, configured in .github/zizmor.yml), the shell +# scripts workflows call, and the tests next to the workflow scripts. +on: + workflow_call: {} + push: + branches: ["main"] + paths: + - ".github/workflows/**" + - ".github/scripts/**" + - ".github/zizmor.yml" + - "scripts/redact-sensitive-text.mjs" + +permissions: + contents: read + +concurrency: + group: lint-workflows-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + lint: + name: Workflows and their scripts + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout repository code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 + with: + persist-credentials: false + + - name: Run actionlint + uses: raven-actions/actionlint@3d39aea434753780c3b3d4a1a31c854b4dbf49d7 #v2.2.0 + with: + version: 1.7.12 + + - name: Run shellcheck on workflow scripts + run: shellcheck -S warning .github/scripts/*.sh scripts/*.sh + + # Fails on findings of high severity. Lower ones show in the log. + - name: Run zizmor + uses: zizmorcore/zizmor-action@45d7276c9ca790aabd705e31ca99c6185c3e76dd #v0.8.1 + with: + advanced-security: false + annotations: true + min-severity: high + + - name: Set up Node.js + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 #v7.1.0 + with: + node-version-file: .node-version + package-manager-cache: false + + # The scripts use only the standard library, so nothing is installed. + - name: Test workflow scripts + run: | + shopt -s globstar nullglob + tests=(.github/scripts/**/*.test.mjs) + if [ "${#tests[@]}" -eq 0 ]; then + echo "No tests under .github/scripts" + exit 0 + fi + node --test "${tests[@]}" diff --git a/.github/workflows/linux-packages.yml b/.github/workflows/linux-packages.yml index cb666e2a..52951910 100644 --- a/.github/workflows/linux-packages.yml +++ b/.github/workflows/linux-packages.yml @@ -60,6 +60,8 @@ jobs: timeout-minutes: 90 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 + with: + persist-credentials: false - name: Setup pnpm uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 #v6.1.1 @@ -96,8 +98,6 @@ jobs: # beforeBuildCommand builds the donut-proxy sidecar, downloads the # verified Xray-core sidecar and builds the frontend. - name: Build the .deb - env: - NEXT_PUBLIC_TURNSTILE: ${{ secrets.NEXT_PUBLIC_TURNSTILE }} run: | BUILD_TAG="nightly-$(git show -s --format=%cs HEAD)-${GITHUB_SHA::7}" export BUILD_TAG @@ -154,6 +154,8 @@ jobs: options: --privileged steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 + with: + persist-credentials: false - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 #v8.0.2 with: @@ -212,6 +214,8 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 + with: + persist-credentials: false - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 #v8.0.2 with: @@ -288,6 +292,8 @@ jobs: timeout-minutes: 60 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 + with: + persist-credentials: false - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 #v8.0.2 with: @@ -297,8 +303,16 @@ jobs: - name: Put the .deb where snapcraft.yaml expects it run: mv linux-deb/*.deb packaging/donut.deb + # The Snap Store times out now and then; one such timeout failed a + # whole nightly run. - name: Install Snapcraft - run: sudo snap install snapcraft --classic + run: | + for attempt in 1 2 3 4; do + sudo snap install snapcraft --classic && exit 0 + echo "::warning::snap install failed (attempt $attempt)" + sleep $((attempt * 20)) + done + exit 1 # The runner is Ubuntu 24.04, the same system as the core24 base, so # the snap is built on the host rather than in an LXD instance. @@ -335,7 +349,12 @@ jobs: - name: Install the snap run: | - sudo snap install gnome-46-2404 mesa-2404 gtk-common-themes + for attempt in 1 2 3 4; do + sudo snap install gnome-46-2404 mesa-2404 gtk-common-themes && break + echo "::warning::snap install failed (attempt $attempt)" + [ "$attempt" -lt 4 ] || exit 1 + sleep $((attempt * 20)) + done sudo snap install --dangerous "$SNAP_FILE" snap connections donutbrowser diff --git a/.github/workflows/pr-ai-policy.yml b/.github/workflows/pr-ai-policy.yml index 9476e0b2..a5332ca9 100644 --- a/.github/workflows/pr-ai-policy.yml +++ b/.github/workflows/pr-ai-policy.yml @@ -17,9 +17,7 @@ concurrency: jobs: check-ai-policy: # Nobody is exempt: maintainers are checked like everyone else. The one - # exception is bot-authored pull requests (Dependabot). They never use the - # template, and closing them would silently stop dependency updates and - # break dependabot-automerge.yml. + # exception is bot-authored pull requests. They never use the template. if: >- github.repository == 'donutbrowser/donutbrowser' && github.event.pull_request.state == 'open' && diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 7bc3eef1..bf1bde06 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -25,6 +25,8 @@ jobs: js: ${{ steps.filter.outputs.js }} rust: ${{ steps.filter.outputs.rust }} deps: ${{ steps.filter.outputs.deps }} + ci: ${{ steps.filter.outputs.ci }} + sdk: ${{ steps.filter.outputs.sdk }} steps: - name: Checkout repository code if: github.event_name == 'pull_request' @@ -44,6 +46,8 @@ jobs: echo "js=true" echo "rust=true" echo "deps=true" + echo "ci=true" + echo "sdk=true" } >> "$GITHUB_OUTPUT" exit 0 } @@ -51,25 +55,38 @@ jobs: git diff --name-only HEAD^1 HEAD > /tmp/changed.txt || all [ -s /tmp/changed.txt ] || all - js=false; rust=false; deps=false + js=false; rust=false; deps=false; ci=false; sdk=false while IFS= read -r file; do case "$file" in # Text and tooling the lint and test jobs never read. *.md|LICENSE|.github/ISSUE_TEMPLATE/*|\ - .github/prompts/*|.github/dependabot.yml|.github/codeql/*|.github/actionlint.yaml|\ - .github/scripts/*|.github/actions/*|_typos.toml|assets/*|flake.nix|flake.lock|\ - packaging/*|snap/*|sdk/*|.vscode/*|.envrc|osv-scanner.toml) + .github/prompts/*|.github/codeql/*|.github/actions/*|_typos.toml|assets/*|\ + flake.nix|flake.lock|packaging/*|snap/*|.vscode/*|.envrc|osv-scanner.toml) ;; - # Workflows that are not part of this check. + sdk/*) + sdk=true ;; + .github/scripts/*|.github/zizmor.yml) + ci=true ;; + # Every workflow is linted. Only the ones this check calls also + # run the suites. .github/workflows/*) + ci=true case "$file" in .github/workflows/pr-checks.yml|.github/workflows/lint-js.yml|.github/workflows/lint-rs.yml) js=true; rust=true ;; + .github/workflows/test-sdk.yml) + sdk=true ;; esac ;; + # Templates and other repository settings no job reads. + .github/*) + ;; # Rust only. The .mjs helpers under src-tauri are linted by biome. src-tauri/*.mjs) js=true; rust=true ;; + # Workflows run this script on issue and pull request text. + scripts/redact-sensitive-text.mjs) + js=true; rust=true; ci=true ;; src-tauri/*|donut-sync/*) rust=true ;; *) @@ -86,8 +103,10 @@ jobs: echo "js=$js" echo "rust=$rust" echo "deps=$deps" + echo "ci=$ci" + echo "sdk=$sdk" } >> "$GITHUB_OUTPUT" - echo "Changed files: $(wc -l < /tmp/changed.txt); js=$js rust=$rust deps=$deps" + echo "Changed files: $(wc -l < /tmp/changed.txt); js=$js rust=$rust deps=$deps ci=$ci sdk=$sdk" lint-js: name: Lint JavaScript/TypeScript @@ -105,6 +124,22 @@ jobs: permissions: contents: read + lint-workflows: + name: Lint Workflows + needs: changes + if: needs.changes.outputs.ci == 'true' + uses: ./.github/workflows/lint-workflows.yml + permissions: + contents: read + + test-sdk: + name: Test SDKs + needs: changes + if: needs.changes.outputs.sdk == 'true' + uses: ./.github/workflows/test-sdk.yml + permissions: + contents: read + # Reports only vulnerabilities a pull request introduces, so it has nothing # to say unless a manifest or lockfile changed. osv.yml no longer runs this # scan a second time for the same pull request. @@ -130,31 +165,31 @@ jobs: # and a desktop session, which CI could not supply reliably. They are run # locally instead; see the E2E section of AGENTS.md. + # The one check to require in branch protection: it is green only when + # every suite the change can affect passed. pr-status: name: PR Status Check runs-on: ubuntu-latest timeout-minutes: 5 - needs: [changes, lint-js, lint-rust, security-scan] + needs: [changes, lint-js, lint-rust, lint-workflows, test-sdk, security-scan] if: always() steps: - name: Check all jobs succeeded env: - CHANGES: ${{ needs.changes.result }} - LINT_JS: ${{ needs.lint-js.result }} - LINT_RUST: ${{ needs.lint-rust.result }} - SECURITY_SCAN: ${{ needs.security-scan.result }} + NEEDS: ${{ toJSON(needs) }} run: | # `skipped` means the pull request cannot affect that suite. - failed=0 - [ "$CHANGES" = "success" ] || { echo "Change detection: $CHANGES"; failed=1; } - for pair in "lint-js=$LINT_JS" "lint-rust=$LINT_RUST" "security-scan=$SECURITY_SCAN"; do - case "${pair#*=}" in - success|skipped) echo "${pair%%=*}: ${pair#*=}" ;; - *) echo "${pair%%=*}: ${pair#*=}"; failed=1 ;; - esac - done - if [ "$failed" -ne 0 ]; then - echo "One or more checks failed" + { + echo "| Check | Result |" + echo "| --- | --- |" + jq -r 'to_entries[] | "| \(.key) | \(.value.result) |"' <<< "$NEEDS" + } >> "$GITHUB_STEP_SUMMARY" + failed=$(jq -r ' + to_entries[] + | select(.value.result != "success" and (.key == "changes" or .value.result != "skipped")) + | "\(.key): \(.value.result)"' <<< "$NEEDS") + if [ -n "$failed" ]; then + echo "::error::Checks that did not pass: $(tr '\n' ' ' <<< "$failed")" exit 1 fi - echo "All checks passed!" + echo "All checks passed" diff --git a/.github/workflows/publish-repos.yml b/.github/workflows/publish-repos.yml index 6c3fdc68..988b2912 100644 --- a/.github/workflows/publish-repos.yml +++ b/.github/workflows/publish-repos.yml @@ -26,6 +26,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 + with: + persist-credentials: false - name: Determine release tag id: tag diff --git a/.github/workflows/publish-sidecars.yml b/.github/workflows/publish-sidecars.yml index d33db750..5903b566 100644 --- a/.github/workflows/publish-sidecars.yml +++ b/.github/workflows/publish-sidecars.yml @@ -93,9 +93,10 @@ jobs: xray_artifact: xray-x86_64-unknown-linux-gnu steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 with: ref: ${{ inputs.ref || github.ref }} + persist-credentials: false # build.rs derives BUILD_VERSION from git; a shallow clone with no tags # makes every published binary report `nightly-` instead of a # version, which is what an operator reads to tell builds apart. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e4941431..ea266ae9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,15 +5,16 @@ on: tags: - "v*" +# A tag is released once. A second push of the same tag waits for the first. +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false + +# Each job names what it needs above this. permissions: - contents: write - security-events: write - packages: read - actions: read + contents: read env: - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} STABLE_RELEASE: "true" jobs: @@ -97,6 +98,8 @@ jobs: pkg_target: "latest-win-x64" runs-on: ${{ matrix.platform }} + # Builds take 38 to 65 minutes; this only stops a hung runner. + timeout-minutes: 180 env: # linuxdeploy's AppImage plugin embeds this, so AppImageUpdate and # similar tools update the AppImage from the latest release, and writes @@ -104,6 +107,8 @@ jobs: LDAI_UPDATE_INFORMATION: ${{ matrix.appimage_arch && format('gh-releases-zsync|{0}|{1}|latest|Donut_*_{2}.AppImage.zsync', github.repository_owner, github.event.repository.name, matrix.appimage_arch) || '' }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 + with: + persist-credentials: false - name: Setup pnpm uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 #v6.1.1 @@ -114,7 +119,8 @@ jobs: uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 #v7.1.0 with: node-version-file: .node-version - cache: "pnpm" + # A release takes nothing from a cache that another run can write. + package-manager-cache: false - name: Setup Rust uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 #master @@ -128,19 +134,10 @@ jobs: sudo apt-get update sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev libxdo-dev pkg-config unzip xdg-utils - - name: Rust cache - uses: swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 #v2.9.3 - with: - workdir: ./src-tauri - - name: Install frontend dependencies run: pnpm install --frozen-lockfile - name: Build frontend - # NEXT_PUBLIC_* vars are inlined at build time and must be forwarded - # from secrets explicitly — they are NOT inherited from the job env. - env: - NEXT_PUBLIC_TURNSTILE: ${{ secrets.NEXT_PUBLIC_TURNSTILE }} run: pnpm build - name: Verify frontend dist exists @@ -191,24 +188,24 @@ jobs: KEYCHAIN_PASSWORD=$(openssl rand -base64 32) P12_PASSWORD=$(openssl rand -base64 32) - echo "$APPLE_CERTIFICATE" | base64 --decode > $CERT_PATH - echo "$APPLE_CERTIFICATE_KEY" | base64 --decode > $KEY_PATH + echo "$APPLE_CERTIFICATE" | base64 --decode > "$CERT_PATH" + echo "$APPLE_CERTIFICATE_KEY" | base64 --decode > "$KEY_PATH" - openssl x509 -inform DER -in $CERT_PATH -out $PEM_PATH - openssl pkcs12 -export -out $P12_PATH -inkey $KEY_PATH -in $PEM_PATH -passout pass:$P12_PASSWORD + openssl x509 -inform DER -in "$CERT_PATH" -out "$PEM_PATH" + openssl pkcs12 -export -out "$P12_PATH" -inkey "$KEY_PATH" -in "$PEM_PATH" -passout "pass:$P12_PASSWORD" - security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH - security set-keychain-settings -lut 21600 $KEYCHAIN_PATH - security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" + security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH" + security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" - security import $P12_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH - security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH - security list-keychain -d user -s $KEYCHAIN_PATH login.keychain-db + security import "$P12_PATH" -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH" + security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" + security list-keychain -d user -s "$KEYCHAIN_PATH" login.keychain-db echo "Available signing identities:" - security find-identity -v -p codesigning $KEYCHAIN_PATH + security find-identity -v -p codesigning "$KEYCHAIN_PATH" - rm -f $CERT_PATH $KEY_PATH $PEM_PATH $P12_PATH + rm -f "$CERT_PATH" "$KEY_PATH" "$PEM_PATH" "$P12_PATH" - name: Set up Python for the DMG layout if: matrix.platform == 'macos-latest' @@ -228,12 +225,10 @@ jobs: APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} TARGET: ${{ matrix.target }} - # tauri-action invokes `pnpm tauri build`, which runs - # `beforeBuildCommand` from tauri.conf.json. That rebuilds the - # frontend in its own subprocess, so the env var MUST be forwarded - # here or the inner `next build` inlines an empty string and - # overwrites the dist the explicit "Build frontend" step produced. - NEXT_PUBLIC_TURNSTILE: ${{ secrets.NEXT_PUBLIC_TURNSTILE }} + # Signs the updater artifacts. Kept on this step so that install + # scripts and the other steps never see the key. + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} with: projectPath: ./src-tauri tagName: ${{ github.ref_name }} @@ -340,8 +335,8 @@ jobs: - name: Clean up Apple certificate if: matrix.platform == 'macos-latest' && always() run: | - security delete-keychain $RUNNER_TEMP/app-signing.keychain-db || true - rm -f $RUNNER_TEMP/build_certificate.p12 || true + security delete-keychain "$RUNNER_TEMP/app-signing.keychain-db" || true + rm -f "$RUNNER_TEMP/build_certificate.p12" || true # The Flatpak and the Snap, repackaged from this release's .deb and attached # to it; checksums-with-packages then adds them to SHA256SUMS.txt. @@ -362,14 +357,18 @@ jobs: if: github.repository == 'donutbrowser/donutbrowser' needs: [release] runs-on: ubuntu-latest + timeout-minutes: 30 permissions: contents: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 + with: + persist-credentials: false - name: Generate and upload SHA256SUMS.txt env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: bash .github/scripts/release-checksums.sh "${{ github.ref_name }}" + TAG: ${{ github.ref_name }} + run: bash .github/scripts/release-checksums.sh "$TAG" # The same sums again, now with whatever Linux packages were attached. A # failed Flatpak or Snap never holds them back. @@ -377,19 +376,34 @@ jobs: if: ${{ !cancelled() && github.repository == 'donutbrowser/donutbrowser' && needs.checksums.result == 'success' }} needs: [checksums, linux-packages] runs-on: ubuntu-latest + timeout-minutes: 30 permissions: contents: write + id-token: write + attestations: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 + with: + persist-credentials: false - name: Generate and upload SHA256SUMS.txt env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: bash .github/scripts/release-checksums.sh "${{ github.ref_name }}" + TAG: ${{ github.ref_name }} + run: bash .github/scripts/release-checksums.sh "$TAG" "$RUNNER_TEMP/SHA256SUMS.txt" + + # Signed build provenance for every asset in the sums file. Check one with + # `gh attestation verify --repo donutbrowser/donutbrowser`. It runs + # after the upload, so a failure here never holds back the sums. + - name: Attest the release assets + uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 #v4.2.2 + with: + subject-checksums: ${{ runner.temp }}/SHA256SUMS.txt changelog: if: github.repository == 'donutbrowser/donutbrowser' needs: [release] runs-on: ubuntu-latest + timeout-minutes: 15 permissions: contents: write pull-requests: write @@ -484,30 +498,28 @@ jobs: run: | VERSION="${TAG#v}" BASE="https://github.com/donutbrowser/donutbrowser/releases/download/${TAG}" + BADGE="https://img.shields.io/badge" # Generate the new install section between markers cat > /tmp/install-links.md << LINKS - ### macOS +

+ Download Donut Browser ${VERSION} for macOS (Apple Silicon, DMG) + Download Donut Browser ${VERSION} for Windows (x64 installer) + Download Donut Browser ${VERSION} for Linux (x64, deb) +

- [Download DMG (Apple Silicon)](${BASE}/Donut_${VERSION}_aarch64.dmg) + | OS | Package | x64 | ARM64 | + |---|---|---|---| + | macOS | DMG | | [Apple Silicon](${BASE}/Donut_${VERSION}_aarch64.dmg) | + | Windows | Installer | [setup.exe](${BASE}/Donut_${VERSION}_x64-setup.exe) | | + | Windows | Portable | [zip](${BASE}/Donut_${VERSION}_x64-portable.zip) | | + | Linux | deb | [amd64](${BASE}/Donut_${VERSION}_amd64.deb) | [arm64](${BASE}/Donut_${VERSION}_arm64.deb) | + | Linux | rpm | [x86_64](${BASE}/Donut-${VERSION}-1.x86_64.rpm) | [aarch64](${BASE}/Donut-${VERSION}-1.aarch64.rpm) | + | Linux | AppImage | [amd64](${BASE}/Donut_${VERSION}_amd64.AppImage) | [aarch64](${BASE}/Donut_${VERSION}_aarch64.AppImage) | + | Linux | Flatpak | [x86_64](${BASE}/Donut_${VERSION}_x86_64.flatpak) | | + | Linux | Snap | [amd64](${BASE}/Donut_${VERSION}_amd64.snap) | | - Or install via Homebrew: - - \`\`\`bash - brew install --cask donut - \`\`\` - - ### Windows - - [Download Windows Installer (x64)](${BASE}/Donut_${VERSION}_x64-setup.exe) · [Portable (x64)](${BASE}/Donut_${VERSION}_x64-portable.zip) - - ### Linux - - | Format | x86_64 | ARM64 | - |---|---|---| - | **deb** | [Download](${BASE}/Donut_${VERSION}_amd64.deb) | [Download](${BASE}/Donut_${VERSION}_arm64.deb) | - | **rpm** | [Download](${BASE}/Donut-${VERSION}-1.x86_64.rpm) | [Download](${BASE}/Donut-${VERSION}-1.aarch64.rpm) | - | **AppImage** | [Download](${BASE}/Donut_${VERSION}_amd64.AppImage) | [Download](${BASE}/Donut_${VERSION}_aarch64.AppImage) | + Version ${VERSION}. Verify a download with [SHA256SUMS.txt](${BASE}/SHA256SUMS.txt). LINKS # Strip leading whitespace from heredoc @@ -557,11 +569,13 @@ jobs: if: github.repository == 'donutbrowser/donutbrowser' needs: [release, changelog] runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 with: ref: main fetch-depth: 0 + persist-credentials: false - name: Generate changelog summary env: @@ -606,6 +620,7 @@ jobs: run: | VERSION="${TAG}" RELEASE_URL="https://github.com/${GITHUB_REPOSITORY}/releases/tag/${VERSION}" + DL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${VERSION}/Donut_${VERSION#v}" CHANGES=$(cat /tmp/discord-changes.txt) # Build JSON with jq to handle escaping @@ -613,9 +628,9 @@ jobs: --arg title "Donut Browser ${VERSION} Released" \ --arg url "$RELEASE_URL" \ --arg changes "$CHANGES" \ - --arg dl_mac_arm "https://github.com/'"${GITHUB_REPOSITORY}"'/releases/download/'"${VERSION}"'/Donut_'"${VERSION#v}"'_aarch64.dmg" \ - --arg dl_win "https://github.com/'"${GITHUB_REPOSITORY}"'/releases/download/'"${VERSION}"'/Donut_'"${VERSION#v}"'_x64-setup.exe" \ - --arg dl_linux "https://github.com/'"${GITHUB_REPOSITORY}"'/releases/download/'"${VERSION}"'/Donut_'"${VERSION#v}"'_amd64.AppImage" \ + --arg dl_mac_arm "${DL}_aarch64.dmg" \ + --arg dl_win "${DL}_x64-setup.exe" \ + --arg dl_linux "${DL}_amd64.AppImage" \ '{ embeds: [{ title: $title, @@ -635,6 +650,8 @@ jobs: if: github.repository == 'donutbrowser/donutbrowser' needs: [release] runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: {} steps: - name: Trigger Cloudflare Pages deployment env: @@ -655,6 +672,7 @@ jobs: if: github.repository == 'donutbrowser/donutbrowser' needs: [release, changelog] runs-on: ubuntu-latest + timeout-minutes: 15 permissions: contents: write pull-requests: write @@ -669,7 +687,6 @@ jobs: TAG: ${{ github.ref_name }} run: | VERSION="${TAG#v}" - echo "VERSION=${VERSION}" >> "$GITHUB_ENV" AMD64_URL="https://github.com/donutbrowser/donutbrowser/releases/download/${TAG}/Donut_${VERSION}_amd64.AppImage" AARCH64_URL="https://github.com/donutbrowser/donutbrowser/releases/download/${TAG}/Donut_${VERSION}_aarch64.AppImage" @@ -684,10 +701,13 @@ jobs: AMD64_HASH="sha256-$(sha256sum /tmp/amd64.AppImage | awk '{print $1}' | xxd -r -p | base64 | tr -d '\n')" AARCH64_HASH="sha256-$(sha256sum /tmp/aarch64.AppImage | awk '{print $1}' | xxd -r -p | base64 | tr -d '\n')" - echo "AMD64_HASH=${AMD64_HASH}" >> "$GITHUB_ENV" - echo "AARCH64_HASH=${AARCH64_HASH}" >> "$GITHUB_ENV" - echo "AMD64_URL=${AMD64_URL}" >> "$GITHUB_ENV" - echo "AARCH64_URL=${AARCH64_URL}" >> "$GITHUB_ENV" + { + echo "VERSION=${VERSION}" + echo "AMD64_HASH=${AMD64_HASH}" + echo "AARCH64_HASH=${AARCH64_HASH}" + echo "AMD64_URL=${AMD64_URL}" + echo "AARCH64_URL=${AARCH64_URL}" + } >> "$GITHUB_ENV" echo "x86_64 hash: ${AMD64_HASH}" echo "aarch64 hash: ${AARCH64_HASH}" diff --git a/.github/workflows/rolling-release.yml b/.github/workflows/rolling-release.yml index 2b9dd901..ee3891ae 100644 --- a/.github/workflows/rolling-release.yml +++ b/.github/workflows/rolling-release.yml @@ -13,15 +13,9 @@ concurrency: group: rolling-release cancel-in-progress: false +# Each job names what it needs above this. permissions: - contents: write - security-events: write - packages: read - actions: read - -env: - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} + contents: read jobs: security-scan: @@ -34,6 +28,7 @@ jobs: --config=osv-scanner.toml --lockfile=pnpm-lock.yaml --lockfile=src-tauri/Cargo.lock + --lockfile=donut-sync/Cargo.lock ./ permissions: security-events: write @@ -106,6 +101,8 @@ jobs: timeout-minutes: 180 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 + with: + persist-credentials: false - name: Setup pnpm uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 #v6.1.1 @@ -145,10 +142,6 @@ jobs: run: pnpm install --frozen-lockfile - name: Build frontend - # NEXT_PUBLIC_* vars are inlined at build time and must be forwarded - # from secrets explicitly — they are NOT inherited from the job env. - env: - NEXT_PUBLIC_TURNSTILE: ${{ secrets.NEXT_PUBLIC_TURNSTILE }} run: pnpm build - name: Verify frontend dist exists @@ -252,9 +245,10 @@ jobs: APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} TARGET: ${{ matrix.target }} - # tauri-action's inner `pnpm tauri build` re-runs beforeBuildCommand - # which rebuilds dist/ in a subprocess. The env var must be here too. - NEXT_PUBLIC_TURNSTILE: ${{ secrets.NEXT_PUBLIC_TURNSTILE }} + # Signs the updater artifacts. Kept on this step so that install + # scripts and the other steps never see the key. + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} with: projectPath: ./src-tauri tagName: "nightly-${{ steps.timestamp.outputs.timestamp }}" @@ -429,8 +423,8 @@ jobs: - name: Update rolling nightly release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NIGHTLY_TAG: ${{ steps.tag.outputs.nightly_tag }} run: | - NIGHTLY_TAG="${{ steps.tag.outputs.nightly_tag }}" ASSETS_DIR="/tmp/nightly-assets" # Download all assets from the per-commit nightly release @@ -482,6 +476,7 @@ jobs: needs: [update-nightly-release] runs-on: ubuntu-latest timeout-minutes: 10 + permissions: {} steps: - name: Trigger Cloudflare Pages deployment env: @@ -493,6 +488,7 @@ jobs: needs: [update-nightly-release] runs-on: ubuntu-latest timeout-minutes: 10 + permissions: {} steps: - name: Send Discord notification env: diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml index ed9e99b3..9a610784 100644 --- a/.github/workflows/spellcheck.yml +++ b/.github/workflows/spellcheck.yml @@ -3,10 +3,10 @@ name: Spell Check permissions: contents: read +# Pushes to main reach this through rolling-release.yml and tags through +# release.yml. A push trigger of its own ran it twice for each push to main. on: workflow_call: {} - push: - branches: ["main"] pull_request: branches: ["main"] @@ -14,7 +14,7 @@ concurrency: # A called workflow sees its caller's `github.workflow`, so the literal # prefix keeps this group apart from the caller's own. group: spellcheck-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main') }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} env: RUST_BACKTRACE: 1 diff --git a/.github/workflows/test-sdk.yml b/.github/workflows/test-sdk.yml new file mode 100644 index 00000000..3d9c7c43 --- /dev/null +++ b/.github/workflows/test-sdk.yml @@ -0,0 +1,67 @@ +name: Test SDKs + +# The Python and Node clients of the local REST API. Their tests run against +# a fake server and need nothing from the app build. +on: + workflow_call: {} + push: + branches: ["main"] + paths: + - "sdk/**" + - ".github/workflows/test-sdk.yml" + +permissions: + contents: read + +concurrency: + group: test-sdk-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + node: + name: Node SDK + runs-on: ubuntu-latest + timeout-minutes: 10 + defaults: + run: + working-directory: sdk/node + steps: + - name: Checkout repository code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 + with: + persist-credentials: false + + - name: Set up Node.js + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 #v7.1.0 + with: + node-version-file: .node-version + package-manager-cache: false + + # The tests import no package: Node runs the .mts files as they are. + - name: Run tests + run: npm test + + python: + name: Python SDK + runs-on: ubuntu-latest + timeout-minutes: 10 + defaults: + run: + working-directory: sdk/python + steps: + - name: Checkout repository code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1 + with: + persist-credentials: false + + # The oldest version the package supports (requires-python). + - name: Set up Python + uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 #v7.1.0 + with: + python-version: "3.10" + + - name: Install the package with its test dependencies + run: python -m pip install --disable-pip-version-check -e ".[dev]" + + - name: Run tests + run: python -m pytest -q diff --git a/.github/zizmor.yml b/.github/zizmor.yml new file mode 100644 index 00000000..3c7c3687 --- /dev/null +++ b/.github/zizmor.yml @@ -0,0 +1,19 @@ +# zizmor configuration: https://docs.zizmor.sh/configuration/ +rules: + # Each of these workflows must comment on, label or close issues and pull + # requests from forks, which needs the base repository's token. All of them + # check out only the base branch and read the pull request as text through + # the API; none runs code from a fork. + dangerous-triggers: + ignore: + - issue-validation.yml + - pr-ai-policy.yml + - i18n-review.yml + - release-notes-generator.yml + - publish-repos.yml + - notify-telegram.yml + # The value is "$HOME/.local/bin", written to GITHUB_PATH for pip's awscli. + # No untrusted text reaches it. + github-env: + ignore: + - publish-repos.yml:57 diff --git a/osv-scanner.toml b/osv-scanner.toml index 75704fde..1c41eac9 100644 --- a/osv-scanner.toml +++ b/osv-scanner.toml @@ -60,3 +60,23 @@ ignoreUntil = 2026-12-31 id = "GHSA-qwgh-2vcv-g2f7" reason = "block-buffer 0.10 has no fix; axum, boringtun and tauri-codegen still require digest 0.10." ignoreUntil = 2026-12-31 + +# chrono and chrono-tz are direct dependencies of the app, and utoipa's +# `chrono` feature uses the same types. The notices cover every version, so no +# update clears them; the way out is a move to jiff or time. +[[IgnoredVulns]] +id = "RUSTSEC-2026-0543" +reason = "chrono is unmaintained, all versions; no fix to update to until the app moves to another date library." +ignoreUntil = 2027-02-28 + +[[IgnoredVulns]] +id = "RUSTSEC-2026-0555" +reason = "chrono-tz is unmaintained, all versions; it leaves together with chrono." +ignoreUntil = 2027-02-28 + +# Withdrawn by its publisher as not a security issue, but still served by the +# database. picomatch 4.0.7 is the newest release; build tooling only. +[[IgnoredVulns]] +id = "GHSA-fc5q-39xc-vjpf" +reason = "Withdrawn advisory; picomatch 4.0.7 is the latest release and is a build-time dependency." +ignoreUntil = 2027-02-28