Skip to content

Commit 0095f10

Browse files
authored
Merge pull request #88 from sentry-demos/kw-add-release-action
ci: Add release workflow
2 parents 53e5699 + 3214dc3 commit 0095f10

File tree

5 files changed

+291
-139
lines changed

5 files changed

+291
-139
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Android
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ref:
7+
description: 'The branch to build from. E.g. main'
8+
required: false
9+
type: string
10+
11+
jobs:
12+
build-android:
13+
name: Android
14+
runs-on: ubuntu-latest
15+
env:
16+
APK_PATH: android/app/build/outputs/apk/release/app-release.apk
17+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
18+
SENTRY_ALLOW_FAILURE: false
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
ref: ${{ inputs.ref }}
23+
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: 18
27+
cache: 'npm'
28+
cache-dependency-path: package-lock.json
29+
30+
- run: npm ci
31+
32+
- uses: actions/setup-java@v4
33+
with:
34+
java-version: '17'
35+
distribution: 'adopt'
36+
37+
- uses: gradle/gradle-build-action@v3
38+
39+
- working-directory: android
40+
run: ./gradlew :app:assembleRelease
41+
42+
- name: Upload APK
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: empower-plant-react-native-android
46+
path: ${{ env.APK_PATH }}
47+
retention-days: 60

.github/workflows/build-ios.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: iOS
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ref:
7+
description: 'The branch to build from. E.g. main'
8+
required: false
9+
type: string
10+
11+
jobs:
12+
build-ios:
13+
name: iOS
14+
runs-on: macos-14
15+
env:
16+
APP_ARCHIVE_PATH: sentry_react_native.app.zip
17+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
18+
SENTRY_ALLOW_FAILURE: false
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
ref: ${{ inputs.ref }}
23+
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: 18
27+
cache: 'npm'
28+
cache-dependency-path: package-lock.json
29+
30+
- run: npm ci
31+
32+
- uses: ruby/setup-ruby@v1
33+
with:
34+
ruby-version: '3.3.0'
35+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
36+
37+
- working-directory: ios
38+
run: bundle exec pod install
39+
40+
- name: Run xcodebuild
41+
working-directory: ios
42+
run: |
43+
mkdir -p "DerivedData"
44+
derivedData="$(cd "DerivedData" ; pwd -P)"
45+
set -o pipefail && xcodebuild \
46+
-workspace sentry_react_native.xcworkspace \
47+
-configuration "Release" \
48+
-scheme sentry_react_native \
49+
-destination 'generic/platform=iOS Simulator' \
50+
-derivedDataPath "$derivedData" \
51+
build \
52+
| tee xcodebuild.log \
53+
| xcbeautify --quieter --is-ci --disable-colored-output
54+
55+
- name: Archive App
56+
run: |
57+
cd ios/DerivedData/Build/Products/Release-iphonesimulator
58+
zip -r \
59+
${{ github.workspace }}/${{ env.APP_ARCHIVE_PATH }} \
60+
sentry_react_native.app
61+
62+
- name: Upload APP
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: empower-plant-react-native-ios
66+
path: ${{ env.APP_ARCHIVE_PATH }}
67+
retention-days: 60
68+
69+
- name: Upload logs
70+
if: ${{ always() }}
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: build-ios-logs
74+
path: ios/xcodebuild.log

.github/workflows/build.yml

Lines changed: 9 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -6,152 +6,22 @@ on:
66
- master
77
pull_request:
88

9-
env:
10-
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
11-
SENTRY_ALLOW_FAILURE: false
12-
MAESTRO_VERSION: 1.39.0
13-
APK_PATH: android/app/build/outputs/apk/release/app-release.apk
14-
APP_ARCHIVE_PATH: sentry_react_native.app.zip
15-
169
concurrency:
1710
group: ${{ github.workflow }}-${{ github.ref }}
1811
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
1912

2013
jobs:
2114
build-android:
22-
name: Android
23-
runs-on: ubuntu-latest
24-
steps:
25-
- uses: actions/checkout@v4
26-
27-
- uses: actions/setup-node@v4
28-
with:
29-
node-version: 18
30-
cache: 'npm'
31-
cache-dependency-path: package-lock.json
32-
33-
- run: npm ci
34-
35-
- uses: actions/setup-java@v4
36-
with:
37-
java-version: '17'
38-
distribution: 'adopt'
39-
40-
- uses: gradle/gradle-build-action@v3
41-
42-
- working-directory: android
43-
run: ./gradlew :app:assembleRelease
44-
45-
- name: Upload APK
46-
uses: actions/upload-artifact@v4
47-
with:
48-
name: empower-plant-react-native-android
49-
path: ${{ env.APK_PATH }}
50-
retention-days: 60
15+
name: 'Build Android'
16+
uses: ./.github/workflows/build-android.yml
17+
secrets: inherit
5118

5219
build-ios:
53-
name: iOS
54-
runs-on: macos-14
55-
steps:
56-
- uses: actions/checkout@v4
57-
58-
- uses: actions/setup-node@v4
59-
with:
60-
node-version: 18
61-
cache: 'npm'
62-
cache-dependency-path: package-lock.json
63-
64-
- run: npm ci
65-
66-
- uses: ruby/setup-ruby@v1
67-
with:
68-
ruby-version: '3.3.0'
69-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
20+
name: 'Build iOS'
21+
uses: ./.github/workflows/build-ios.yml
22+
secrets: inherit
7023

71-
- working-directory: ios
72-
run: bundle exec pod install
73-
74-
- name: Run xcodebuild
75-
working-directory: ios
76-
run: |
77-
mkdir -p "DerivedData"
78-
derivedData="$(cd "DerivedData" ; pwd -P)"
79-
set -o pipefail && xcodebuild \
80-
-workspace sentry_react_native.xcworkspace \
81-
-configuration "Release" \
82-
-scheme sentry_react_native \
83-
-destination 'generic/platform=iOS Simulator' \
84-
-derivedDataPath "$derivedData" \
85-
build \
86-
| tee xcodebuild.log \
87-
| xcbeautify --quieter --is-ci --disable-colored-output
88-
89-
- name: Archive App
90-
run: |
91-
zip -r \
92-
${{ env.APP_ARCHIVE_PATH }} \
93-
ios/DerivedData/Build/Products/Release-iphonesimulator/sentry_react_native.app
94-
95-
- name: Upload APP
96-
uses: actions/upload-artifact@v4
97-
with:
98-
name: empower-plant-react-native-ios
99-
path: ${{ env.APP_ARCHIVE_PATH }}
100-
retention-days: 60
101-
102-
- name: Upload logs
103-
if: ${{ always() }}
104-
uses: actions/upload-artifact@v4
105-
with:
106-
name: build-ios-logs
107-
path: ios/xcodebuild.log
108-
109-
run-ui-test-android:
110-
name: UI Test Android
24+
test:
25+
name: 'Run UI Tests'
11126
needs: build-android
112-
runs-on: ubuntu-latest
113-
steps:
114-
- uses: actions/checkout@v4
115-
116-
- name: Setup KVM
117-
shell: bash
118-
run: |
119-
# check if virtualization is supported...
120-
sudo apt install -y --no-install-recommends cpu-checker coreutils && echo "CPUs=$(nproc --all)" && kvm-ok
121-
# allow access to KVM to run the emulator
122-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
123-
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
124-
sudo udevadm control --reload-rules
125-
sudo udevadm trigger --name-match=kvm
126-
127-
- name: Download APK artifact
128-
uses: actions/download-artifact@v4
129-
with:
130-
name: empower-plant-react-native-android
131-
132-
- name: Install Maestro
133-
uses: dniHze/maestro-test-action@bda8a93211c86d0a05b7a4597c5ad134566fbde4 # [email protected]
134-
with:
135-
maestro-version: ${{env.MAESTRO_VERSION}}
136-
137-
- name: Run tests
138-
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # [email protected]
139-
with:
140-
api-level: 30
141-
force-avd-creation: false
142-
disable-animations: true
143-
disable-spellchecker: true
144-
target: 'aosp_atd'
145-
channel: canary # Necessary for ATDs
146-
emulator-options: >
147-
-no-window
148-
-no-snapshot-save
149-
-gpu swiftshader_indirect
150-
-noaudio
151-
-no-boot-anim
152-
-camera-back none
153-
-camera-front none
154-
-timezone US/Pacific
155-
script: |
156-
adb install -r -d app-release.apk
157-
maestro test maestro --debug-output maestro-logs --env=APP_ID=com.sentry_react_native
27+
uses: ./.github/workflows/test.yml

.github/workflows/release.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: 'The version name to release. E.g. 4.0.2'
7+
required: true
8+
9+
env:
10+
APK_PATH: app-release.apk
11+
APP_ARCHIVE_PATH: sentry_react_native.app.zip
12+
GH_TOKEN: ${{ github.token }}
13+
14+
jobs:
15+
bump-version:
16+
runs-on: ubuntu-latest
17+
name: 'Prepare Release'
18+
steps:
19+
- name: Set environment variables
20+
run: |
21+
echo "VERSION=${{ inputs.version }}" >> $GITHUB_ENV
22+
23+
- uses: actions/checkout@v4
24+
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: 18
28+
cache: 'npm'
29+
cache-dependency-path: package-lock.json
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Bump Version
35+
run: |
36+
git config user.name getsentry-bot
37+
git config user.email [email protected]
38+
39+
git checkout -b release/${{ env.VERSION }}
40+
npm version ${{ env.VERSION }}
41+
git tag --force ${{ env.VERSION }} -m ${{ env.VERSION }}
42+
git push origin ${{ env.VERSION }}
43+
git push origin release/${{ env.VERSION }}
44+
45+
build-android:
46+
name: 'Build Android'
47+
needs: [bump-version]
48+
uses: ./.github/workflows/build-android.yml
49+
secrets: inherit
50+
with:
51+
ref: release/${{ inputs.version }}
52+
53+
build-ios:
54+
name: 'Build iOS'
55+
needs: [bump-version]
56+
uses: ./.github/workflows/build-ios.yml
57+
secrets: inherit
58+
with:
59+
ref: release/${{ inputs.version }}
60+
61+
publish-release:
62+
name: 'Publish Release'
63+
needs: [bump-version, build-android]
64+
runs-on: ubuntu-latest
65+
env:
66+
MERGE_TARGET: master
67+
steps:
68+
- name: Set environment variables
69+
run: |
70+
echo "VERSION=${{ inputs.version }}" >> $GITHUB_ENV
71+
72+
- uses: actions/checkout@v4
73+
with:
74+
ref: ${{ env.MERGE_TARGET }}
75+
76+
- name: Download iOS App
77+
uses: actions/download-artifact@v4
78+
with:
79+
name: empower-plant-react-native-ios
80+
81+
- name: Download Android APK
82+
uses: actions/download-artifact@v4
83+
with:
84+
name: empower-plant-react-native-android
85+
86+
- name: Set GitHub user
87+
run: |
88+
git config user.name getsentry-bot
89+
git config user.email [email protected]
90+
91+
- name: Create Release
92+
run: |
93+
gh release create \
94+
${{ env.VERSION }} \
95+
${{ env.APK_PATH }} \
96+
${{ env.APP_ARCHIVE_PATH }} \
97+
--title ${{ env.VERSION }} \
98+
--notes "Release ${{ env.VERSION }}" \
99+
|| error_exit "Failed to create GitHub release."
100+
101+
- name: Merge Release
102+
run: |
103+
git merge release/${{ env.VERSION }} \
104+
&& git push origin ${{ env.MERGE_TARGET }} \
105+
|| gh pr create --title "Merge Release ${{ env.VERSION }}" --body "Merge of the release ${{ env.VERSION }} into ${{ env.MERGE_TARGET }} failed. Please it merge manually."

0 commit comments

Comments
 (0)