Skip to content

Commit

Permalink
feat: add preview and release ci
Browse files Browse the repository at this point in the history
  • Loading branch information
IZUMI-Zu committed Jul 31, 2024
1 parent 90b7351 commit 8044dce
Show file tree
Hide file tree
Showing 7 changed files with 385 additions and 31 deletions.
12 changes: 12 additions & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Always validate the PR title AND all the commits
titleAndCommits: true
# Require at least one commit to be valid
# this is only relevant when using commitsOnly: true or titleAndCommits: true,
# which validate all commits by default
anyCommit: true
# Allow use of Merge commits (eg on github: "Merge branch 'master' into feature/ride-unicorns")
# this is only relevant when using commitsOnly: true (or titleAndCommits: true)
allowMergeCommits: false
# Allow use of Revert commits (eg on github: "Revert "feat: ride unicorns"")
# this is only relevant when using commitsOnly: true (or titleAndCommits: true)
allowRevertCommits: false
50 changes: 50 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build preview for pull requests

on:
push:
# REQUIRED: push main(default) branch is necessary for this action to update its fingerprint database
branches: [master]
pull_request:
types: [opened, synchronize]

jobs:
build:
runs-on: ubuntu-latest
# REQUIRED: limit concurrency when pushing main(default) branch to prevent conflict for this action to update its fingerprint database
concurrency: fingerprint-${{ github.event_name != 'pull_request' && 'master' || github.run_id }}
permissions:
# REQUIRED: Allow comments of PRs
pull-requests: write # Allow comments on PRs
# REQUIRED: Allow updating fingerprint in acton caches
actions: write
# Following permissions are required for private repos
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: 🏗 Setup EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}

- name: Install dependencies
run: npm install

- name: 🚀 Create preview
if: ${{ github.event_name == 'pull_request' }}
uses: expo/expo-github-action/preview@v8
with:
command: eas update --auto --branch ${{ github.event.pull_request.head.ref }}
comment: true
qr-target: 'expo-go'
working-directory: ${{ github.workspace }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Create preview builds if needed
uses: expo/expo-github-action/preview-build@main
with:
command: eas build --profile development --platform all

110 changes: 110 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Build and Release

on:
workflow_dispatch:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build-apk:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: set up JDK 18
uses: actions/setup-java@v4
with:
java-version: 18
distribution: temurin

- name: Install npm dependencies
run: |
npm install && npx expo prebuild --platform android
- name: Build Android Release
run: |
cd android && ./gradlew assembleRelease
mv app/build/outputs/apk/release/app-release.apk app/build/outputs/apk/release/casdoorapp.apk
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: casdoorapp.apk
path: android/app/build/outputs/apk/release/

build-ipa:
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4

- name: set up JDK 18
uses: actions/setup-java@v4
with:
java-version: 18
distribution: temurin

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm install && npx expo prebuild --platform ios

- name: Pod Install
run: cd ios && rm Podfile.lock && pod install --repo-update

- name: build
run: cd ios && xcodebuild -scheme casdoorapp -workspace casdoorapp.xcworkspace -configuration Release clean archive -archivePath "build/casdoorapp.xcarchive" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO

- name: archive to ipa
run: |
cd ios
mkdir build/Payload
mv build/casdoorapp.xcarchive/Products/Applications/casdoorapp.app build/Payload/casdoorapp.app
cd build
zip -r casdoorapp.ipa Payload/
- name: Update artifact
uses: actions/upload-artifact@v4
with:
name: casdoorapp.ipa
path: ios/build/casdoorapp.ipa

semantic-release:
needs: [build-ipa, build-apk]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Download iOS build artifacts
uses: actions/download-artifact@v4
with:
name: casdoorapp.ipa
path: release/ios/

- name: Download Android build artifacts
uses: actions/download-artifact@v4
with:
name: casdoorapp.apk
path: release/android/

- name: Run semantic-release
run: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 21 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,34 @@
"**/*"
],
"ios": {
"supportsTablet": true
"supportsTablet": true,
"bundleIdentifier": "com.zzbs.casdoorapp"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
}
},
"package": "com.zzbs.casdoorapp"
},
"web": {
"favicon": "./assets/favicon.png"
}
},
"extra": {
"eas": {
"projectId": "d0ddea88-9be6-46db-8aa5-ea6d80cef527"
}
},
"plugins": [
[
"expo-camera",
{
"cameraPermission": "Allow $(PRODUCT_NAME) to access your camera",
"microphonePermission": "Allow $(PRODUCT_NAME) to access your microphone",
"recordAudioAndroid": true
}
]
],
"owner": "zzbs"
}
}
45 changes: 45 additions & 0 deletions eas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"cli": {
"version": ">= 10.2.1"
},
"build": {
"base": {
"android": {
"image": "latest",
"buildType": "apk"
},
"ios": {
"image": "latest",
"simulator": true
}
},
"development": {
"extends": "base",
"channel": "development",
"developmentClient": true,
"distribution": "internal",
"android": {
"withoutCredentials": true
},
"ios": {
"buildConfiguration": "Debug"
}
},
"preview": {
"extends": "base",
"channel": "preview",
"distribution": "internal",
"ios": {
"simulator": true
}
},
"production": {
"extends": "base",
"channel": "production",
"autoIncrement": true
}
},
"submit": {
"production": {}
}
}
Loading

0 comments on commit 8044dce

Please sign in to comment.