Automate Publishing All Packages (#11) #2
Workflow file for this run
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 Packages to pub.dev | |
| on: | |
| push: | |
| tags: | |
| - 'Release/[0-9]+.[0-9]+.[0-9]+*' # matches Release/0.2.0-beta, Release/1.0.0, etc. | |
| permissions: | |
| contents: read | |
| id-token: write # Required for OIDC authentication with pub.dev | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| environment: pub.dev # Optional: requires approval before publishing | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Dart | |
| uses: dart-lang/setup-dart@v1 | |
| with: | |
| sdk: stable | |
| - name: Extract version from tag | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/Release/}" >> $GITHUB_OUTPUT | |
| - name: Prepare packages for publishing | |
| run: dart tools/prepare_publish.dart ${{ steps.version.outputs.VERSION }} | |
| - name: Verify package contents | |
| run: | | |
| for pkg in dart_node_core dart_node_express dart_node_ws dart_node_react dart_node_react_native; do | |
| echo "=== $pkg pubspec.yaml ===" | |
| cat packages/$pkg/pubspec.yaml | |
| echo "" | |
| done | |
| # Publish packages in dependency order | |
| # dart-lang/setup-dart handles OIDC token provisioning automatically | |
| - name: Publish dart_node_core | |
| run: | | |
| cd packages/dart_node_core | |
| dart pub get | |
| dart pub publish --force | |
| - name: Wait for dart_node_core on pub.dev | |
| env: | |
| VERSION: ${{ steps.version.outputs.VERSION }} | |
| run: | | |
| echo "Waiting for dart_node_core $VERSION to be available on pub.dev..." | |
| for i in {1..60}; do | |
| if curl -s "https://pub.dev/api/packages/dart_node_core/versions/$VERSION" | grep -q '"version"'; then | |
| echo "dart_node_core $VERSION is now available!" | |
| exit 0 | |
| fi | |
| echo "Attempt $i/60: Not yet available, waiting 10 seconds..." | |
| sleep 10 | |
| done | |
| echo "Timeout waiting for dart_node_core to be available" | |
| exit 1 | |
| - name: Publish dart_node_express | |
| run: | | |
| cd packages/dart_node_express | |
| dart pub get | |
| dart pub publish --force | |
| - name: Publish dart_node_ws | |
| run: | | |
| cd packages/dart_node_ws | |
| dart pub get | |
| dart pub publish --force | |
| - name: Publish dart_node_react | |
| run: | | |
| cd packages/dart_node_react | |
| dart pub get | |
| dart pub publish --force | |
| - name: Wait for dart_node_react on pub.dev | |
| env: | |
| VERSION: ${{ steps.version.outputs.VERSION }} | |
| run: | | |
| echo "Waiting for dart_node_react $VERSION to be available on pub.dev..." | |
| for i in {1..60}; do | |
| if curl -s "https://pub.dev/api/packages/dart_node_react/versions/$VERSION" | grep -q '"version"'; then | |
| echo "dart_node_react $VERSION is now available!" | |
| exit 0 | |
| fi | |
| echo "Attempt $i/60: Not yet available, waiting 10 seconds..." | |
| sleep 10 | |
| done | |
| echo "Timeout waiting for dart_node_react to be available" | |
| exit 1 | |
| - name: Publish dart_node_react_native | |
| run: | | |
| cd packages/dart_node_react_native | |
| dart pub get | |
| dart pub publish --force |