Skip to content

Commit bab5c6a

Browse files
committed
Github release script plus README updates
1 parent dab72a9 commit bab5c6a

File tree

2 files changed

+108
-3
lines changed

2 files changed

+108
-3
lines changed

README.md

Lines changed: 94 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,101 @@ Could also be a problem with the backend container/app you're requesting the too
158158

159159
When developing locally, must point React Native to http://127.0.0.1:8080/products backend instead of https://localhost:8080/products backend.
160160

161+
# How To Create a Release
161162

162-
## Creating release with APK + .app.zip for [Test-Data Automation](https://github.com/sentry-demos/application-monitoring/tree/master/tests)
163+
You must complete all of the following steps when setting a new release version:
163164

164-
First generate the apps using `npx react-native run-ios --configuration Release` for iOS, and `npx react-native run-android --variant Release` for Andriod
165+
## 1. Tick the release version forward.
165166

167+
There is only one command needed here:
166168

167-
`gh releaase create <VERSION> <PATH_TO_ANDROID_APK> <PATH_TO_ZIPPED_IOS_APP>`
169+
```
170+
$ npm version patch
171+
```
172+
173+
This:
174+
- Increments version by 0.0.1, i.e. `2.0.1` -> `2.0.2`.
175+
- Automatically keeps versioning consistent across package.json and associated android and ios files
176+
- Automatically creates a commit for the newly created release, i.e. `2.0.2`
177+
178+
You should see:
179+
180+
![Screen Shot 2021-12-08 at 12 42 36 PM](https://user-images.githubusercontent.com/12092849/145281424-5900b190-4369-4607-ac2d-b4a317e28eea.png)
181+
182+
We can run `git log` to confirm that the release commit for `2.0.2` was created:
183+
184+
![Screen Shot 2021-12-08 at 12 59 35 PM](https://user-images.githubusercontent.com/12092849/145283580-5b6186c7-4861-46b9-a6f0-0dfa8d20db58.png)
185+
186+
Be careful about which project you are pointing to when you start ticking releases forward or triggering them. Note that once you tick the release version forward locally (i.e. to `2.0.2`), if you locally trigger an error, the Sentry project you're pointing to will start reporting that error as associated with release `2.0.2` (even though your code is being run locally and is technically not deployed). Such are the dangers of having a demo app's release process not occur during a typical release pipeline.
187+
188+
The `npm version patch` command automatically keeps releases consistent across `package.json`, `Info.plist`, and `build.gradle` thanks to [react-native-version](https://github.com/stovmascript/react-native-version).
189+
190+
## 2. Create a Github Release
191+
192+
It's also crucial that we create a Github release so that our automated test jobs (located in the [application-monitoring repo](https://github.com/sentry-demos/application-monitoring/tree/master/tests)) can create data in Sentry based on the latest react native code.
193+
194+
What’s the purpose of this?
195+
196+
Basically in the Github releases, we want to make sure certain artifacts are uploaded. For example in this release I did, 1.9, we have .apk and .app.zip artifacts uploaded. The generated artifacts will be uploaded to the Github Release we create. Then, our automated ‘TDA’ (test data automation) tests will use these builds of the app to generate data and populate our Sentry demo projects.
197+
198+
This is a guide of how to build those artifacts and create a Github Release, while uploading the relevant artifacts along with the release.
199+
200+
### Generate Release/Debug Artifacts
201+
202+
(:pencil2: I'm hoping to make this a less manual process in the future so that you can just run one or two scripts. Unfortunately some things I haven't figured out about Xcode are preventing that. -Chris)
203+
204+
First: ensure your local repo is up to date with the Github `master` branch via `git pull origin master`.
205+
206+
#### iOS
207+
208+
1. Generate the Release build
209+
- `cd` into the root repository directory - `sentry_react_native`
210+
- Run `npx react-native run-ios --configuration Release`. This will start the iPhone simulator and launch the app but we don’t care about that -- this command also creates the release build.
211+
- This will result in a directory being populated under /Users/cstavitsky/Library/Developer/Xcode/DerivedData (replace cstavitsky with your local username). There will be a sentry-react-native-<bunch of random chars> directory.
212+
- Copy the newly created release artifact into the current directory: `cp -r /Users/cstavitsky/Library/Developer/Xcode/DerivedData/sentry_react_native-dgoblbkgunhkxscqaagaqprvjqus/Build/Products/Release-iphonesimulator/sentry_react_native.app sentry_react_native.app` [your hash sentry_react_native-<....> will probably be different]
213+
- Zip the copied directory so that the .zip can be uploaded along with the Github release: `zip -r sentry_react_native.app.zip sentry_react_native.app`
214+
- If you do a `git status` you should see that `sentry_react_native.app.zip` was `modified`.
215+
- Run `git add sentry_react_native.app.zip`
216+
217+
2. Generate the Debug build
218+
- Run `npx react-native run-ios --configuration Debug`. This will start the iPhone simulator and launch the app but we don’t care about that -- this command also creates the debug build.
219+
- This will result in a directory being populated under /Users/cstavitsky/Library/Developer/Xcode/DerivedData (replace cstavitsky with your local username). There will be a sentry-react-native-<bunch of random chars> directory.
220+
- Copy the newly created release artifact into the current directory: `cp -r /Users/cstavitsky/Library/Developer/Xcode/DerivedData/sentry_react_native-dgoblbkgunhkxscqaagaqprvjqus/Build/Products/Debug-iphonesimulator/sentry_react_native.app sentry_react_native_debug.app` [your hash sentry_react_native-<....> will probably be different]
221+
- Zip the copied directory `zip -r sentry_react_native_debug.app.zip sentry_react_native_debug.app`
222+
- Run `git add sentry_react_native_debug.app.zip`
223+
224+
### Android
225+
226+
1. Generate the Release build
227+
- Run `npx react-native run-android --variant Release`. This will generate the Android release build. Ignore the emulator.
228+
- Copy the release build to the root directory of the project: `cp android/app/build/outputs/apk/release/app-release.apk ./`
229+
- Run `git add app-release.apk`
230+
231+
2. Generate the Debug build
232+
- Run `npx react-native run-android --variant Debug`. This will generate the Android debug build. Ignore the emulator.
233+
- Copy the debug build to the root directory of the project: `cp android/app/build/outputs/apk/debug/app-debug.apk ./`
234+
- Run `git add app-debug.apk`
235+
236+
Create a Github Release:
237+
238+
Note: do not proceed with this until you have done all the previous steps.
239+
240+
1. (If this is your first time doing this, run `brew install gh` to install the Github CLI tool. Once you install it, you can skip this step in the future)
241+
2. Commit the four files `git commit -m “Add release artifacts”`
242+
3. Run the release script `./github_release.sh`, and select yes when prompted.
243+
244+
Your new release should be [visible on Github](https://github.com/sentry-demos/sentry_react_native/releases).
245+
246+
### [Troubleshooting - Locally undoing an accidental increment of the release version]
247+
248+
If you accidentally tick the version forward by running `npm version patch`, and did not intend to do so, you can undo this.
249+
250+
Let's say we were previously on `2.0.1` and accidentally ran the command twice, ticking the release to `2.0.2` and `2.0.3`, but we only wanted to go to `2.0.2`.
251+
252+
- First, run `git log`.
253+
- Copy the commit hash associated with the previous commit that you want to reset to.
254+
255+
![Screen Shot 2021-12-08 at 12 55 09 PM](https://user-images.githubusercontent.com/12092849/145283369-2130cae7-fe0c-42ff-b826-0015c3cd565b.png)
256+
257+
- run `git reset <the commit hash>`.
258+
- Check out any unwanted files that are no longer staged for commit.

github_release.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
PACKAGE_VERSION=$(node -p -e "require('./package.json').version")
2+
REPO=sentry-demos/sentry_react_native
3+
4+
while true; do
5+
read -p "Do you wish to create Github Release $PACKAGE_VERSION for $REPO? Answer y/n: " yn
6+
case $yn in
7+
[Yy]* ) make install; break;;
8+
[Nn]* ) exit;;
9+
* ) echo "Please answer y or n.";;
10+
esac
11+
done
12+
13+
gh release create $PACKAGE_VERSION app-debug.apk app-release.apk sentry_react_native.app.zip sentry_react_native_debug.app.zip
14+

0 commit comments

Comments
 (0)