Skip to content

Commit

Permalink
feat: add Semantic (#1)
Browse files Browse the repository at this point in the history
* feat: add preview ci (casdoor#11)

* feat: change Expo owner (casdoor#12)

* feat: change preview ci to manual trigger (casdoor#15)

* feat: update dependencies and useNetInfo for network status (casdoor#16)

* feat: add semantic release

* feat: update installation instructions and build steps

* feat: remove ios build

---------

Co-authored-by: IZUMI-Zu <274620705z@gmail.com>
  • Loading branch information
binshuoz and IZUMI-Zu authored Aug 4, 2024
1 parent 9627c58 commit ac66df4
Show file tree
Hide file tree
Showing 9 changed files with 410 additions and 294 deletions.
145 changes: 114 additions & 31 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,133 @@
name: Build preview for pull requests
name: Manual Expo Preview

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

permissions:
contents: read
pull-requests: write
issues: write

jobs:
build:
check_permissions:
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
if: github.event_name == 'issue_comment' && contains(github.event.comment.body, '/preview') && github.event.issue.pull_request
outputs:
has_permissions: ${{ steps.check.outputs.has_permissions }}
pr_number: ${{ steps.get_pr_details.outputs.pr_number }}
pr_head_ref: ${{ steps.get_pr_details.outputs.pr_head_ref }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get PR details
id: get_pr_details
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { data: pullRequest } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
core.setOutput('pr_number', pullRequest.number);
core.setOutput('pr_head_ref', pullRequest.head.ref);
- name: 🏗 Setup EAS
uses: expo/expo-github-action@v8
- name: Check permissions
id: check
uses: actions/github-script@v7
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: context.payload.comment.user.login
});
const hasPermissions = ['admin', 'write'].includes(permission.permission);
core.setOutput('has_permissions', hasPermissions);
preview:
needs: check_permissions
if: needs.check_permissions.outputs.has_permissions == 'true'
runs-on: ubuntu-latest
steps:
- name: Get PR details
uses: actions/github-script@v7
id: pr-details
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ needs.check_permissions.outputs.pr_number }}
});
core.setOutput('head_sha', pr.head.sha);
core.setOutput('head_repo', pr.head.repo.full_name);
core.setOutput('head_ref', pr.head.ref);
- uses: actions/checkout@v4
with:
repository: ${{ steps.pr-details.outputs.head_repo }}
ref: ${{ steps.pr-details.outputs.head_ref }}
fetch-depth: 0

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

- name: Install dependencies
run: npm install

- name: 🚀 Create preview
if: ${{ github.event_name == 'pull_request' }}
- name: Setup Expo
uses: expo/expo-github-action@v8
with:
eas-version: latest
eas-cache: true
expo-version: latest
expo-cache: true
packager: npm
token: ${{ secrets.EXPO_TOKEN }}

- name: Create preview
id: preview
uses: expo/expo-github-action/preview@v8
with:
command: eas update --auto --branch ${{ github.event.pull_request.head.ref }}
comment: true
comment: false
qr-target: 'expo-go'
working-directory: ${{ github.workspace }}
github-token: ${{ secrets.GITHUB_TOKEN }}
command: eas update --auto --branch pr-${{ needs.check_permissions.outputs.pr_head_ref }}

- name: Create preview builds if needed
uses: expo/expo-github-action/preview-build@main
- name: Find Comment
uses: peter-evans/find-comment@v3
id: find_comment
with:
command: eas build --profile development --platform all
issue-number: ${{ needs.check_permissions.outputs.pr_number }}
comment-author: 'github-actions[bot]'
body-includes: Expo Preview

- name: Create or Update Comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ needs.check_permissions.outputs.pr_number }}
comment-id: ${{ steps.find_comment.outputs.comment-id }}
body: |
## Expo Preview
${{steps.preview.outputs.comment}}
> Commit hash: ${{steps.preview.outputs.gitCommitHash}}
> Update published at: ${{steps.preview.outputs.createdAt}}
edit-mode: replace

pr_comment:
needs: check_permissions
if: needs.check_permissions.outputs.has_permissions != 'true'
runs-on: ubuntu-latest
steps:
- name: Comment on PR (insufficient permissions)
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ needs.check_permissions.outputs.pr_number }}
body: |
Sorry, you do not have the required permissions to trigger an Expo preview.
Please ask a maintainer to review and trigger the preview if necessary.
50 changes: 1 addition & 49 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,60 +29,18 @@ jobs:
- 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]
needs: [build-apk]
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -92,12 +50,6 @@ jobs:
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:
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,35 @@ cd casdoor-app
npm install && npm run start
```

## Installation

You can download the latest version of the Casdoor Authenticator App from the GitHub Releases page.

- Android: Download and install the APK file directly on your device.

### Building from Source

If you prefer to build the app yourself, follow these steps:

### Common Steps

```bash
git clone git@github.com:casdoor/casdoor-app.git
cd casdoor-app
npm install
```

### android build

```bash
npm install && npx expo prebuild --platform android
cd android && ./gradlew assembleRelease
```

The APK file in the `app/build/outputs/apk/release/` directory.

Note: You'll need to have the necessary development environments set up for React Native, Android. Refer to the React Native documentation for detailed setup instructions.
## Usage
- Open the app on your mobile device.
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@
],
"owner": "zzbs"
}
}
}
80 changes: 40 additions & 40 deletions eas.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
{
"cli": {
"version": ">= 10.2.1"
},
"build": {
"base": {
"android": {
"image": "latest",
"buildType": "apk"
},
"ios": {
"image": "latest",
"simulator": true
}
"cli": {
"version": ">= 10.2.1"
},
"development": {
"extends": "base",
"channel": "development",
"developmentClient": true,
"distribution": "internal",
"android": {
"withoutCredentials": true
},
"ios": {
"buildConfiguration": "Debug"
}
"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
}
},
"preview": {
"extends": "base",
"channel": "preview",
"distribution": "internal",
"ios": {
"simulator": true
}
},
"production": {
"extends": "base",
"channel": "production",
"autoIncrement": true
"submit": {
"production": {}
}
},
"submit": {
"production": {}
}
}
Loading

0 comments on commit ac66df4

Please sign in to comment.