Skip to content

Commit

Permalink
[WIP]build: support github actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
richardo2016x committed Mar 22, 2024
1 parent bc38c58 commit f6390fa
Show file tree
Hide file tree
Showing 13 changed files with 623 additions and 46 deletions.
114 changes: 114 additions & 0 deletions .github/workflows/android_alpha.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Build and deploy Android alpha
on:
push:
tags:
- 'android-alpha-*'
branches:
- 'ci/android-alpha-*'
# - ci/*
workflow_call:
secrets:
RABBY_MOBILE_ANDROID_KEY_STORE:
required: true
RABBY_MOBILE_ANDROID_KEY_PASSWORD:
required: true
RABBY_MOBILE_ANDROID_KEY_ALIAS:
required: true
RABBY_MOBILE_KR_PWD:
required: true

# defaults:
# run:
# shell: bash -ieo pipefail {0}
env:
BUILD_TARGET_PLATFORM: android

jobs:
alpha-build:
name: android-alpha-build
runs-on:
- self-hosted
- mobile
- macOS
steps:
- uses: actions/checkout@v3
- name: Get Actions Variables
id: actionvars
shell: bash
run: |
trigger_date=$(date +'%Y%m%d%H%M%S')
echo "trigger_date=$trigger_date" >> "$GITHUB_OUTPUT"
flatten_refname=${GITHUB_REF_NAME//\//'_'}
flatten_refname=${flatten_refname//\./'_'}
echo "flatten_refname=$flatten_refname" >> "$GITHUB_OUTPUT"
# env:
# GITHUB_REF_NAME: ${{ github.ref_name }}

# - name: Setup Nodejs and Yarn
# uses: actions/setup-node@v3
# with:
# node-version: 18

# - name: Setup Ruby & Fastlane
# uses: ruby/setup-ruby@v1
# with:
# ruby-version: '2.7'
# bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Setup & Install dependencies
run: |
yarn --version;
# yarn setup && yarn postinstall;
yarn install;
cd apps/mobile;
bundle install;
env:
FLATTEN_REFNAME: ${{ steps.actionvars.outputs.flatten_refname }}
TRIGGER_DATE: ${{ steps.actionvars.outputs.trigger_date }}

# - name: Prepare JSBundle for sourcemap
# run: |
# cd apps/mobile;
# SENTRY_BUNDLE_STAGE=bundle bash ./android/bundle_sourcemap.sh

- name: Build app
env:
RABBY_MOBILE_BUILD_BUCKET: ${{ secrets.RABBY_MOBILE_BUILD_BUCKET }}
RABBY_MOBILE_KR_PWD: ${{ secrets.RABBY_DESKTOP_KR_PWD }}
RABBY_MOBILE_ANDROID_KEY_STORE: ${{ secrets.RABBY_MOBILE_ANDROID_KEY_STORE }}
RABBY_MOBILE_ANDROID_KEY_PASSWORD: ${{ secrets.RABBY_MOBILE_ANDROID_KEY_PASSWORD }}
RABBY_MOBILE_ANDROID_KEY_ALIAS: ${{ secrets.RABBY_MOBILE_ANDROID_KEY_ALIAS }}
RABBY_MOBILE_SENTRY_AUTH_TOKEN: ${{ secrets.RABBY_MOBILE_SENTRY_AUTH_TOKEN }}
SENTRY_AUTH_TOKEN: ${{ secrets.RABBY_MOBILE_SENTRY_AUTH_TOKEN }}
LARK_CHAT_URL: ${{ secrets.LARK_CHAT_URL }}
LARK_CHAT_SECRET: ${{ secrets.LARK_CHAT_SECRET }}
# see more details on https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
GIT_ACTIONS_JOB_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
GIT_COMMIT_URL: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}
GIT_REF_NAME: ${{ github.ref_name }}
GIT_REF_URL: ${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}
GITHUB_REF: ${{ github.ref }}
run: |
cd apps/mobile;
bundle exec fastlane android alpha;
# - name: Upload app to aws bucket
# run: aws s3 cp ./android/app/build/outputs/apk/release/app-release.apk s3://${RABBY_MOBILE_BUILD_BUCKET}/downloads/debank-app/${APK_NAME}.apk --acl public-read

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: rabbymobile-${{ steps.actionvars.outputs.flatten_refname }}-${{ steps.actionvars.outputs.trigger_date }}
path: |
./apps/mobile/android/app/build/outputs/apk/release/app-release.apk
retention-days: 90
98 changes: 98 additions & 0 deletions .github/workflows/ios_alpha.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Build and deploy iOS alpha
on:
push:
tags:
- 'ios-alpha-*'
branches:
- 'ci/ios-alpha-*'
- ci/*
workflow_dispatch:
workflow_call:
secrets:
MATCH_GIT_PRIVATE_KEY:
required: true
MATCH_PASSWORD:
required: true
NPM_AUTH_TOKEN:
required: true

# defaults:
# run:
# shell: bash -ieo pipefail {0}

env:
BUILD_TARGET_PLATFORM: ios

jobs:
setup:
name: iOS-alpha-build
runs-on: [self-hosted, mobile, macOS]
# defaults:
# run:
# shell: bash -ieo pipefail {0}
steps:
- uses: actions/checkout@v4
- name: Get Actions Variables
id: actionvars
shell: bash
run: |
trigger_date=$(date +'%Y%m%d%H%M%S')
echo "trigger_date=$trigger_date" >> "$GITHUB_OUTPUT"
flatten_refname=${GITHUB_REF_NAME//\//'_'}
flatten_refname=${flatten_refname//\./'_'}
echo "flatten_refname=$flatten_refname" >> "$GITHUB_OUTPUT"
# - name: Setup Nodejs and Yarn
# uses: actions/setup-node@v3
# with:
# node-version: 18

# - name: Setup Ruby & Fastlane
# uses: ruby/setup-ruby@v1
# with:
# ruby-version: '2.7'
# bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- uses: maxim-lobanov/setup-xcode@v1
id: setup-xcode
with:
# use specific version rather than 'latest-stable' if multiple Xcodes installed
xcode-version: '15.3'

- name: Install dependencies
run: |
yarn --version;
cd ./apps/mobile;
yarn install;
cd ios;
bundle install && bundle exec pod install;
- name: Build app
env:
RABBY_MOBILE_BUILD_BUCKET: ${{ secrets.RABBY_MOBILE_BUILD_BUCKET }}
RABBY_MOBILE_KR_PWD: ${{ secrets.RABBY_DESKTOP_KR_PWD }}
RABBY_MOBILE_SENTRY_AUTH_TOKEN: ${{ secrets.RABBY_MOBILE_SENTRY_AUTH_TOKEN }}
SENTRY_AUTH_TOKEN: ${{ secrets.RABBY_MOBILE_SENTRY_AUTH_TOKEN }}
CONFIGURATION: release
TYPE: adhoc
BUILD_ENV: alpha
LARK_CHAT_URL: ${{ secrets.LARK_CHAT_URL }}
LARK_CHAT_SECRET: ${{ secrets.LARK_CHAT_SECRET }}
# see more details on https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
GIT_ACTIONS_JOB_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
GIT_COMMIT_URL: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}
GIT_REF_NAME: ${{ github.ref_name }}
GIT_REF_URL: ${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}
GITHUB_REF: ${{ github.ref }}
run: |
cd apps/mobile;
bundle exec fastlane ios alpha
# - name: copy dest
# run: |
# cp ./ios/Package/rabbymobile.ipa ./ios/outputs/RabbyMobile.ipa
# cp ./ios/Package/manifest.plist ./ios/outputs/manifest.plist

# - name: Upload app
# run: aws s3 cp ./ios/outputs s3://${BUILD_BUCKET}/downloads/debank-app/ --recursive --acl public-read
67 changes: 67 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Test

on:
push:
branches:
- dev
- feat*
# - ci/*

defaults:
run:
shell: bash -ieo pipefail {0}

jobs:
setup:
name: Build
strategy:
matrix:
host: [macOS]
runs-on:
- self-hosted
- mobile
- ${{ matrix.host }}
env:
NODE_OPTIONS: '--max_old_space_size=4096'

steps:
- name: Checkout git repo
uses: actions/checkout@v3

- name: Env Test
id: env-test
shell: bash
run: |
echo "whoami $(whoami)"
echo "shell is $(echo $0)"
echo "HOME is $HOME"
echo "which node $(which node)"
- name: Install and build
shell: bash
run: |
npm i -g @debank/cli@latest;
cd apps/mobile;
yarn install;
yarn apply-patch;
yarn prepare-archive;
security unlock-keychain -p ${{ secrets.KEYCHAIN_PASS }} ~/Library/Keychains/login.keychain-db
env:
KEYCHAIN_PASS: ${{ secrets.KEYCHAIN_PASS }}
RABBY_MOBILE_BUILD_BUCKET: ${{ secrets.RABBY_MOBILE_BUILD_BUCKET }}
RABBY_MOBILE_KR_PWD: ${{ secrets.RABBY_DESKTOP_KR_PWD }}
RABBY_MOBILE_ANDROID_KEY_STORE: ${{ secrets.RABBY_MOBILE_ANDROID_KEY_STORE }}
RABBY_MOBILE_ANDROID_KEY_PASSWORD: ${{ secrets.RABBY_MOBILE_ANDROID_KEY_PASSWORD }}
RABBY_MOBILE_ANDROID_KEY_ALIAS: ${{ secrets.RABBY_MOBILE_ANDROID_KEY_ALIAS }}
RABBY_MOBILE_SENTRY_AUTH_TOKEN: ${{ secrets.RABBY_MOBILE_SENTRY_AUTH_TOKEN }}
LARK_CHAT_URL: ${{ secrets.LARK_CHAT_URL }}
LARK_CHAT_SECRET: ${{ secrets.LARK_CHAT_SECRET }}
RABBY_REALLY_COPY: ${{ vars.RABBY_REALLY_COPY }}
# see more details on https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
GIT_ACTIONS_JOB_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
GIT_COMMIT_URL: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}
GIT_REF_NAME: ${{ github.ref_name }}
GIT_REF_URL: ${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}
GITHUB_REF: ${{ github.ref }}
1 change: 1 addition & 0 deletions apps/mobile/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ios/.xcode.env.local
# Android/IntelliJ
#
build/
build4sentry/
.idea
.gradle
local.properties
Expand Down
3 changes: 3 additions & 0 deletions apps/mobile/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ ruby ">= 2.6.10"
gem 'cocoapods', '~> 1.11', '>= 1.11.2'
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'
gem 'fastlane'

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
5 changes: 5 additions & 0 deletions apps/mobile/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
fastlane-plugin-sentry (1.20.0)
os (~> 1.1, >= 1.1.4)
fastlane-plugin-versioning_android (0.1.1)
ffi (1.16.3)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
Expand Down Expand Up @@ -279,6 +282,8 @@ DEPENDENCIES
activesupport (>= 6.1.7.3, < 7.1.0)
cocoapods (~> 1.11, >= 1.11.2)
fastlane
fastlane-plugin-sentry
fastlane-plugin-versioning_android

RUBY VERSION
ruby 2.6.10p210
Expand Down
35 changes: 35 additions & 0 deletions apps/mobile/android/bundle_sourcemap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

set -e

script_dir="$( cd "$( dirname "$0" )" && pwd )"
android_dir=$script_dir
project_dir=$(dirname $script_dir)

. $project_dir/scripts/fns.sentry.sh --source-only

# https://docs.sentry.io/platforms/react-native/manual-setup/hermes/
# script would be also executed on ../fastlane/

sentryfn_setup;
if [[ ! -f $HERMES_BIN ]]; then
echo "[bundle_sourcemap] Hermes compiler not found. Make sure you have hermesc installed correctly."
exit 1
fi

if [[ $SENTRY_BUNDLE_STAGE == "bundle" ]]; then
echo "[bundle_sourcemap::bundle] Start to bundle."

sentryfn_build_sourcemap;
elif [[ $SENTRY_BUNDLE_STAGE == "postbundle" ]]; then
echo "[bundle_sourcemap::postbundle] Start to output & compose sourcemap."

sentryfn_build_sourcemap;
sentryfn_build_hbc;
sentryfn_compose_sourcemap;
else
echo "[bundle_sourcemap] Unknown SENTRY_BUNDLE_STAGE: $SENTRY_BUNDLE_STAGE"
exit 1
fi

echo "[bundle_sourcemap] Done."
46 changes: 0 additions & 46 deletions apps/mobile/android/upload_sentry_source.sh

This file was deleted.

Loading

0 comments on commit f6390fa

Please sign in to comment.