Skip to content

Commit

Permalink
feat: revamp build system to allow auto update and CI build of App (#3)
Browse files Browse the repository at this point in the history
setup build pipeline, correct frontend looking at wrong .env file.
cleanup build process
  • Loading branch information
RakuJa authored Nov 13, 2024
1 parent f030abe commit ba9bf96
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 17 deletions.
5 changes: 3 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# BE Env data
DATABASE_URL=sqlite://../database.db
DATABASE_URL=sqlite://database.db
SERVICE_STARTUP_STATE=Persistent
N_OF_SERVICE_WORKERS=1
SERVICE_IP=127.0.0.1
SERVICE_PORT=25566

# FE Env data
API_URL='http://127.0.0.1:25566'
REPO_URL='RakuJa/BYBE-portable'
# Avoid frontend opening browser on build/dev
AUTO_OPEN_BROWSER=true
AUTO_OPEN_BROWSER=false
41 changes: 37 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ on:
branches:
- release

env:
DATABASE_URL: "sqlite://database.db"
# This workflow will trigger on each push to the `release` branch to create or update a GitHub release, build your app, and upload the artifacts to the release.

jobs:
publish-tauri:
permissions:
Expand All @@ -27,6 +28,13 @@ jobs:
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: setup python
uses: actions/setup-python@v5
with:
python-version: '3.13'
check-latest: 'true'

- name: setup node
uses: actions/setup-node@v4
Expand All @@ -43,18 +51,43 @@ jobs:
if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above.
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf xapp
- name: Remove Frontend default .env
uses: JesseTG/[email protected]
with:
path: /BYBE-frontend/.env

- name: Copy BYBE-Portable .env to Frontend (Windows)
if: matrix.platform == 'windows-latest'
run:
Copy-Item -Path .\.env -Destination .\BYBE-frontend\.env

- name: Copy BYBE-Portable .env to Frontend (Linux/Macos)
if: matrix.platform != 'windows-latest'
run:
cp .env BYBE-frontend/.env

- name: install Cargo make
uses: davidB/rust-cargo-make@v1

- name: install frontend dependencies
run: npm --prefix ./BYBE-frontend install
working-directory: BYBE-frontend
run: npm install

- name: build BYBE-Backend downloading necessary data
run: cargo make prebuild

- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
NO_STRIP: true
with:
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
releaseName: 'v__VERSION__'
releaseBody: 'See the assets to download this version and install. \n for more info on changes look at https://github.com/RakuJa/BYBE/releases and https://github.com/theasel/BYBE-frontend/releases'
releaseBody: 'For more info on changes look at https://github.com/RakuJa/BYBE/releases and https://github.com/theasel/BYBE-frontend/releases'
releaseDraft: true
prerelease: false
args: ${{ matrix.args }}
2 changes: 1 addition & 1 deletion BYBE-backend
2 changes: 1 addition & 1 deletion BYBE-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
tauri-build = { version = "2.0.3", features = [] }

[dependencies]
tauri = { version = "2.1.0", features = [] }
tauri = { version = "2.1.1", features = [] }
tauri-plugin-devtools = "2.0.0"
tauri-plugin-log = "2.0.2"
# Both dialog and updater are used for handling automatic updates
Expand Down
6 changes: 3 additions & 3 deletions BYBE-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn run() {
// Get Environmental Variables
let env_path = app
.path()
.resolve("data/.env", BaseDirectory::Resource)
.resolve(".env", BaseDirectory::Resource)
.expect("Should find BYBE env variables inside resources")
.into_os_string()
.into_string()
Expand All @@ -40,7 +40,7 @@ pub fn run() {
pub fn get_db_path(app: &mut App) -> anyhow::Result<String> {
let db_canonical_path = dunce::canonicalize(
app.path()
.resolve("data/database.db", BaseDirectory::Resource)?,
.resolve("database.db", BaseDirectory::Resource)?,
)?
.into_os_string()
.into_string();
Expand All @@ -55,7 +55,7 @@ pub fn get_db_path(app: &mut App) -> anyhow::Result<String> {
pub fn get_db_path(app: &mut App) -> anyhow::Result<String> {
let db_path = app
.path()
.resolve("data/database.db", BaseDirectory::Resource)?
.resolve("database.db", BaseDirectory::Resource)?
.into_os_string()
.into_string();
if let Ok(x) = db_path {
Expand Down
14 changes: 8 additions & 6 deletions BYBE-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"$schema": "https://schema.tauri.app/config/2.0.0-rc",
"productName": "BYBE-Portable",
"version": "0.1.0",
"version": "2.3.0",
"identifier": "com.danielegiachetto.bybe",
"build": {
"frontendDist": "../BYBE-frontend/dist/spa",
"devUrl": "http://localhost:9000",
"beforeDevCommand": "cd ../BYBE-frontend && npm install && npm run dev",
"beforeBuildCommand": "cd ../BYBE-frontend && npm install && npm run build"
"beforeDevCommand": "npm install && npm update && npm run dev",
"beforeBuildCommand": "npm install && npm update && npm run build"
},
"bundle": {
"createUpdaterArtifacts": true,
Expand All @@ -20,9 +20,10 @@
"icons/icon.icns",
"icons/icon.ico"
],
"resources": [
"data/*"
]
"resources": {
"data/.env": ".env",
"../BYBE-backend/database.db": "database.db"
}
},
"app": {
"security": {
Expand Down Expand Up @@ -50,6 +51,7 @@
},
"permissions": [
"updater:default",
"window:all",
{
"identifier": "http:default",
"allow": [
Expand Down
40 changes: 40 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[tasks.clean-app]
run_task = [
{name = ["clean-backend", "clean-tauri"]}
]

[tasks.clean-backend]
cwd = "./BYBE-backend/"
command = "cargo"
args = ["clean"]

[tasks.clean-tauri]
cwd = "./BYBE-tauri/"
command = "cargo"
args = ["clean"]

[tasks.prebuild]
cwd = "./BYBE-backend/"
command = "cargo"
args = ["make", "bybe-release"]


[tasks.build-multiplat-app]
install_crate = "tauri-cli"
command = "cargo"
args = ["tauri", "build"]
dependencies = ["clean-app", "prebuild"]

[tasks.build-linux-app]
install_crate = "tauri-cli"
command = "cargo"
args = ["tauri", "build"]
dependencies = ["clean-app", "prebuild"]
env = { NO_STRIP=true }


[tasks.build-app]
run_task = [
{ name = "build-multiplat-app", condition = { platforms = ["windows", "mac"]} },
{ name = "build-linux-app", condition = { platforms = ["linux"]} },
]

0 comments on commit ba9bf96

Please sign in to comment.