Skip to content

Commit 8403ffc

Browse files
Automate Sentry JS SDK version updates (#3080)
* Add CI workflow to auto-update Sentry JavaScript SDK version Co-authored-by: giancarlo.buenaflor <[email protected]> * Fix perl regex replacement in update-js.sh script Co-authored-by: giancarlo.buenaflor <[email protected]> * Update * Move yml file * Update * Temporary enable it * Checkpoint before follow-up message * Update Sentry bundle integrity hash replacement logic in update-js.sh script Co-authored-by: giancarlo.buenaflor <[email protected]> * Update sh * Update * Remove unnecessary file * Update sentry_js_bundle.dart * Fix sh * Finalize PR * Update * Update * Update update-js.sh --------- Co-authored-by: Cursor Agent <[email protected]>
1 parent 4a336e9 commit 8403ffc

File tree

5 files changed

+101
-6
lines changed

5 files changed

+101
-6
lines changed

.github/workflows/update-deps.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ jobs:
2727
secrets:
2828
api-token: ${{ secrets.CI_DEPLOY_KEY }}
2929

30+
js:
31+
uses: getsentry/github-workflows/.github/workflows/updater.yml@v2
32+
with:
33+
path: flutter/scripts/update-js.sh
34+
name: JavaScript SDK
35+
secrets:
36+
api-token: ${{ secrets.CI_DEPLOY_KEY }}
37+
3038
native:
3139
uses: getsentry/github-workflows/.github/workflows/updater.yml@v2
3240
with:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#091)
1616
- [diff](https://github.com/getsentry/sentry-native/compare/0.9.0...0.9.1)
1717

18+
## Internal
19+
20+
- Automate Sentry JS SDK version updates ([#3080](https://github.com/getsentry/sentry-dart/pull/3080))
21+
1822
## 9.4.1
1923

2024
### Fixes
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
import 'package:meta/meta.dart';
2+
import 'sentry_js_sdk_version.dart';
23

3-
// todo: set up ci to update this and the integrity
4+
// The JS SDK version is automatically bumped by CI via `update-js.sh`.
45
@internal
5-
const jsSdkVersion = '9.5.0';
6+
const jsSdkVersion = sentryJsSdkVersion;
67

78
// The URLs from which the script should be downloaded.
89
@internal
910
const productionScripts = [
1011
{
1112
'url': 'https://browser.sentry-cdn.com/$jsSdkVersion/bundle.tracing.min.js',
12-
'integrity':
13-
'sha384-nsiByevQ25GvAyX+c3T3VctX7x10qZpYsLt3dfkBt04A71M451kWQEu+K4r1Uuk3'
13+
'integrity': productionIntegrity,
1414
}
1515
];
1616

1717
@internal
1818
const debugScripts = [
1919
{
2020
'url': 'https://browser.sentry-cdn.com/$jsSdkVersion/bundle.tracing.js',
21-
'integrity':
22-
'sha384-Iw737zuRcOiGNbRmsWBSA17nCEbheKhfoqbG/3/9JScn1+WV/V6KdisyboGHqovH'
21+
'integrity': debugIntegrity,
2322
},
2423
];
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import 'package:meta/meta.dart';
2+
3+
/// DO NOT EDIT – generated by scripts/update-js.sh
4+
@internal
5+
const sentryJsSdkVersion = '9.5.0';
6+
7+
@internal
8+
const productionIntegrity =
9+
'sha384-nsiByevQ25GvAyX+c3T3VctX7x10qZpYsLt3dfkBt04A71M451kWQEu+K4r1Uuk3';
10+
11+
@internal
12+
const debugIntegrity =
13+
'sha384-Iw737zuRcOiGNbRmsWBSA17nCEbheKhfoqbG/3/9JScn1+WV/V6KdisyboGHqovH';

flutter/scripts/update-js.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# This script bumps the Sentry JavaScript SDK used by the Flutter web integration.
5+
# The expected interface is identical to the other updater scripts used by the
6+
# monorepo so that it can be consumed by the generic getsentry/updater workflow.
7+
#
8+
# Usage: ./update-js.sh <command>
9+
# get-version – prints the currently used SDK version (read from sentry-js-sdk.yaml)
10+
# get-repo – prints the upstream Git repository URL
11+
# set-version X – updates the version to X, refreshes integrity hashes and
12+
# regenerates the Dart constant file used by the web runtime
13+
14+
VERSION_DART_FILE="$(git rev-parse --show-toplevel)/flutter/lib/src/web/sentry_js_sdk_version.dart"
15+
16+
get_current_version() {
17+
awk -F"'" '/sentryJsSdkVersion/ { print $2 }' "$VERSION_DART_FILE"
18+
}
19+
20+
# Regenerates the Dart helper that exposes the SDK version as a compile-time
21+
# constant so that the rest of the code can simply import it.
22+
write_version_dart() {
23+
local version="$1"
24+
local integrity_prod="$2"
25+
local integrity_dbg="$3"
26+
cat >"$VERSION_DART_FILE" <<EOF
27+
import 'package:meta/meta.dart';
28+
29+
/// DO NOT EDIT – generated by scripts/update-js.sh
30+
@internal
31+
const sentryJsSdkVersion = '$version';
32+
33+
@internal
34+
const productionIntegrity =
35+
'sha384-$integrity_prod';
36+
37+
@internal
38+
const debugIntegrity =
39+
'sha384-$integrity_dbg';
40+
EOF
41+
}
42+
43+
case "${1:-}" in
44+
get-version)
45+
get_current_version
46+
;;
47+
48+
get-repo)
49+
echo "https://github.com/getsentry/sentry-javascript.git"
50+
;;
51+
52+
set-version)
53+
new_version="$2"
54+
55+
# Fetch SRI hashes for the given version.
56+
min_js_url="https://browser.sentry-cdn.com/$new_version/bundle.tracing.min.js"
57+
dbg_js_url="https://browser.sentry-cdn.com/$new_version/bundle.tracing.js"
58+
59+
# Compute the SHA-384 SRI hashes (without the sha384- prefix)
60+
integrity_prod=$(curl -sSL "$min_js_url" | openssl dgst -sha384 -binary | openssl base64 -A)
61+
integrity_dbg=$(curl -sSL "$dbg_js_url" | openssl dgst -sha384 -binary | openssl base64 -A)
62+
63+
# Persist changes
64+
write_version_dart "$new_version" "$integrity_prod" "$integrity_dbg"
65+
;;
66+
67+
*)
68+
echo "Unknown argument $1" >&2
69+
exit 1
70+
;;
71+
esac

0 commit comments

Comments
 (0)