Skip to content

Commit

Permalink
add(ci): build releases for android and ios (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
luisecm authored Oct 29, 2024
1 parent 75a55db commit 276996a
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build-release-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build Android Release
on:
push:
branches:
- main
workflow_dispatch:

jobs:
build-android-release:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- name: setup node
uses: actions/[email protected]
with:
node-version: lts/*

- name: install Rust stable
uses: dtolnay/rust-toolchain@stable

- name: install dependencies (ubuntu only)
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: install frontend dependencies
run: npm install

- name: Build Web Assets 🔨
run: npm run build

- name: Set up JDK
uses: actions/[email protected]
with:
distribution: "temurin"
java-version: "21"

- name: Set up Android SDK
uses: android-actions/[email protected]

- name: Sync Capacitor Assets 🔨
run: npx cap sync && npx cap copy android && cd android && ./gradlew assembleDebug

- name: Upload APK
uses: actions/[email protected]
with:
name: build-android
path: android/app/build/outputs/apk/debug/app-debug.apk
retention-days: 5

- name: Github Release Android
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
android/app/build/outputs/apk/debug/app-debug.apk
88 changes: 88 additions & 0 deletions .github/workflows/build-release-ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build iOS

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: macos-13
name: Build iOS app
steps:
- name: Checkout source
uses: actions/[email protected]

- name: Set up keychain and import certificate
env:
APPLE_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
run: |
# Create a temporary keychain
security create-keychain -p "" build.keychain
security set-keychain-settings -lut 21600 build.keychain
# Import the certificate
echo "$APPLE_CERTIFICATE" | base64 --decode > certificate.p12
security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
# Set the keychain as default
security list-keychains -d user -s build.keychain
security unlock-keychain -p "" build.keychain
# Give the codesign tool access to the keychain
security set-key-partition-list -S apple-tool:,apple: -k "" build.keychain
- name: Set up XCode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 14.3.1

- name: setup node
uses: actions/[email protected]
with:
node-version: lts/*

- name: Install app dependencies
run: npm install

- name: Build project app
run: npm run build

- name: Capacitor update
run: npx cap update

- name: Capacitor copy
run: npx cap copy

- name: Build project
env:
APPLE_TEAM_ID: ${{ secrets.MACOS_NOTARIZATION_TEAM_ID }}
APPLE_SIGNING_IDENTITY: ${{ secrets.MACOS_CERTIFICATE_NAME }}
run: xcodebuild -workspace './ios/App/App.xcworkspace' -scheme App -destination generic/platform=iOS -archivePath App.xcarchive archive DEVELOPMENT_TEAM="$APPLE_TEAM_ID" CODE_SIGN_IDENTITY="$APPLE_SIGNING_IDENTITY"

- name: 🍻 Assemble IPA
run: xcodebuild archive -archivePath App.xcarchive -exportArchive -exportOptionsPlist ./archive.plist -exportPath output -allowProvisioningUpdates

- name: Notarize App with Apple
env:
APPLE_ID: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.MACOS_NOTARIZATION_PWD }}
APPLE_TEAM_ID: ${{ secrets.MACOS_NOTARIZATION_TEAM_ID }}
run: |
xcrun altool --notarize-app -f build/YourApp.ipa \
--primary-bundle-id "com.yourapp.bundle" \
-u "$APPLE_ID" \
-p "$APPLE_PASSWORD"
- name: Upload release bundle
uses: actions/upload-artifact@v3
with:
name: app-ios
path: output/
retention-days: 60

- name: Remove temporary keychain
run: |
security delete-keychain build.keychain

0 comments on commit 276996a

Please sign in to comment.