Skip to content

Commit e2d7fa6

Browse files
authored
Fix Flutter package publish (#20)
1 parent 658c9f6 commit e2d7fa6

7 files changed

Lines changed: 65 additions & 4 deletions

File tree

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ jobs:
5252
working-directory: packages/allure_flutter_test
5353
run: flutter test test
5454

55+
- name: Publish dry-run
56+
run: bash scripts/publish-dry-run.sh
57+
5558
publish-commons:
5659
name: Publish allure_dart_commons
5760
if: startsWith(github.ref_name, 'allure_dart_commons-v')

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ jobs:
5959
working-directory: packages/allure_flutter_test
6060
run: flutter analyze --no-fatal-infos
6161

62+
- name: Publish dry-run
63+
run: bash scripts/publish-dry-run.sh
64+
6265
build:
6366
name: Build (${{ matrix.name }})
6467
runs-on: ${{ matrix.os }}

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ dart analyze
5656

5757
and, when Flutter is available, analyzes `allure_flutter_test`.
5858

59+
Before a release, also validate pub.dev packaging:
60+
61+
```bash
62+
bash scripts/publish-dry-run.sh
63+
```
64+
65+
CI runs that dry-run on every pull request so unconstrained dependencies and
66+
similar publish blockers fail before tagging.
67+
5968
## Running Tests
6069

6170
The default contributor path is the normal Dart and Flutter test runners.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# LocalFileComparator failure diffs written next to goldens during test runs
22
**/failures/
3+
4+
# Accidental local packages created while experimenting with flutter create
5+
flutter_package_*/

packages/allure_flutter_test/.pubignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ pubspec_overrides.yaml
77
build/
88
allure-results/
99
allure-report/
10+
flutter_package_*/

packages/allure_flutter_test/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ dependencies:
1818
sdk: flutter
1919
integration_test:
2020
sdk: flutter
21-
# Version is pinned by the Flutter SDK's own flutter_test dependency, so
22-
# use `any` rather than a manually tracked constraint.
23-
leak_tracker_flutter_testing: any
24-
test_api: any
21+
# Declared for pub.dev (unconstrained `any` is rejected). Keep these wide so
22+
# Flutter SDK's own flutter_test pins can select the matching versions.
23+
leak_tracker_flutter_testing: ^3.0.0
24+
test_api: ^0.7.0
2525

2626
dev_dependencies:
2727
lints: ^6.1.0

scripts/publish-dry-run.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
# Validate that packages can be published to pub.dev.
3+
# Fails on pub publish warnings (for example unconstrained dependencies).
4+
set -euo pipefail
5+
6+
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
7+
cd "${root}"
8+
9+
overrides="${root}/packages/allure_flutter_test/pubspec_overrides.yaml"
10+
if [[ -f "${overrides}" ]]; then
11+
echo "==> removing Flutter workspace overrides for publish dry-run"
12+
rm -f "${overrides}"
13+
fi
14+
15+
echo "==> dart pub get (workspace)"
16+
dart pub get
17+
18+
for package in allure_dart_commons allure_dart_test; do
19+
echo "==> dart pub publish --dry-run (${package})"
20+
(
21+
cd "packages/${package}"
22+
dart pub publish --dry-run
23+
)
24+
done
25+
26+
echo "==> flutter pub get (allure_flutter_test)"
27+
(
28+
cd packages/allure_flutter_test
29+
flutter pub get
30+
)
31+
32+
echo "==> flutter pub publish --dry-run (allure_flutter_test)"
33+
(
34+
cd packages/allure_flutter_test
35+
# Prefer flutter pub so local Flutter SDK resolution matches CI publishers.
36+
if ! flutter pub publish --dry-run; then
37+
echo "allure_flutter_test publish dry-run failed" >&2
38+
exit 1
39+
fi
40+
)
41+
42+
echo "==> publish dry-run passed"

0 commit comments

Comments
 (0)