Publish WebF Native Plugins #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish WebF Native Plugins | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| packages: | |
| description: "Comma-separated package paths (default: auto-discover native_uis/* + native_plugins/*)" | |
| required: false | |
| default: "" | |
| type: string | |
| dry_run: | |
| description: "Run `flutter pub publish --dry-run` only" | |
| required: true | |
| default: true | |
| type: boolean | |
| force: | |
| description: "Pass --force when publishing" | |
| required: true | |
| default: true | |
| type: boolean | |
| skip_tests: | |
| description: "Skip tests in publisher action" | |
| required: true | |
| default: true | |
| type: boolean | |
| concurrency: | |
| group: publish-webf-native-plugins | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| resolve-packages: | |
| name: Resolve Packages | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.resolve.outputs.matrix }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Resolve package list | |
| id: resolve | |
| shell: bash | |
| run: | | |
| python3 - <<'PY' > packages.json | |
| import glob | |
| import json | |
| import os | |
| raw = os.environ.get("INPUT_PACKAGES", "").strip() | |
| packages = [] | |
| if raw: | |
| for item in raw.split(","): | |
| p = item.strip().rstrip("/") | |
| if p: | |
| packages.append(p) | |
| else: | |
| # Auto-discover packages in native_uis/* | |
| for pubspec in sorted(glob.glob("native_uis/*/pubspec.yaml")): | |
| directory = os.path.dirname(pubspec) | |
| if "/.dart_tool/" in directory: | |
| continue | |
| packages.append(directory) | |
| # Auto-discover packages in native_plugins/* | |
| for pubspec in sorted(glob.glob("native_plugins/*/pubspec.yaml")): | |
| directory = os.path.dirname(pubspec) | |
| if "/.dart_tool/" in directory: | |
| continue | |
| packages.append(directory) | |
| # De-duplicate while preserving order | |
| seen = set() | |
| packages = [p for p in packages if not (p in seen or seen.add(p))] | |
| if not packages: | |
| raise SystemExit("No publishable packages found (set workflow input `packages` to override).") | |
| print(json.dumps({"include": [{"relativePath": p} for p in packages]})) | |
| PY | |
| echo "Resolved packages:" | |
| cat packages.json | |
| echo "" | |
| MATRIX="$(cat packages.json)" | |
| echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT" | |
| env: | |
| INPUT_PACKAGES: ${{ inputs.packages }} | |
| publish: | |
| name: Publish | |
| runs-on: ubuntu-latest | |
| needs: [resolve-packages] | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.resolve-packages.outputs.matrix) }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Validate package path | |
| shell: bash | |
| run: | | |
| test -f "${{ matrix.relativePath }}/pubspec.yaml" | |
| echo "Publishing package at: ${{ matrix.relativePath }}" | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| - name: Pub publish (dry run) | |
| if: ${{ inputs.dry_run }} | |
| working-directory: ${{ matrix.relativePath }} | |
| run: flutter pub publish --dry-run | |
| - name: Publish to pub.dev | |
| if: ${{ !inputs.dry_run }} | |
| uses: k-paxian/dart-package-publisher@master | |
| with: | |
| credentialJson: ${{ secrets.PUB_DEV_TOKEN }} | |
| flutter: true | |
| force: ${{ inputs.force }} | |
| skipTests: ${{ inputs.skip_tests }} | |
| relativePath: ${{ matrix.relativePath }} |