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 30, 2024
1 parent 90b7351 commit 0291bbf
Show file tree
Hide file tree
Showing 8 changed files with 406 additions and 30 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
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: EAS Build

on:
workflow_dispatch:
pull_request:
paths:
- "*.js"
- "package.json"
- "eas.json"
- "app.json"

jobs:
build:
name: Install and build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version: 18.x
# cache: npm
# - name: Setup Expo and EAS
# uses: expo/expo-github-action@v8
# with:
# eas-version: latest
# token: ${{ secrets.EXPO_TOKEN }}
# - name: Install dependencies
# run: npm ci

# - name: Build on EAS
# run: eas build --platform all --non-interactive --no-wait
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

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

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

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
build: [development, production]
include:
- os: macos-latest
platform: ios
- os: ubuntu-latest
platform: android

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup JDK 21
if: matrix.platform == 'android'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Setup Expo and EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Install dependencies
run: npm ci
- name: Build Locally
run: eas build --profile ${{ matrix.build }} --platform ${{ matrix.platform }} --no-wait --non-interactive --local

- name: Archive iOS build artifacts
if: matrix.platform == 'ios'
run: |
tar -xzvf build-*.tar.gz
mkdir -p Payload
mv $(find . -name "*.app" | head -n 1) Payload/casdoorapp.app
zip -r casdoor-app-ios-${{ matrix.build }}.ipa Payload/
- name: Upload iOS build artifacts
uses: actions/upload-artifact@v4
if: matrix.platform == 'ios'
with:
name: casdoor-app-ios-${{ matrix.build }}
path: casdoor-app-ios-${{ matrix.build }}.ipa

- name: Archive Android build artifacts
if: matrix.platform == 'android'
run: |
mv $(find . -name "*.apk" | head -n 1) casdoor-app-android-${{ matrix.build }}.apk
- name: Upload Android build artifacts
if: matrix.platform == 'android'
uses: actions/upload-artifact@v4
with:
name: casdoor-app-android-${{ matrix.build }}
path: casdoor-app-android-${{ matrix.build }}.apk

semantic-release:
needs: build
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 (development)
uses: actions/download-artifact@v4
with:
name: casdoor-app-ios-development
path: release/ios/

- name: Download iOS build artifacts (production)
uses: actions/download-artifact@v4
with:
name: casdoor-app-ios-production
path: release/ios/

- name: Download Android build artifacts (development)
uses: actions/download-artifact@v4
with:
name: casdoor-app-android-development
path: release/android/

- name: Download Android build artifacts (production)
uses: actions/download-artifact@v4
with:
name: casdoor-app-android-production
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 0291bbf

Please sign in to comment.