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