Skip to content

Commit

Permalink
Ref: Github Action for updating Sentry dependencies. (#512)
Browse files Browse the repository at this point in the history
* add auto update deps

* fix peerDeps, add current branch for testing, removed sentry/cli,  added current branch for testing

* add missing pd package

* test

* test

* dont run scripts in async

* test

* refactor sibling sdk package json

* remove old script

* define updatePeerPackages on all js scripts

* default value for updatePeerPackages

* Update .github/workflows/update-deps.yml
lucas-zimerman authored Dec 21, 2023
1 parent 4b97c4f commit 444c07e
Showing 7 changed files with 182 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/update-deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Update Dependencies

on:
# Run every day.
schedule:
- cron: '0 3 * * *'
# And on on every PR merge so we get the updated dependencies ASAP, and to make sure the changelog doesn't conflict.
push:
branches:
- main

jobs:
android:
uses: getsentry/github-workflows/.github/workflows/updater.yml@v2
with:
path: scripts/update-android.sh
name: Android SDK
pr-strategy: update
secrets:
api-token: ${{ secrets.CI_DEPLOY_KEY }}

cocoa:
uses: getsentry/github-workflows/.github/workflows/updater.yml@v2
with:
path: scripts/update-cocoa.sh
name: Cocoa SDK
pr-strategy: update
secrets:
api-token: ${{ secrets.CI_DEPLOY_KEY }}

javascript:
uses: getsentry/github-workflows/.github/workflows/updater.yml@v2
with:
path: scripts/update-javascript.sh
name: JavaScript SDK
pr-strategy: update
secrets:
api-token: ${{ secrets.CI_DEPLOY_KEY }}

javascript-siblings:
uses: getsentry/github-workflows/.github/workflows/updater.yml@v2
with:
path: scripts/update-javascript-siblings.sh
name: JavaScript Sibling SDKs
pr-strategy: update
secrets:
api-token: ${{ secrets.CI_DEPLOY_KEY }}

wizard:
uses: getsentry/github-workflows/.github/workflows/updater.yml@v2
with:
path: scripts/update-wizard.sh
name: Wizard
pr-strategy: update
changelog-entry: false
secrets:
api-token: ${{ secrets.CI_DEPLOY_KEY }}
28 changes: 28 additions & 0 deletions scripts/update-android.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail

cd $(dirname "$0")/../android
file='build.gradle'
content=$(cat $file)
regex='(io\.sentry:sentry-android:)([0-9\.]+)'
if ! [[ $content =~ $regex ]]; then
echo "Failed to find the android plugin version in $file"
exit 1
fi

case $1 in
get-version)
echo ${BASH_REMATCH[2]}
;;
get-repo)
echo "https://github.com/getsentry/sentry-java.git"
;;
set-version)
newValue="${BASH_REMATCH[1]}$2"
echo "${content/${BASH_REMATCH[0]}/$newValue}" >$file
;;
*)
echo "Unknown argument $1"
exit 1
;;
esac
27 changes: 27 additions & 0 deletions scripts/update-cocoa.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail

file="$(dirname "$0")/../SentryCapacitor.podspec"
content=$(cat $file)
regex="('Sentry/HybridSDK', *)'([0-9\.]+)'"
if ! [[ $content =~ $regex ]]; then
echo "Failed to find the plugin version in $file"
exit 1
fi

case $1 in
get-version)
echo ${BASH_REMATCH[2]}
;;
get-repo)
echo "https://github.com/getsentry/sentry-cocoa.git"
;;
set-version)
newValue="${BASH_REMATCH[1]}'$2'"
echo "${content/${BASH_REMATCH[0]}/$newValue}" >$file
;;
*)
echo "Unknown argument $1"
exit 1
;;
esac
8 changes: 8 additions & 0 deletions scripts/update-javascript-siblings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail

tagPrefix=''
updatePeerPackages=1
repo="https://github.com/getsentry/sentry-javascript.git"
packages=('@sentry/react' '@sentry/vue' '@sentry/angular' '@sentry/angular-ivy')
. $(dirname "$0")/update-package-json.sh
11 changes: 11 additions & 0 deletions scripts/update-javascript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail

tagPrefix=''
repo="https://github.com/getsentry/sentry-javascript.git"
packages=('@sentry/browser' '@sentry/core' '@sentry/integrations' '@sentry/types' '@sentry/utils')
#TODO: remove @sentry/hub and @sentry/tracing on next major release.
#https://github.com/getsentry/sentry-capacitor/issues/511
packages+=('@sentry/hub' '@sentry/tracing')
packages+=('@sentry-internal/eslint-config-sdk' '@sentry-internal/eslint-plugin-sdk' '@sentry-internal/typescript')
. $(dirname "$0")/update-package-json.sh
43 changes: 43 additions & 0 deletions scripts/update-package-json.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# expects `$repo`, `$tagPrefix` and `$packages` (array) variables to be defined, see e.g. update-javascript.sh

file="$(dirname "$0")/../package.json"
content=$(cat $file)
updatePeerPackages=${updatePeerPackages:-0}

case $1 in
get-version)
regex='"'${packages[0]}'": *"([0-9.]+)"'
if ! [[ $content =~ $regex ]]; then
echo "Failed to find plugin '${packages[0]}' version in $file"
exit 1
fi
echo $tagPrefix${BASH_REMATCH[1]}
;;
get-repo)
echo $repo
;;
set-version)
list=""
version="$2"
# remove $tagPrefix from the $version by skipping the first `strlen($tagPrefix)` characters
if [[ "$version" == "$tagPrefix"* ]]; then
version="${version:${#tagPrefix}}"
fi
for i in ${!packages[@]}; do
list+="${packages[$i]}@$version "
done
(
cd "$(dirname "$file")"
if [ "$updatePeerPackages" -eq 1 ]; then
#upgrade doesn't support peerDependencies so we'll use the yarn option.
yarn add --peer $list --update-sentry-capacitor
else
yarn upgrade --non-interactive $list --update-sentry-capacitor
fi
)
;;
*)
echo "Unknown argument $1"
exit 1
;;
esac
8 changes: 8 additions & 0 deletions scripts/update-wizard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail

tagPrefix='v' # wizard has a prefix in the repo, but the package.json doesn't have that - we must align
repo="https://github.com/getsentry/sentry-wizard.git"
packages=('@sentry/wizard')

. $(dirname "$0")/update-package-json.sh

0 comments on commit 444c07e

Please sign in to comment.