diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 884de8b04f0..483f25eb123 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,6 +69,9 @@ jobs: uses: andymckay/cancel-action@0.2 if: steps.release_exists.outputs.id != '' + - name: Bump Version Metadata + run: sed -i -e "s/sdkVersion = 'v[0-9]*\.[0-9]*\.[0-9]*'/sdkVersion = 'v${{ steps.which_version.outputs.version }}'" > lib/src/utils.dart + - name: "Generate release changelog" uses: heinrichreimer/github-changelog-generator-action@v2.3 with: diff --git a/.github/workflows/update_protos.yml b/.github/workflows/update_protos.yml index 4dd7d20ed1f..94eead1e619 100644 --- a/.github/workflows/update_protos.yml +++ b/.github/workflows/update_protos.yml @@ -26,6 +26,9 @@ jobs: - run: make setup + - name: Update Proto Tag + run: sed -i -e "s/apiTag = 'v[0-9]*\.[0-9]*\.[0-9]*'/apiTag = '${{ github.event.client_payload.tag }}'" > lib/src/utils.dart + - name: Generate buf run: make buf env: diff --git a/Makefile b/Makefile index 1fb8170f63d..f55ec3f95b9 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,9 @@ endif buf: buf.yaml buf.gen.yaml rm -rf lib/src/gen + $(eval API_VERSION := $(shell grep 'const String apiTag' lib/src/utils.dart | awk -F "'" '{print $$2}')) PATH=$(PATH_WITH_TOOLS) buf generate buf.build/viamrobotics/goutils - PATH=$(PATH_WITH_TOOLS) buf generate buf.build/viamrobotics/api + PATH=$(PATH_WITH_TOOLS) buf generate buf.build/viamrobotics/api:${API_VERSION} PATH=$(PATH_WITH_TOOLS) buf generate buf.build/googleapis/googleapis PATH=$(PATH_WITH_TOOLS) buf generate buf.build/protocolbuffers/wellknowntypes --path google/protobuf/any.proto PATH=$(PATH_WITH_TOOLS) buf generate buf.build/protocolbuffers/wellknowntypes --path google/protobuf/duration.proto diff --git a/lib/src/rpc/dial.dart b/lib/src/rpc/dial.dart index 6e54328c88e..d9aa5e8473e 100644 --- a/lib/src/rpc/dial.dart +++ b/lib/src/rpc/dial.dart @@ -586,6 +586,7 @@ class AuthenticatedChannel extends ViamGrpcOrGrpcWebChannel { } options = options.mergedWith(CallOptions(metadata: {'Authorization': 'Bearer $accessToken'})); + options = options.mergedWith(CallOptions(metadata: {'viam_client': getVersionMetadata()})); return super.createCall(method, requests, options); } } diff --git a/lib/src/rpc/web_rtc/web_rtc_client.dart b/lib/src/rpc/web_rtc/web_rtc_client.dart index 2f5d7eb74a4..b4ed257abee 100644 --- a/lib/src/rpc/web_rtc/web_rtc_client.dart +++ b/lib/src/rpc/web_rtc/web_rtc_client.dart @@ -1,6 +1,7 @@ import 'package:flutter_webrtc/flutter_webrtc.dart'; import 'package:grpc/grpc.dart'; import 'package:grpc/grpc_connection_interface.dart'; +import 'package:viam_sdk/src/utils.dart'; import '../../robot/sessions_client.dart'; import 'web_rtc_client_connection.dart'; @@ -31,6 +32,7 @@ class WebRtcClientChannel extends ClientChannelBase { if (!SessionsClient.unallowedMethods.contains(method.path)) { options = options.mergedWith(CallOptions(metadata: {SessionsClient.sessionMetadataKey: _sessionId()})); } + options = options.mergedWith(CallOptions(metadata: {'viam_client': getVersionMetadata()})); return super.createCall(method, requests, options); } } diff --git a/lib/src/utils.dart b/lib/src/utils.dart index 7aaecc7ba6d..5254d7ce563 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -82,3 +82,9 @@ extension MapStructUtils on Map { return Value()..structValue = toStruct(); } } + +String getVersionMetadata() { + const String sdkVersion = 'v0.0.18'; + const String apiTag = 'v0.1.328'; + return 'flutter;$sdkVersion;$apiTag'; +}