Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .github/workflows/publish-pub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,7 @@ jobs:
shell: bash
run: |
set -euo pipefail
flutter pub publish --dry-run
# Tolerates only the expected exact-pin warning for
# flutter_rust_bridge (see tool/check_pub_dry_run.sh).
tool/check_pub_dry_run.sh
flutter pub publish --force
1 change: 1 addition & 0 deletions libfjs/cargokit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ precompiled_binaries:
- tool/check_darwin_package_support.sh
- tool/check_frb_codegen.sh
- tool/check_frb_content_hash.dart
- tool/check_pub_dry_run.sh
build_recipe:
rust_toolchain: '1.97.1'
flutter_version: '3.35.5'
Expand Down
10 changes: 7 additions & 3 deletions tool/check_darwin_package_support.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ check_structure() {
require_file "tool/build_fjs_xcframework.sh"
require_file "tool/check_frb_content_hash.dart"
require_file "tool/check_minimum_flutter_compatibility.sh"
require_file "tool/check_pub_dry_run.sh"
require_file "tool/prepare_darwin_release.sh"

require_contains "pubspec.yaml" "sharedDarwinSource: true"
Expand Down Expand Up @@ -244,7 +245,8 @@ check_structure() {
tool/build_fjs_xcframework.sh \
tool/check_darwin_package_support.sh \
tool/check_frb_codegen.sh \
tool/check_frb_content_hash.dart; do
tool/check_frb_content_hash.dart \
tool/check_pub_dry_run.sh; do
require_exact_line "libfjs/cargokit.yaml" " - $hash_input"
done
require_exact_line "libfjs/cargokit.yaml" " rust_toolchain: '1.97.1'"
Expand Down Expand Up @@ -338,8 +340,10 @@ fjs.xcframework.zip.checksum'
require_not_contains "tool/build_fjs_xcframework.sh" 'assemble_fjs_xcframework.sh'
require_contains "tool/prepare_darwin_release.sh" "--require-artifact"
require_contains "tool/prepare_darwin_release.sh" "check_frb_codegen.sh"
require_contains "tool/prepare_darwin_release.sh" "flutter pub publish --dry-run"
require_contains "tool/prepare_darwin_release.sh" "should allow more than one version"
require_contains "tool/prepare_darwin_release.sh" "check_pub_dry_run.sh"
require_contains "tool/check_pub_dry_run.sh" "flutter pub publish --dry-run"
require_contains "tool/check_pub_dry_run.sh" "should allow more than one version"
require_contains ".github/workflows/publish-pub.yml" "tool/check_pub_dry_run.sh"
require_contains "tool/check_frb_codegen.sh" "FRB_FMT_TOOLCHAIN=nightly"
require_contains ".github/workflows/build-all-platforms.yml" \
"rustup toolchain install nightly --profile minimal --component rustfmt"
Expand Down
34 changes: 34 additions & 0 deletions tool/check_pub_dry_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh
set -eu

# Runs `flutter pub publish --dry-run` and enforces its warnings.
#
# The flutter_rust_bridge dependency is pinned to the exact codegen version
# because FRB requires runtime == codegen at run time, so pub's "should
# allow more than one version" warning for it is expected; it is the only
# warning tolerated here. Any other warning or failure is fatal.

ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"

log="$(mktemp "${TMPDIR:-/tmp}/fjs-pub-dry-run.XXXXXX")"
cleanup() {
rm -f "$log"
}
trap cleanup EXIT
trap 'exit 130' HUP INT TERM

status=0
(cd "$ROOT_DIR" && flutter pub publish --dry-run) >"$log" 2>&1 || status=$?

total_warnings="$(sed -nE 's/^Package has ([0-9]+) warnings?\.$/\1/p' "$log" | tail -n 1)"
[ -n "$total_warnings" ] || total_warnings=0
frb_pin_warnings="$(grep -c 'should allow more than one version' "$log" || true)"
unexpected_warnings=$((total_warnings - frb_pin_warnings))

if [ "$unexpected_warnings" -gt 0 ] ||
{ [ "$status" -ne 0 ] && [ "$frb_pin_warnings" -eq 0 ]; } ||
grep -q '^Error' "$log"; then
cat "$log" >&2
echo "error: pub publish dry-run failed or reported unexpected warnings ($unexpected_warnings)" >&2
exit 1
fi
23 changes: 3 additions & 20 deletions tool/prepare_darwin_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,9 @@ RELEASE_TEMP_DIR=""

pod ipc spec "$ROOT_DIR/darwin/fjs.podspec" >/dev/null

# The runtime dependency is pinned to the exact FRB codegen version because
# FRB enforces runtime == codegen at run time, so pub's "should allow more
# than one version" warning for flutter_rust_bridge is expected; it is the
# only warning this script tolerates. Anything else still fails the release.
publish_log="$(mktemp "$ARTIFACT_DIR/.fjs-pub-dry-run.XXXXXX")"
publish_status=0
(cd "$ROOT_DIR" && flutter pub publish --dry-run) >"$publish_log" 2>&1 || publish_status=$?
total_warnings="$(sed -nE 's/^Package has ([0-9]+) warnings?\.$/\1/p' "$publish_log" | tail -n 1)"
[ -n "$total_warnings" ] || total_warnings=0
frb_pin_warnings="$(grep -c 'should allow more than one version' "$publish_log" || true)"
unexpected_warnings=$((total_warnings - frb_pin_warnings))
if [ "$unexpected_warnings" -gt 0 ] ||
{ [ "$publish_status" -ne 0 ] && [ "$frb_pin_warnings" -eq 0 ]; } ||
grep -q '^Error' "$publish_log"; then
cat "$publish_log" >&2
echo "error: pub publish dry-run failed or reported unexpected warnings ($unexpected_warnings)" >&2
rm -f "$publish_log"
exit 1
fi
rm -f "$publish_log"
# Enforce the publish dry-run, tolerating only the expected exact-pin
# warning for flutter_rust_bridge (see tool/check_pub_dry_run.sh).
"$ROOT_DIR/tool/check_pub_dry_run.sh"

echo "Darwin release artifact: $ARTIFACT_DIR/fjs.xcframework.zip"
echo "SwiftPM checksum: $(cat "$ARTIFACT_DIR/fjs.xcframework.zip.checksum")"
Loading