Skip to content

Commit edf8b7a

Browse files
refac: add reusable worfklow
1 parent ac4e312 commit edf8b7a

4 files changed

Lines changed: 177 additions & 312 deletions

File tree

.github/workflows/app-build-debug-artifacts.yml

Lines changed: 15 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -13,104 +13,25 @@ jobs:
1313
matrix:
1414
include:
1515
- platform: 'macos-latest' # for Arm based macs (M1 and above).
16-
args: '--target aarch64-apple-darwin --debug'
16+
args: '--target aarch64-apple-darwin'
1717
- platform: 'macos-latest' # for Intel based macs.
18-
args: '--target x86_64-apple-darwin --debug'
18+
args: '--target x86_64-apple-darwin'
1919
- platform: 'ubuntu-22.04'
20-
args: '--debug'
20+
args: ''
2121
- platform: 'ubuntu-22.04-arm'
22-
args: '--debug'
22+
args: ''
2323
- platform: 'windows-2022'
24-
args: '--debug'
24+
args: ''
2525
- platform: 'windows-11-arm'
26-
args: '--debug'
26+
args: ''
2727
- platform: 'ubuntu-22.04'
28-
args: '--apk --split-per-abi --target aarch64 --target armv7 --debug'
28+
args: '--apk --split-per-abi --target aarch64 --target armv7'
2929
mobile: 'android'
30-
runs-on: ${{ matrix.platform }}
31-
steps:
32-
# ------------ Git Clone ----------------
33-
- uses: actions/checkout@v6
34-
35-
# ------------ Desktop OS ----------------
36-
- name: Free up disk space on Linux runners
37-
uses: mathio/gha-cleanup@v1
38-
if: startsWith(matrix.platform, 'ubuntu')
39-
with:
40-
remove-browsers: true
41-
verbose: true
42-
- name: Fix Android Directory Permissions
43-
if: startsWith(matrix.platform, 'ubuntu')
44-
run: |
45-
sudo mkdir -p /usr/local/lib/android
46-
sudo chown -R $USER:$USER /usr/local/lib/android
47-
- name: install dependencies (ubuntu only)
48-
if: startsWith(matrix.platform, 'ubuntu')
49-
run: |
50-
sudo apt-get update
51-
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev xdg-utils
52-
53-
# ------------- Node -------------
54-
- name: setup node
55-
uses: actions/setup-node@v4
56-
with:
57-
node-version: lts/*
58-
- name: setup bun
59-
uses: oven-sh/setup-bun@v2
60-
- name: install frontend dependencies
61-
run: bun i
62-
63-
# ------------- Rust -------------
64-
- name: install Rust stable (desktop)
65-
if: matrix.mobile == ''
66-
uses: dtolnay/rust-toolchain@stable
67-
with:
68-
targets: aarch64-apple-darwin,x86_64-apple-darwin
69-
- name: install Rust stable (android)
70-
if: matrix.mobile == 'android'
71-
uses: dtolnay/rust-toolchain@stable
72-
with:
73-
targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android
74-
- uses: Swatinem/rust-cache@v2
75-
with:
76-
cache-on-failure: true
77-
workspaces: apps/app/src-tauri/ -> target
78-
79-
# ------------- Android -------------
80-
- name: Set up JDK
81-
if: matrix.mobile == 'android'
82-
uses: actions/setup-java@v5
83-
with:
84-
java-version: '17' # Maybe 17
85-
distribution: 'temurin'
86-
- name: Setup Android SDK
87-
if: matrix.mobile == 'android'
88-
uses: android-actions/setup-android@v3
89-
- name: Setup Android NDK
90-
if: matrix.mobile == 'android'
91-
uses: nttld/setup-ndk@v1
92-
id: setup-ndk
93-
with:
94-
ndk-version: r29
95-
link-to-sdk: true
96-
- name: setup Android signing
97-
if: matrix.mobile == 'android'
98-
run: |
99-
cd apps/app/src-tauri/gen/android
100-
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" > keystore.properties
101-
echo "password=${{ secrets.ANDROID_KEY_PASSWORD }}" >> keystore.properties
102-
base64 -d <<< "${{ secrets.ANDROID_KEY_BASE64 }}" > $RUNNER_TEMP/keystore.jks
103-
echo "storeFile=$RUNNER_TEMP/keystore.jks" >> keystore.properties
104-
105-
# ---------------- Tauri -----------------
106-
- name: Build Tauri Project
107-
uses: tauri-apps/tauri-action@8236c82510173ef930d644f38790c4cf3fd43cf2
108-
env:
109-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110-
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
111-
with:
112-
projectPath: 'apps/app'
113-
uploadWorkflowArtifacts: true
114-
workflowArtifactNamePattern: '[name]-v[version]-[platform]-[arch]-[mode][ext]'
115-
args: ${{ matrix.args }}
116-
mobile: ${{ matrix.mobile }}
30+
uses: ./.github/workflows/app-build.yml
31+
with:
32+
build-mode: 'debug'
33+
publish: false
34+
platform: ${{ matrix.platform }}
35+
args: ${{ matrix.args }}
36+
mobile: ${{ matrix.mobile || '' }}
37+
secrets: inherit

.github/workflows/app-build-release-artifacts.yml

Lines changed: 8 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -40,110 +40,11 @@ jobs:
4040
- platform: 'ubuntu-22.04'
4141
args: '--apk --split-per-abi --target aarch64 --target armv7'
4242
mobile: 'android'
43-
runs-on: ${{ matrix.platform }}
44-
steps:
45-
- uses: actions/checkout@v6
46-
47-
# ------------- Node & Frontend Cache -------------
48-
- name: setup node
49-
uses: actions/setup-node@v4
50-
with:
51-
node-version: lts/*
52-
53-
- name: setup bun
54-
uses: oven-sh/setup-bun@v2
55-
56-
# NEW: Cache Bun dependencies
57-
- name: Cache Bun dependencies
58-
uses: actions/cache@v4
59-
with:
60-
path: ~/.bun/install/cache
61-
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
62-
restore-keys: |
63-
${{ runner.os }}-bun-
64-
65-
# Case 1: Run bun for everything EXCEPT Windows ARM
66-
- name: install frontend dependencies
67-
run: bun i
68-
69-
# ------------- Rust & Cargo Cache -------------
70-
- name: install Rust stable (desktop)
71-
if: matrix.mobile == ''
72-
uses: dtolnay/rust-toolchain@stable
73-
with:
74-
targets: aarch64-apple-darwin,x86_64-apple-darwin
75-
76-
- name: install Rust stable (android)
77-
if: matrix.mobile == 'android'
78-
uses: dtolnay/rust-toolchain@stable
79-
with:
80-
targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android
81-
82-
# MODIFIED: Fixed workspaces syntax and ensured shared key matches matrix
83-
- uses: Swatinem/rust-cache@v2
84-
with:
85-
cache-on-failure: true
86-
# Point this to the folder containing Cargo.toml.
87-
# The action automatically handles the 'target' directory.
88-
workspaces: apps/app/src-tauri
89-
# Adding a key based on the job matrix helps prevent cache conflicts between platforms
90-
key: ${{ matrix.platform }}-${{ matrix.args }}
91-
92-
# ------------- Android -------------
93-
- name: Set up JDK
94-
if: matrix.mobile == 'android'
95-
uses: actions/setup-java@v5
96-
with:
97-
java-version: '17'
98-
distribution: 'temurin'
99-
100-
# NEW: Cache Gradle for Android
101-
- name: Cache Gradle
102-
if: matrix.mobile == 'android'
103-
uses: actions/cache@v4
104-
with:
105-
path: |
106-
~/.gradle/caches
107-
~/.gradle/wrapper
108-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
109-
restore-keys: |
110-
${{ runner.os }}-gradle-
111-
112-
- name: Setup Android SDK
113-
if: matrix.mobile == 'android'
114-
uses: android-actions/setup-android@v3
115-
- name: Setup Android NDK
116-
if: matrix.mobile == 'android'
117-
uses: nttld/setup-ndk@v1
118-
id: setup-ndk
119-
with:
120-
ndk-version: r29
121-
link-to-sdk: true
122-
- name: setup Android signing
123-
if: matrix.mobile == 'android'
124-
run: |
125-
cd apps/app/src-tauri/gen/android
126-
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" > keystore.properties
127-
echo "password=${{ secrets.ANDROID_KEY_PASSWORD }}" >> keystore.properties
128-
base64 -d <<< "${{ secrets.ANDROID_KEY_BASE64 }}" > $RUNNER_TEMP/keystore.jks
129-
echo "storeFile=$RUNNER_TEMP/keystore.jks" >> keystore.properties
130-
131-
# ------------ Desktop OS ----------------
132-
- name: install dependencies (ubuntu only)
133-
if: startsWith(matrix.platform, 'ubuntu')
134-
run: |
135-
sudo apt-get update
136-
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev xdg-utils
137-
138-
# ---------------- Tauri -----------------
139-
- name: Build Tauri Project
140-
uses: tauri-apps/tauri-action@8236c82510173ef930d644f38790c4cf3fd43cf2
141-
env:
142-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143-
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
144-
with:
145-
projectPath: 'apps/app'
146-
uploadWorkflowArtifacts: true
147-
workflowArtifactNamePattern: '[name]-v[version]-[platform]-[arch]-[mode][ext]'
148-
args: ${{ matrix.args }}
149-
mobile: ${{ matrix.mobile }}
43+
uses: ./.github/workflows/app-build.yml
44+
with:
45+
build-mode: 'release'
46+
publish: false
47+
platform: ${{ matrix.platform }}
48+
args: ${{ matrix.args }}
49+
mobile: ${{ matrix.mobile || '' }}
50+
secrets: inherit

.github/workflows/app-build-release-publish.yml

Lines changed: 8 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -39,114 +39,11 @@ jobs:
3939
- platform: 'ubuntu-22.04'
4040
args: '--apk --split-per-abi --target aarch64 --target armv7'
4141
mobile: 'android'
42-
runs-on: ${{ matrix.platform }}
43-
steps:
44-
- uses: actions/checkout@v6
45-
46-
# ------------- Node & Frontend Cache -------------
47-
- name: setup node
48-
uses: actions/setup-node@v4
49-
with:
50-
node-version: lts/*
51-
52-
- name: setup bun
53-
uses: oven-sh/setup-bun@v2
54-
55-
# NEW: Cache Bun dependencies
56-
- name: Cache Bun dependencies
57-
uses: actions/cache@v4
58-
with:
59-
path: ~/.bun/install/cache
60-
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
61-
restore-keys: |
62-
${{ runner.os }}-bun-
63-
64-
# Case 1: Run bun for everything EXCEPT Windows ARM
65-
- name: install frontend dependencies
66-
run: bun i
67-
68-
# ------------- Rust & Cargo Cache -------------
69-
- name: install Rust stable (desktop)
70-
if: matrix.mobile == ''
71-
uses: dtolnay/rust-toolchain@stable
72-
with:
73-
targets: aarch64-apple-darwin,x86_64-apple-darwin
74-
75-
- name: install Rust stable (android)
76-
if: matrix.mobile == 'android'
77-
uses: dtolnay/rust-toolchain@stable
78-
with:
79-
targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android
80-
81-
# MODIFIED: Fixed workspaces syntax and ensured shared key matches matrix
82-
- uses: Swatinem/rust-cache@v2
83-
with:
84-
cache-on-failure: true
85-
# Point this to the folder containing Cargo.toml.
86-
# The action automatically handles the 'target' directory.
87-
workspaces: apps/app/src-tauri
88-
# Adding a key based on the job matrix helps prevent cache conflicts between platforms
89-
key: ${{ matrix.platform }}-${{ matrix.args }}
90-
91-
# ------------- Android -------------
92-
- name: Set up JDK
93-
if: matrix.mobile == 'android'
94-
uses: actions/setup-java@v5
95-
with:
96-
java-version: '17'
97-
distribution: 'temurin'
98-
99-
# NEW: Cache Gradle for Android
100-
- name: Cache Gradle
101-
if: matrix.mobile == 'android'
102-
uses: actions/cache@v4
103-
with:
104-
path: |
105-
~/.gradle/caches
106-
~/.gradle/wrapper
107-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
108-
restore-keys: |
109-
${{ runner.os }}-gradle-
110-
111-
- name: Setup Android SDK
112-
if: matrix.mobile == 'android'
113-
uses: android-actions/setup-android@v3
114-
- name: Setup Android NDK
115-
if: matrix.mobile == 'android'
116-
uses: nttld/setup-ndk@v1
117-
id: setup-ndk
118-
with:
119-
ndk-version: r29
120-
link-to-sdk: true
121-
- name: setup Android signing
122-
if: matrix.mobile == 'android'
123-
run: |
124-
cd apps/app/src-tauri/gen/android
125-
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" > keystore.properties
126-
echo "password=${{ secrets.ANDROID_KEY_PASSWORD }}" >> keystore.properties
127-
base64 -d <<< "${{ secrets.ANDROID_KEY_BASE64 }}" > $RUNNER_TEMP/keystore.jks
128-
echo "storeFile=$RUNNER_TEMP/keystore.jks" >> keystore.properties
129-
130-
# ------------ Desktop OS ----------------
131-
- name: install dependencies (ubuntu only)
132-
if: startsWith(matrix.platform, 'ubuntu')
133-
run: |
134-
sudo apt-get update
135-
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev xdg-utils
136-
137-
# ---------------- Tauri -----------------
138-
- name: Build Tauri Project
139-
uses: tauri-apps/tauri-action@8236c82510173ef930d644f38790c4cf3fd43cf2
140-
env:
141-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
142-
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
143-
with:
144-
projectPath: 'apps/app'
145-
tagName: v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
146-
releaseName: 'Cherit v__VERSION__'
147-
releaseAssetNamePattern: '[name]-[platform]-[arch][ext]'
148-
releaseBody: 'Download from Website : [Download](https://keshav.is-a.dev/Cherit/download/)'
149-
releaseDraft: true
150-
prerelease: false
151-
args: ${{ matrix.args }}
152-
mobile: ${{ matrix.mobile }}
42+
uses: ./.github/workflows/app-build.yml
43+
with:
44+
build-mode: 'release'
45+
publish: true
46+
platform: ${{ matrix.platform }}
47+
args: ${{ matrix.args }}
48+
mobile: ${{ matrix.mobile || '' }}
49+
secrets: inherit

0 commit comments

Comments
 (0)