1 name: Release SDK Dart
2
3 on:
4 push:
5 tags:
6 - "[0-9]+.[0-9]+.[0-9]+"
7 workflow_dispatch:
8
9 permissions:
10 contents: write
11
12 jobs:
13 # Cheap ubuntu gate: version agreement, crates.io publishability, tag match.
14 # Blocks the expensive job below so a metadata fault never costs runner time.
15 preflight:
16 uses: ./.github/workflows/release-preflight.yml
17 with:
18 tag: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
19
20 # ── Validate (every run) ──────────────────────────────────────────────────
21 validate:
22 needs: preflight
23 name: Validate
24 runs-on: ubuntu-latest
25
26 outputs:
27 version: ${{ steps.meta.outputs.version }}
28
29 env:
30 GRESIQ_API_KEY_DEV: ${{ secrets.GRESIQ_API_KEY_DEV }}
31 GRESIQ_API_SECRET_DEV: ${{ secrets.GRESIQ_API_SECRET_DEV }}
32 GRESIQ_API_KEY_PRODUCTION: ${{ secrets.GRESIQ_API_KEY_PRODUCTION }}
33 GRESIQ_API_SECRET_PRODUCTION: ${{ secrets.GRESIQ_API_SECRET_PRODUCTION }}
34 HF_TOKEN: ${{ secrets.HF_TOKEN }}
35 steps:
36 - name: Checkout
37 uses: actions/checkout@v6
38
39 - name: Set up Flutter
40 uses: subosito/flutter-action@v2
41 with:
42 flutter-version-file: sdk/dart/.flutter-version
43 channel: stable
44 cache: true
45
46 # ── Read version ───────────────────────────────────────────────────────
47
48 - name: Read version from pubspec.yaml
49 id: meta
50 working-directory: sdk/dart
51 run: |
52 VERSION=$(grep '^version:' pubspec.yaml | awk '{print $2}')
53 echo "version=$VERSION" >> "$GITHUB_OUTPUT"
54 echo "Dart SDK version: $VERSION"
55
56 # ── Validate tag = pubspec version (tag push only) ─────────────────────
57
58 - name: Validate tag matches pubspec.yaml version
59 if: startsWith(github.ref, 'refs/tags/')
60 env:
61 PUBSPEC_VERSION: ${{ steps.meta.outputs.version }}
62 TAG: ${{ github.ref_name }}
63 run: |
64 if [ "$TAG" != "$PUBSPEC_VERSION" ]; then
65 echo "::error::Tag '$TAG' does not match pubspec.yaml version '$PUBSPEC_VERSION'. Update pubspec.yaml or re-tag."
66 exit 1
67 fi
68 echo "Version check passed: $PUBSPEC_VERSION"
69
70 # ── Lint & dry-run ────────────────────────────────────────────────────
71
72 - name: Install dependencies
73 working-directory: sdk/dart
74 run: flutter pub get
75
76 - name: Analyze
77 working-directory: sdk/dart
78 # --no-fatal-infos: flutter_rust_bridge codegen files emit infos that
79 # are intentionally excluded from analysis_options.yaml but the glob
80 # does not cover the frb_generated.dart/ directory structure.
81 run: flutter analyze --no-fatal-infos
82
83 - name: Dry-run publish
84 working-directory: sdk/dart
85 run: flutter pub publish --dry-run
86
87 # ── Publish to pub.dev (tag push only) ────────────────────────────────────
88 publish:
89 name: Publish to pub.dev
90 needs: validate
91 runs-on: ubuntu-latest
92 if: startsWith(github.ref, 'refs/tags/')
93
94 env:
95 GRESIQ_API_KEY_DEV: ${{ secrets.GRESIQ_API_KEY_DEV }}
96 GRESIQ_API_SECRET_DEV: ${{ secrets.GRESIQ_API_SECRET_DEV }}
97 GRESIQ_API_KEY_PRODUCTION: ${{ secrets.GRESIQ_API_KEY_PRODUCTION }}
98 GRESIQ_API_SECRET_PRODUCTION: ${{ secrets.GRESIQ_API_SECRET_PRODUCTION }}
99 HF_TOKEN: ${{ secrets.HF_TOKEN }}
100 steps:
101 - name: Checkout
102 uses: actions/checkout@v6
103
104 - name: Set up Flutter
105 uses: subosito/flutter-action@v2
106 with:
107 flutter-version-file: sdk/dart/.flutter-version
108 channel: stable
109 cache: true
110
111 - name: Install dependencies
112 working-directory: sdk/dart
113 run: flutter pub get
114
115 # flutter pub get regenerates platform plugin registrants (e.g.
116 # GeneratedPluginRegistrant.java) which leaves the working tree dirty.
117 # Restore tracked files to HEAD so pub publish sees a clean state.
118 - name: Restore generated files modified by flutter pub get
119 working-directory: sdk/dart
120 run: git checkout -- . 2>/dev/null || true
121
122 # ── Authenticate with pub.dev ─────────────────────────────────────────
123 # PUB_CREDENTIALS must be a repository secret containing the full JSON
124 # content of the Dart pub credentials file obtained from a machine that
125 # has already run `dart pub login` and authorised the pub.dev publisher.
126 #
127 # The credentials file location depends on your OS:
128 # macOS: ~/Library/Application Support/dart/pub-credentials.json
129 # Linux: ~/.config/dart/pub-credentials.json ($XDG_CONFIG_HOME/dart/)
130 # Windows: %APPDATA%\dart\pub-credentials.json
131 #
132 # To obtain the credentials:
133 # 1. Run `dart pub login` on a local machine and authorise in the browser.
134 # 2. Copy the full JSON content of the credentials file for your OS above.
135 # 3. Add it as a repository secret named PUB_CREDENTIALS.
136 - name: Set up pub.dev credentials
137 run: |
138 mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/dart"
139 echo '${{ secrets.PUB_CREDENTIALS }}' > "${XDG_CONFIG_HOME:-$HOME/.config}/dart/pub-credentials.json"
140
141 # ── Publish ────────────────────────────────────────────────────────────
142 - name: Publish onde_inference to pub.dev
143 working-directory: sdk/dart
144 run: flutter pub publish --force