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 # flutter pub get rewrites tracked files: platform plugin registrants, and
77 # since Flutter 3.44 the analysis_options.yaml of the package and its
78 # example ("Upgrading analysis_options.yaml to exclude build and platform
79 # directories"). pub publish treats a dirty tree as a warning and exits 65,
80 # which is what failed the 1.2.3 release. Restore to HEAD, same as the
81 # publish job below.
82 - name: Restore generated files modified by flutter pub get
83 working-directory: sdk/dart
84 run: git checkout -- . 2>/dev/null || true
85
86 - name: Analyze
87 working-directory: sdk/dart
88 # --no-fatal-infos: flutter_rust_bridge codegen files emit infos that
89 # are intentionally excluded from analysis_options.yaml but the glob
90 # does not cover the frb_generated.dart/ directory structure.
91 run: flutter analyze --no-fatal-infos
92
93 # flutter pub publish --dry-run runs pub get internally, which on newer
94 # Flutter (3.44+) rewrites analysis_options.yaml. Restore the tree right
95 # before the dry-run so pub publish sees a clean git state.
96 - name: Restore tree before dry-run
97 working-directory: sdk/dart
98 run: git checkout -- . 2>/dev/null || true
99
100 - name: Dry-run publish
101 working-directory: sdk/dart
102 run: flutter pub publish --dry-run
103
104 # ── Publish to pub.dev (tag push only) ────────────────────────────────────
105 publish:
106 name: Publish to pub.dev
107 needs: validate
108 runs-on: ubuntu-latest
109 if: startsWith(github.ref, 'refs/tags/')
110
111 env:
112 GRESIQ_API_KEY_DEV: ${{ secrets.GRESIQ_API_KEY_DEV }}
113 GRESIQ_API_SECRET_DEV: ${{ secrets.GRESIQ_API_SECRET_DEV }}
114 GRESIQ_API_KEY_PRODUCTION: ${{ secrets.GRESIQ_API_KEY_PRODUCTION }}
115 GRESIQ_API_SECRET_PRODUCTION: ${{ secrets.GRESIQ_API_SECRET_PRODUCTION }}
116 HF_TOKEN: ${{ secrets.HF_TOKEN }}
117 steps:
118 - name: Checkout
119 uses: actions/checkout@v6
120
121 - name: Set up Flutter
122 uses: subosito/flutter-action@v2
123 with:
124 flutter-version-file: sdk/dart/.flutter-version
125 channel: stable
126 cache: true
127
128 - name: Install dependencies
129 working-directory: sdk/dart
130 run: flutter pub get
131
132 # flutter pub get regenerates platform plugin registrants (e.g.
133 # GeneratedPluginRegistrant.java) which leaves the working tree dirty.
134 # Restore tracked files to HEAD so pub publish sees a clean state.
135 - name: Restore generated files modified by flutter pub get
136 working-directory: sdk/dart
137 run: git checkout -- . 2>/dev/null || true
138
139 # ── Authenticate with pub.dev ─────────────────────────────────────────
140 # PUB_CREDENTIALS must be a repository secret containing the full JSON
141 # content of the Dart pub credentials file obtained from a machine that
142 # has already run `dart pub login` and authorised the pub.dev publisher.
143 #
144 # The credentials file location depends on your OS:
145 # macOS: ~/Library/Application Support/dart/pub-credentials.json
146 # Linux: ~/.config/dart/pub-credentials.json ($XDG_CONFIG_HOME/dart/)
147 # Windows: %APPDATA%\dart\pub-credentials.json
148 #
149 # To obtain the credentials:
150 # 1. Run `dart pub login` on a local machine and authorise in the browser.
151 # 2. Copy the full JSON content of the credentials file for your OS above.
152 # 3. Add it as a repository secret named PUB_CREDENTIALS.
153 - name: Set up pub.dev credentials
154 run: |
155 mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/dart"
156 echo '${{ secrets.PUB_CREDENTIALS }}' > "${XDG_CONFIG_HOME:-$HOME/.config}/dart/pub-credentials.json"
157
158 # ── Publish ────────────────────────────────────────────────────────────
159 - name: Publish onde_inference to pub.dev
160 working-directory: sdk/dart
161 run: flutter pub publish --force