Skip to content

Commit

Permalink
release: release & add generate release data and openapi generation(b…
Browse files Browse the repository at this point in the history
…ackend/front) scripts
  • Loading branch information
AntonioMrtz authored Nov 10, 2024
1 parent f9ea445 commit cfe97f2
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ Electron/.erb/dll/**
# release
Electron/release/build/**
Electron/release/app/dist/**
release_temp/


#python
Expand Down
4 changes: 2 additions & 2 deletions Electron/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"format:check": "prettier src/ --check --ignore-path .prettierignore",
"package": "ts-node ./.erb/scripts/clean.js dist && npm run build && electron-builder build --publish never",
"package:win": "ts-node ./.erb/scripts/clean.js dist && npm run build && electron-builder build --publish never --win",
"package:linux:deb": "ts-node ./.erb/scripts/clean.js dist && npm run build && electron-builder build --publish never --linux deb",
"package:linux:appimage": "ts-node ./.erb/scripts/clean.js dist && npm run build && electron-builder build --publish never --linux appimage",
"rebuild": "electron-rebuild --parallel --types prod,dev,optional --module-dir release/app",
"start": "ts-node ./.erb/scripts/check-port-in-use.js && npm run start:renderer",
Expand Down
2 changes: 1 addition & 1 deletion Electron/release/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Electron/release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spotify-electron",
"version": "2.0.0",
"version": "2.0.1",
"description": "Spotify Electron is a cross-platform music streaming desktop app made with Electron-React frontend and Python-FastAPI-AWS Backend. The goal is to reproduce the original Spotify functionality while adding new ones like uploading songs",
"author": {
"name": "Antonio Martinez Fernandez",
Expand Down
2 changes: 1 addition & 1 deletion Electron/src/swagger/api/core/OpenAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type OpenAPIConfig = {

export const OpenAPI: OpenAPIConfig = {
BASE: '',
VERSION: '2.0.0',
VERSION: '2.0.1',
WITH_CREDENTIALS: false,
CREDENTIALS: 'include',
TOKEN: undefined,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions docs/developer/frontend/Package-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,3 @@ An `.exe` will be generated
```console
npm run package:win
```

##### Deb (not working)

```console
npm run package:linux:deb
```
2 changes: 1 addition & 1 deletion docs/developer/utils/OpenAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ OpenAPI is a standard for describing and documenting APIs. It uses schemas to de
## Generate OpenAPI Client (Frontend)

1. Go to `Electron/`
2. Install app dependencies with `npm run build && npm install`
2. Install app dependencies with `npm install && npm run build`
3. Run `npm run generate-openapi-client` for generating code for backend requests based on its endpoints.
64 changes: 64 additions & 0 deletions tools/generate_release_data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

# Exit on error for most commands but allow non-critical errors to be skipped
set -e
set -o pipefail # Capture errors from pipes

# =============================
# Create release_temp directory
# =============================
cd ../
mkdir -p release_temp/

# =============================
# Copy release assets
# =============================
echo "Copying release assets..."

cp docs/assets/logo.png release_temp/logo.png
echo "Copied logo.png"

cp docs/assets/logo.png release_temp/spotify-electron.desktop
echo "Copied spotify-electron.desktop"

# =============================
# Backend OPENAPI generation and Frontend OPENAPI client update
# =============================
echo "Starting Backend OPENAPI generation and Frontend OpenAPI client update..."

cd tools/
./update_openapi.sh

echo "Virtual environment deactivated"

# =============================
# FRONTEND app client
# =============================
echo "Starting Frontend app client update..."

# Navigate to the Electron directory
cd ../Electron/

# Install dependencies, build, and generate OpenAPI client
npm install
echo "npm install completed"

npm run build
echo "Frontend build completed"

# =============================
# Package the app for Linux and Windows
# =============================
npm run package:linux:appimage
mv release/build/SpotifyElectron.AppImage ../release_temp/
echo "Linux AppImage packaged and moved"

npm run package:win
mv release/build/SpotifyElectron.exe ../release_temp/
echo "Windows executable packaged and moved"

# =============================
# Finish
# =============================
echo "Release process completed successfully."
exit 0
40 changes: 40 additions & 0 deletions tools/update_openapi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
cd ../


cd Backend/

# Activate the virtual environment
source venv/bin/activate
echo "Virtual environment activated"

# Check if mongomock is installed
if pip show mongomock > /dev/null 2>&1; then
echo "mongomock is installed"
else
echo "mongomock is not installed"
exit 1
fi

# Set the environment variable and execute the Python command
echo "Generating OpenAPI schema with timeout..."
timeout 15s env ENV_VALUE="TEST" python -m app.tools.generate_openapi || {
echo "Error: Python generate_openapi script timed out";
exit 1
}

echo "OpenAPI schema generation completed"

# Deactivate the virtual environment
deactivate
echo "Virtual environment deactivated"

# Navigate to the Electron directory and run OpenAPI client generation
cd ../Electron/

npm install
npm build
# Generate the OpenAPI client
echo "Generating OpenAPI client..."
npm run generate-openapi-client || { echo "Error: OpenAPI client generation failed"; exit 1; }
echo "OpenAPI client generation completed"

0 comments on commit cfe97f2

Please sign in to comment.