Skip to content

Commit

Permalink
Make production ready, add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
movabo committed Mar 11, 2024
1 parent 813408a commit 58ee564
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# can also be something like /api/v2/
# can also be something like /api/v2/, make sure it starts with the protocol or with a leading directory-/
VITE_API_BASE_URL=http://localhost:8000/api/
VITE_API_WEBSOCKET_BASE_URL=ws://localhost:8000/api/
3 changes: 3 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# For more information on how to properly set the env-variables, see .env
VITE_API_BASE_URL=/api/
VITE_API_WEBSOCKET_BASE_URL=/api/
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Create release
on:
push:
tags:
- v*
permissions:
contents: write
jobs:
build_and_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up npm
uses: actions/setup-node@v4
- name: Install
run: npm install
- name: Build
run: npm run build-only
- name: Zip
run: zip -r dist.zip dist
- name: Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: dist.zip
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "soundboard",
"version": "0.0.0",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
Expand All @@ -11,7 +11,7 @@
"type-check": "vue-tsc --build --force",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"format": "prettier --write src/",
"generate": "openapi-typescript http://127.0.0.1:8000/openapi.json -o ./src/lib/api/types.d.ts"
"generate": "openapi-typescript http://127.0.0.1:8000/api/openapi.json -o ./src/lib/api/types.ts"
},
"dependencies": {
"daisyui": "^4.7.2",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import createClient from 'openapi-fetch'
import { type paths } from '@/lib/api/types.d'
import { type paths } from '@/lib/api/types'

const apiBaseUrl: string = import.meta.env.VITE_API_BASE_URL
const baseUrl = apiBaseUrl.endsWith("/") ? apiBaseUrl.substring(0, apiBaseUrl.length - 1) : apiBaseUrl;
Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion src/lib/playerEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ class PlayerEvents {

static create(wsBaseUrl: string | null = null) {
if (!wsBaseUrl) {
wsBaseUrl = `${import.meta.env.VITE_API_WEBSOCKET_BASE_URL}events`
let base: string = import.meta.env.VITE_API_WEBSOCKET_BASE_URL
if (!base.startsWith("ws")) {
base = window.location.origin.replace("http", "ws") + base;
}
wsBaseUrl = `${base}events`
}
return new PlayerEvents(wsBaseUrl)
}
Expand Down

0 comments on commit 58ee564

Please sign in to comment.