Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ref: Github Action for updating Sentry dependencies. #512

Merged
merged 13 commits into from
Dec 21, 2023
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
lucas-zimerman marked this conversation as resolved.
Show resolved Hide resolved

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