Skip to content

Commit f771978

Browse files
authored
Add automatic dependency updating workflow to github actions (#2178)
* Add github actions workflow to automatically update the android and cocoa versions when triggered * Use env var to set reviewer for generated PR
1 parent 4f7419a commit f771978

File tree

4 files changed

+89
-3
lines changed

4 files changed

+89
-3
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: update-dependencies
2+
3+
on:
4+
repository_dispatch:
5+
types: [update-dependency]
6+
workflow_dispatch:
7+
inputs:
8+
target_submodule:
9+
description: 'Submodule to update'
10+
required: true
11+
type: string
12+
target_version:
13+
description: 'Version of the submodule to update to'
14+
required: true
15+
type: string
16+
17+
jobs:
18+
update-dependencies:
19+
runs-on: macos-latest
20+
env:
21+
SUBMODULE: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.target_submodule || inputs.target_submodule }}
22+
VERSION: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.target_version || inputs.target_version }}
23+
BUNDLE_GITHUB__COM: ${{ secrets.BUNDLE_ACCESS_TOKEN }}
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
REVIEWER: gingerbenw
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
ref: next
30+
31+
- run: |
32+
git config --global user.name 'Bumpsnag bot'
33+
git config --global user.email ''
34+
35+
- run: git fetch --prune --unshallow
36+
37+
- name: Install ruby
38+
uses: ruby/setup-ruby@v1
39+
with:
40+
ruby-version: 2.7
41+
42+
- name: Install dependencies
43+
run: bundle install
44+
45+
- name: Update references locally
46+
run: TARGET_SUBMODULE=$SUBMODULE TARGET_VERSION=$VERSION bundle exec scripts/update-dependencies.rb
47+
48+
- name: Commit and push changes
49+
run: bundle exec bumpsnag commit_update $SUBMODULE $VERSION
50+
51+
- name: List current branch name
52+
id: current-branch
53+
run: echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
54+
55+
- name: Create pull request
56+
if: ${{ steps.current-branch.outputs.branch != 'next'}}
57+
run: >
58+
gh pr create -B next
59+
-H bumpsnag-$TARGET_SUBMODULE-$TARGET_VERSION
60+
--title "Update $TARGET_SUBMODULE to version $TARGET_VERSION"
61+
--body 'Created by bumpsnag'
62+
--reviewer $REVIEWER

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
source 'https://rubygems.org'
22

33
gem 'cocoapods', '~> 1.14.3'
4+
5+
# Only install bumpsnag if we're using Github actions
6+
unless ENV['GITHUB_ACTIONS'].nil?
7+
gem 'bumpsnag', git: 'https://github.com/bugsnag/platforms-bumpsnag', branch: 'main'
8+
end

packages/react-native/CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
## Upgrading native notifier dependencies
44

5-
Both [`bugsnag-android`](https://github.com/bugnsag/bugsnag-android) and [`bugsnag-cocoa`](https://github.com/bugnsag/bugsnag-cocoa) are vendored into this repository as part of the `@bugsnag/react-native` package. When updates to those notifiers are released, a PR should be make to this repository to vendor the new version.
5+
Both [`bugsnag-android`](https://github.com/bugsnag/bugsnag-android) and [`bugsnag-cocoa`](https://github.com/bugsnag/bugsnag-cocoa) are vendored into this repository as part of the `@bugsnag/react-native` package. When updates to those notifiers are released, a PR should be make to this repository to vendor the new version.
66

77
### Android
88

9-
[bugsnag-android](https://github.com/bugnsag/bugsnag-android) AAR artefacts are located in `packages/react-native/android/com/bugsnag`
9+
[bugsnag-android](https://github.com/bugsnag/bugsnag-android) AAR artefacts are located in `packages/react-native/android/com/bugsnag`
1010

1111
To update the version of the bundled artefacts:
1212

@@ -16,7 +16,7 @@ To update the version of the bundled artefacts:
1616

1717
#### iOS
1818

19-
[bugsnag-cocoa](https://github.com/bugnsag/bugsnag-cocoa) source is vendored in `packages/react-native/ios/vendor/bugsnag-cocoa`.
19+
[bugsnag-cocoa](https://github.com/bugsnag/bugsnag-cocoa) source is vendored in `packages/react-native/ios/vendor/bugsnag-cocoa`.
2020

2121
To update the version of the bundled notifier source:
2222

scripts/update-dependencies.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'bumpsnag'
2+
3+
target_submodule = ENV['TARGET_SUBMODULE']
4+
target_version = ENV['TARGET_VERSION']
5+
6+
if target_submodule.nil? || target_version.nil?
7+
raise 'Submodule or version targets not provided, exiting'
8+
exit(1)
9+
end
10+
11+
pp "Attempting upgrade of #{target_submodule} to #{target_version}"
12+
13+
if target_submodule.eql?('bugsnag-android')
14+
`packages/react-native/update-android.sh --version #{target_version}`
15+
elsif target_submodule.eql?('bugsnag-cocoa')
16+
`packages/react-native/update-ios.sh --version #{target_version}`
17+
else
18+
raise "Submodule #{target_submodule} not supported, exiting"
19+
end

0 commit comments

Comments
 (0)