Skip to content

Commit

Permalink
Add GitHub Actions workflow for build and release; update .gitignore …
Browse files Browse the repository at this point in the history
…and refactor macOS setup
  • Loading branch information
waveyboym committed Nov 23, 2024
1 parent e1dec9e commit 76d7ef4
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 33 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: 'build-and-release'

on:
workflow_dispatch:
push:
branches:
- releases

defaults:
run:
working-directory: muzik-offline

jobs:
publish-tauri:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: 'macos-latest' # for Arm based macs (M1 and above).
args: '--target aarch64-apple-darwin'
- platform: 'macos-latest' # for Intel based macs.
args: '--target x86_64-apple-darwin'
- platform: 'ubuntu-22.04'
args: ''
- platform: 'windows-latest'
args: ''

runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: install dependencies (ubuntu only)
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 libasound2-dev
- name: setup node
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: 'npm' # Set this to npm, yarn or pnpm.

- name: install Rust stable
uses: dtolnay/rust-toolchain@stable # Set this to dtolnay/rust-toolchain@nightly
with:
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'

- name: install frontend dependencies
# If you don't have `beforeBuildCommand` configured you may want to build your frontend here too.
run: npm install # change this to npm or pnpm depending on which one you use.

- name: Install OpenSSL
run: |
if [[ "${{ matrix.platform }}" == "macos-latest" ]]; then
brew install openssl
elif [[ "${{ matrix.platform }}" == "ubuntu-22.04" ]]; then
sudo apt-get update && sudo apt-get install -y openssl
elif [[ "${{ matrix.platform }}" == "windows-latest" ]]; then
choco install openssl -y
fi
- name: Verify OpenSSL Installation
run: openssl version

- name: Decrypt the environment variables in src-tauri/.env.enc
run: |
openssl enc -d -aes-256-cbc -pbkdf2 -in src-tauri/.env.enc -out src-tauri/.env -pass pass:${{ secrets.ENCRYPTION_PASSWORD }}
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
releaseName: 'App v__VERSION__'
releaseBody: 'See the assets to download this version and install.'
releaseDraft: true
prerelease: false
args: ${{ matrix.args }}
21 changes: 6 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,19 @@ DISCORD_CLIENT_ID=<Your client id goes here>
```
npm run tauri dev
```
11. You can encrypt your env file with:
```
openssl enc -aes-256-cbc -salt -pbkdf2 -in src-tauri/.env -out src-tauri/.env.enc -pass pass:{pass-key}
```

## Building
1. Clone the <a href="https://github.com/muzik-apps/muzik-offline/tree/releases">releases</a> branch. It is the most stable and ready to go branch
2. Before you create a build, you will have to embed any env variables into the rust code otherwise the application will panic if you try to run it. The env variables are only meant to be used in the development cycle.
3. To embed the env variables, copy your ```DISCORD_CLIENT_ID``` from the ```.env``` file.
4. Go to <a href="https://github.com/muzik-apps/muzik-offline/blob/main-app-dev/muzik-offline/src-tauri/src/socials/discord_rpc.rs">discord_rpc.rs</a> and comment out these snippets of code:
```
3 -> use dotenv::dotenv;
4 -> use std::env;
15 -> //get client id from env variables
16 -> dotenv().ok();
17 -> let client_id = env::var("DISCORD_CLIENT_ID").expect("DISCORD_CLIENT_ID env variable not set");
```
5. In this snippet of code ```let client: DiscordIpcClient = DiscordIpcClient::new(&client_id)?;```, replace ```&client_id``` with ```"<Your client id goes here>"```
6. You can also remove the <a href="https://github.com/muzik-apps/muzik-offline/blob/main-app-dev/muzik-offline/src-tauri/Cargo.toml#L30">dotnev crate</a> by just removing that line of code.
7. If you want to go back to dev, you will have to undo all the steps above.
8. If you want to create a production build, run
4. If you want to create a production build, run
```
npm run tauri build
```
9. If you want to create a <a href="https://tauri.app/v1/guides/debugging/application#using-the-inspector-in-production">debug production build</a>(one where you have access to devtools), run
5. If you want to create a <a href="https://tauri.app/v1/guides/debugging/application#using-the-inspector-in-production">debug production build</a>(one where you have access to devtools), run
```
npm run tauri build -- --debug
```
Expand Down
1 change: 1 addition & 0 deletions muzik-offline/src-tauri/.env.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Salted__B�Tu��Lb�ne������m�`�d�>����5:�ܓ���Q�$�͜��x��ﱔQQ�B!/�oj�v6+��2���p> <;��{O/Hp2|ڿ�=Bu��T��n�.?�?jc>�z�W��=
Expand Down
3 changes: 2 additions & 1 deletion muzik-offline/src-tauri/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
.vscode/
.VSCodeCounter/
/db/
.env
.env
OUTDIR/
1 change: 0 additions & 1 deletion muzik-offline/src-tauri/2

This file was deleted.

4 changes: 3 additions & 1 deletion muzik-offline/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ tauri-plugin-http = "2"
tauri-plugin-os = "2"
printpdf = "0.7.0"
tabled = "0.16.0"
cocoa = "0.26.0"

[dependencies.uuid]
version = "1.11.0"
Expand All @@ -65,6 +64,9 @@ features = [
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
tauri-plugin-autostart = "2"

[target."cfg(target_os = \"macos\")".dependencies]
cocoa = "0.26.0"

[features]
# this feature is used for production builds or when `devPath` points to the filesystem
# DO NOT REMOVE!!
Expand Down
2 changes: 2 additions & 0 deletions muzik-offline/src-tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ fn main() {

let mut config_data = String::new();
for (key, value) in env::vars() {
if key.starts_with("DISCORD_CLIENT_ID") {
config_data.push_str(&format!("pub const {}: &str = {:?};\n", key, value));
}
}

let out_dir = match env::var("OUT_DIR") {
Expand Down
1 change: 0 additions & 1 deletion muzik-offline/src-tauri/src/app/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pub fn setup_app(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>>
mpsc::Sender<MediaControlEvent>,
mpsc::Receiver<MediaControlEvent>,
) = mpsc::channel(32);
#[cfg(target_os = "macos")]
setup_macos::setup_macos(app)?;
let shared_audio_manager = Arc::clone(&app.state::<Arc<Mutex<BackendStateManager>>>());
let shared_db_manager = Arc::clone(&app.state::<Arc<Mutex<DbManager>>>());
Expand Down
19 changes: 14 additions & 5 deletions muzik-offline/src-tauri/src/app/setup_macos.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
use tauri::{TitleBarStyle, WebviewUrl, WebviewWindowBuilder};
#![cfg(target_os = "windows")]
pub fn setup_macos(_app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[cfg(target_os = "linux")]
pub fn setup_macos(_app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[cfg(target_os = "macos")]
pub fn setup_macos(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
use tauri::{TitleBarStyle, WebviewUrl, WebviewWindowBuilder};

let win_builder =
WebviewWindowBuilder::new(app, "main", WebviewUrl::default())
.fullscreen(false)
.resizable(true)
.title("muzik-offline")
.inner_size(980, 623)
.min_inner_size(980, 623)
.inner_size(980.0, 623.0)
.min_inner_size(980.0, 623.0)
.transparent(true)
.center();

Expand Down Expand Up @@ -35,7 +46,5 @@ pub fn setup_macos(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error
ns_window.setBackgroundColor_(bg_color);
}
}

Ok(())

}
2 changes: 0 additions & 2 deletions muzik-offline/src-tauri/src/socials/discord_rpc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use discord_rich_presence::{activity, DiscordIpc, DiscordIpcClient};
use dotenv::dotenv;
use std::env;
use std::sync::Mutex;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use tauri::State;
Expand Down
2 changes: 1 addition & 1 deletion muzik-offline/src/interface/App/MiniPlayer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NullCoverNull, Pause, Play, SkipBack, SkipFwd, VolumeMax, VolumeMin } from "@assets/icons";
import { usePlayerStore, useSavedObjectStore, usePlayingPositionSec, usePlayingPosition } from "@store/index";
import { invoke } from "@tauri-apps/api/core";
import { getCoverURL, getNullRandomCover, getRandomCover, secondsToTimeFormat } from "@utils/index";
import { getCoverURL, getNullRandomCover, secondsToTimeFormat } from "@utils/index";
import { changeVolumeLevel, changeSeekerPosition, changeVolumeLevelBtnPress, dragSeeker, reconfigurePlayer_AtEndOfSong, pauseSong, playSong, changeSeekerPositionBtnPress, playNextSong, playPreviousSong, setVolumeLevel } from "@utils/playerControl";
import { motion } from "framer-motion";
import { FunctionComponent, useRef, useEffect, useState } from "react";
Expand Down
6 changes: 3 additions & 3 deletions muzik-offline/src/interface/layouts/ExportSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ const ExportSettings: FunctionComponent<ExportSettingsProps> = (props: ExportSet
local_songs_db.songs.where("title").startsWithIgnoreCase(e.target.value).toArray().then((value) => setSongs(value));
}

function clearSearch(){
/*function clearSearch(){
setSearch("");
local_songs_db.songs.toArray().then((value) => setSongs(value));
}
}*/

function exportSongs(){
const uuids = songs.filter((value) => selected.has(value.id)).map((value) => value.uuid);
Expand Down Expand Up @@ -54,7 +54,7 @@ const ExportSettings: FunctionComponent<ExportSettingsProps> = (props: ExportSet
</motion.div>
</div>
<div className="sub_heading">
<CheckboxComponent isChecked={songs.length === selected.size} CheckToggle={configureSelectedState} />
<CheckboxComponent isChecked={songs.length === 0 ? false: (songs.length === selected.size)} CheckToggle={configureSelectedState} />
<h3>{selected.size} {selected.size === 1 ? "song is" : "songs are"} selected</h3>
</div>
<div className="ExportSettings_container" ref={allSongsRef}>
Expand Down
6 changes: 3 additions & 3 deletions muzik-offline/src/interface/styles/pages/AllArtists.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@

.drag-drop-border{
width: calc(100vw - 227px);
max-height: calc(100% - 40px);
height: fit-content;
height: calc(100% - 130px);
display: flex;
flex-direction: column;
justify-content: center;
Expand Down Expand Up @@ -143,7 +142,8 @@

.AllArtists_container{
min-width: 859px;
height: calc(100% - 40px);
max-height: calc(100% - 40px);
height: fit-content;
width: calc(100vw - var(--var-right-side-bar-width-expanded));
display: grid;
grid-template-columns: repeat(auto-fill, 150px);
Expand Down

0 comments on commit 76d7ef4

Please sign in to comment.