Skip to content

Commit 91ffc8a

Browse files
CopilotHONGJICAI
andauthored
Add build and release GitHub Actions pipelines (#1)
* Initial plan * Add build and release GitHub Actions workflows Co-authored-by: HONGJICAI <14875213+HONGJICAI@users.noreply.github.com> * Add permissions block to build.yml to fix CodeQL security alert Co-authored-by: HONGJICAI <14875213+HONGJICAI@users.noreply.github.com> * Fix actions/download-artifact vulnerability by upgrading to v4.1.8 Co-authored-by: HONGJICAI <14875213+HONGJICAI@users.noreply.github.com> * Change workflow branch from main to master Co-authored-by: HONGJICAI <14875213+HONGJICAI@users.noreply.github.com> * Remove unused carbon-preprocess-svelte import to fix build error Co-authored-by: HONGJICAI <14875213+HONGJICAI@users.noreply.github.com> * Fix build error: use index.html as fallback instead of app.html Co-authored-by: HONGJICAI <14875213+HONGJICAI@users.noreply.github.com> * Fix gradlew permission denied error by adding chmod +x Co-authored-by: HONGJICAI <14875213+HONGJICAI@users.noreply.github.com> * Upgrade JDK from 17 to 21 to match Capacitor requirements Co-authored-by: HONGJICAI <14875213+HONGJICAI@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: HONGJICAI <14875213+HONGJICAI@users.noreply.github.com>
1 parent ea8d649 commit 91ffc8a

File tree

4 files changed

+131
-14
lines changed

4 files changed

+131
-14
lines changed

.github/workflows/build.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
workflow_dispatch:
11+
workflow_call:
12+
13+
env:
14+
FRP_VERSION: "0.66.0"
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Set up JDK 21
28+
uses: actions/setup-java@v4
29+
with:
30+
java-version: '21'
31+
distribution: 'temurin'
32+
33+
- name: Set up Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: '20'
37+
cache: 'npm'
38+
cache-dependency-path: my-app/package-lock.json
39+
40+
- name: Install npm dependencies
41+
working-directory: my-app
42+
run: npm ci
43+
44+
- name: Download frpc binaries
45+
run: |
46+
# Create directories if they don't exist
47+
mkdir -p my-app/android/app/src/main/jniLibs/arm64-v8a
48+
mkdir -p my-app/android/app/src/main/jniLibs/armeabi-v7a
49+
mkdir -p my-app/android/app/src/main/jniLibs/x86_64
50+
51+
# Download and extract frpc for arm64-v8a (Android ARM64)
52+
curl -sL "https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_android_arm64.tar.gz" -o frp_android_arm64.tar.gz
53+
tar -xzf frp_android_arm64.tar.gz
54+
cp "frp_${FRP_VERSION}_android_arm64/frpc" my-app/android/app/src/main/jniLibs/arm64-v8a/libfrpc.so
55+
rm -rf frp_android_arm64.tar.gz "frp_${FRP_VERSION}_android_arm64"
56+
57+
# Download and extract frpc for armeabi-v7a (Linux ARM 32-bit)
58+
curl -sL "https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_arm.tar.gz" -o frp_linux_arm.tar.gz
59+
tar -xzf frp_linux_arm.tar.gz
60+
cp "frp_${FRP_VERSION}_linux_arm/frpc" my-app/android/app/src/main/jniLibs/armeabi-v7a/libfrpc.so
61+
rm -rf frp_linux_arm.tar.gz "frp_${FRP_VERSION}_linux_arm"
62+
63+
# Download and extract frpc for x86_64 (Linux x86_64)
64+
curl -sL "https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_amd64.tar.gz" -o frp_linux_amd64.tar.gz
65+
tar -xzf frp_linux_amd64.tar.gz
66+
cp "frp_${FRP_VERSION}_linux_amd64/frpc" my-app/android/app/src/main/jniLibs/x86_64/libfrpc.so
67+
rm -rf frp_linux_amd64.tar.gz "frp_${FRP_VERSION}_linux_amd64"
68+
69+
# Verify files were copied
70+
ls -la my-app/android/app/src/main/jniLibs/*/
71+
72+
- name: Build frontend
73+
working-directory: my-app
74+
run: npm run build
75+
76+
- name: Sync Capacitor
77+
working-directory: my-app
78+
run: npx cap sync android
79+
80+
- name: Build Android APK
81+
working-directory: my-app/android
82+
run: |
83+
chmod +x ./gradlew
84+
./gradlew assembleRelease
85+
86+
- name: Upload APK artifacts
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: apk-release
90+
path: my-app/android/app/build/outputs/apk/release/*.apk
91+
if-no-files-found: error

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
release:
8+
types: [created]
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
build:
16+
uses: ./.github/workflows/build.yml
17+
18+
release:
19+
needs: build
20+
runs-on: ubuntu-latest
21+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
22+
23+
steps:
24+
- name: Download APK artifacts
25+
uses: actions/download-artifact@v4.1.8
26+
with:
27+
name: apk-release
28+
path: ./apk
29+
30+
- name: List downloaded files
31+
run: ls -la ./apk/
32+
33+
- name: Upload Release Assets
34+
uses: softprops/action-gh-release@v2
35+
with:
36+
files: ./apk/*.apk
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

my-app/svelte.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import adapter from '@sveltejs/adapter-static';
22
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
3-
import { optimizeImports } from 'carbon-preprocess-svelte';
43

54
/** @type {import('@sveltejs/kit').Config} */
65
const config = {
@@ -13,7 +12,7 @@ const config = {
1312
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
1413
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
1514
adapter: adapter({
16-
fallback: 'app.html'
15+
fallback: 'index.html'
1716
})
1817
}
1918
};

my-app/vite.config.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
import { sveltekit } from '@sveltejs/kit/vite';
22
import { defineConfig } from 'vite';
3-
import { copyFileSync } from 'fs';
43

54
export default defineConfig({
6-
plugins: [
7-
sveltekit() /* other plugins */,
8-
// copy app.html to index.html in npm build
9-
{
10-
name: 'copy-app-html',
11-
apply: 'build',
12-
closeBundle: async () => {
13-
copyFileSync('build/app.html', 'build/index.html');
14-
}
15-
}
16-
]
5+
plugins: [sveltekit()]
176
});

0 commit comments

Comments
 (0)