generated from Chocobois/choco-jam-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b540e3d
Showing
56 changed files
with
1,961 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Install dependencies | ||
run: npm install && sudo apt install genisoimage | ||
|
||
- name: Load game.config.json | ||
uses: antifree/[email protected] | ||
with: | ||
filename: 'game.config.json' | ||
prefix: game | ||
|
||
- name: Build project | ||
run: npm run build | ||
|
||
- name: Load meta.json | ||
uses: antifree/[email protected] | ||
with: | ||
filename: 'dist/meta.json' | ||
prefix: meta | ||
|
||
- name: Deploy to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./dist/web | ||
|
||
- name: Create release | ||
uses: "marvinpinto/action-automatic-releases@latest" | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
automatic_release_tag: "latest" | ||
prerelease: false | ||
title: "${{ env.game_title }} latest build" | ||
files: | | ||
./dist/${{ env.meta_title }}-web.zip | ||
./dist/${{ env.meta_title }}-win.zip | ||
./dist/${{ env.meta_title }}-mac.dmg | ||
./dist/${{ env.meta_title }}-linux.zip | ||
- name: Upload to Itch | ||
if: ${{env.game_itch_upload == 'true'}} | ||
uses: Ayowel/[email protected] | ||
with: | ||
butler_key: ${{ secrets.BUTLER_CREDENTIALS }} | ||
itch_user: ${{ env.game_itch_username }} | ||
itch_game: ${{ env.game_itch_game }} | ||
files: | | ||
./dist/${{ env.meta_title }}-web.zip | ||
./dist/${{ env.meta_title }}-win.zip | ||
./dist/${{ env.meta_title }}-mac.dmg | ||
./dist/${{ env.meta_title }}-linux.zip | ||
auto_channel: true | ||
butler_version: "latest" | ||
check_signature: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
# Ignore lock files | ||
# Nobody uses the same package manager | ||
package-lock.json | ||
yarn.lock | ||
pnpm-lock.yaml | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/launch.json | ||
!.vscode/settings.json | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
# Neutralino files | ||
bin/ | ||
src/neutralino.js | ||
.tmp | ||
|
||
# Uncompressed music | ||
*.wav | ||
|
||
# Misc files | ||
.cache/ | ||
.firebase/ | ||
*.zip | ||
src/version.json | ||
neutralino.config.json | ||
__neutralino_globals.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Vite DEV server", | ||
"request": "launch", | ||
"runtimeExecutable": "npx", | ||
"runtimeArgs": ["vite"], | ||
"type": "node", | ||
"serverReadyAction": { | ||
"action": "debugWithChrome", | ||
"pattern": "127.0.0.1:.*m([0-9]+)", | ||
"uriFormat": "http://127.0.0.1:%s" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"git.pullTags": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Chocobois Game Jam Template | ||
|
||
We make game, but faster | ||
|
||
## Quick start | ||
### Prerequisites | ||
* Git installed. | ||
* Node 18+ installed. | ||
|
||
### Steps | ||
1. Clone the repository | ||
2. `npm install` | ||
3. `npm run dev` | ||
|
||
Remember to update [`game.config.json`](game.config.json) accordingly. | ||
|
||
## Building | ||
|
||
1. `npm run build` | ||
2. Build goes to `/dist` directory | ||
|
||
## Debugging | ||
This assumes you have VS Code and Chrome installed | ||
|
||
* Hit F5 to debug | ||
* This will launch Vite and Chrome | ||
* You can now add breakpoints in VS Code | ||
* Hit Shift+F5 twice to stop debugging | ||
|
||
## Deploying | ||
### GitHub | ||
The repository is configured to automatically deploy to Github Pages, you just have to change a setting on the repository to deploy from a branch and set the deploy branch to `gh-pages`. | ||
|
||
It will also create new downloads under releases. | ||
### Itch | ||
You can configure this repository to automatically deploy and upload releases to Itch. What you have to do is set the `BUTLER_CREDENTIALS` repository secret and set your Itch username and game name in [`game.config.json`](game.config.json). | ||
|
||
## System requirements | ||
### Web | ||
A modern up-to-date web browser | ||
|
||
### Windows | ||
* Microsoft Edge 89 or newer | ||
* [WebView2](https://go.microsoft.com/fwlink/p/?LinkId=2124703) installed (Windows 11 has this preinstalled) | ||
|
||
### MacOS | ||
* Safari 15 or newer | ||
|
||
### Linux | ||
* WebKitGTK installed | ||
|
||
## Notes | ||
### Mac | ||
The app is unsigned when built, so you need to follow these steps when distributing: | ||
1. First you need to extract the .app from the .dmg before attempting to run the game. | ||
2. Second, try running the game, a popup will say the app is unverified. | ||
3. Right click/Open the context menu on the .app, hold option, click open. | ||
4. Click open in the popup. | ||
|
||
The game will start normally from now on. | ||
|
||
### Linux | ||
You may have to mark the games as executable before it will let you run them. | ||
|
||
There have been reports of the game freezing, so the web version might be preferred in that case. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { PluginOption } from 'vite'; | ||
import { rimrafSync } from 'rimraf'; | ||
import { writeFileSync } from 'fs'; | ||
import { build_path, title_dashed } from './constants'; | ||
|
||
const BuildCleanup = () => { | ||
rimrafSync(build_path); | ||
writeFileSync('./dist/meta.json', JSON.stringify({title: title_dashed})); | ||
} | ||
|
||
export default function buildCleanup() { | ||
return { | ||
name: 'build-cleanup', | ||
apply: 'build', | ||
enforce: 'post', | ||
closeBundle: BuildCleanup, | ||
} as PluginOption; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { execSync } from 'child_process'; | ||
import { platform } from 'os'; | ||
import { team, title, description, neutralino } from '../game.config.json'; | ||
|
||
export { team, title, description, neutralino }; | ||
|
||
const tryCatch = <T>(fun: () => T, fallback: T): T => { | ||
try { | ||
return fun(); | ||
} catch(e) { | ||
return fallback; | ||
} | ||
} | ||
|
||
export const git_count = tryCatch(() => execSync('git rev-list --count HEAD').toString().trim(), "-1"); | ||
export const git_short = tryCatch(() => execSync('git rev-parse --short HEAD').toString().trim(), "no-git"); | ||
export const git_version = `v${git_count}.${git_short}`; | ||
|
||
export const year_current = new Date().getFullYear(); | ||
export const year_initial = tryCatch(() => Number(platform() == 'win32' | ||
? execSync('git log --reverse | findstr "Date"').toString().match(/(\d+) \+/)?.[1] | ||
: execSync('git log --reverse | grep "Date" -m 1').toString().match(/(\d+) \+/)?.[1] | ||
), year_current); | ||
export const year_copyright = year_initial == year_current | ||
? `${year_initial}` : `${year_initial} - ${year_current}`; | ||
|
||
export const team_dashed = team.toLowerCase().replace(/\s/gi, '-'); | ||
export const title_dashed = title.toLowerCase().replace(/\s/gi, '-'); | ||
export const game_dir = `${team_dashed}-${title_dashed}`; | ||
export const build_path = `./dist/${game_dir}/`; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { execSync } from 'child_process'; | ||
import WriteNeuConfig from './write-neu-config'; | ||
|
||
WriteNeuConfig(); | ||
execSync('vite', { stdio: 'inherit' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { PluginOption } from 'vite'; | ||
import { writeFileSync } from 'fs'; | ||
import { git_count, git_short, git_version, title, team } from './constants'; | ||
|
||
const WriteGitVersion = () => { | ||
writeFileSync('./src/version.json', JSON.stringify({ | ||
title, | ||
team, | ||
count: git_count, | ||
short: git_short, | ||
version: git_version | ||
})); | ||
} | ||
|
||
export default function writeGitVersion() { | ||
return { | ||
name: 'write-version-json', | ||
buildStart: WriteGitVersion | ||
} as PluginOption; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { PluginOption } from 'vite'; | ||
import { title_dashed, game_dir, build_path } from './constants'; | ||
import { mkdirSync, copyFileSync } from 'fs'; | ||
|
||
const BuildWinApp = () => { | ||
console.log(`Packaging Linux app...`); | ||
|
||
const out_dir = `./dist/linux/${title_dashed}`; | ||
|
||
mkdirSync('./dist/linux'); | ||
mkdirSync(out_dir); | ||
|
||
copyFileSync(`${build_path}/${game_dir}-linux_x64`, `${out_dir}/${title_dashed}-x64`); | ||
copyFileSync(`${build_path}/${game_dir}-linux_arm64`, `${out_dir}/${title_dashed}-arm64`); | ||
copyFileSync(`${build_path}/${game_dir}-linux_armhf`, `${out_dir}/${title_dashed}-armhf`); | ||
copyFileSync(`${build_path}/resources.neu`, `${out_dir}/resources.neu`); | ||
}; | ||
|
||
export default function buildWinApp() { | ||
return { | ||
name: 'build-linux-bundle', | ||
apply: 'build', | ||
closeBundle: BuildWinApp, | ||
} as PluginOption; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { PluginOption } from 'vite'; | ||
import { team, title, git_count, git_version, team_dashed, | ||
title_dashed, game_dir, build_path, year_copyright } from './constants'; | ||
import { execSync } from 'child_process'; | ||
import { mkdirSync, writeFileSync, copyFileSync, renameSync } from 'fs'; | ||
|
||
const BuildMacApp = () => { | ||
console.log(`Packaging Mac dmg...`); | ||
|
||
const bootstrapper = `#!/usr/bin/env bash | ||
MACOS="\$( cd -- "$( dirname -- "\${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
CONTENTS="$(dirname "$MACOS")" | ||
exec "\${MACOS}/game" --path="\${CONTENTS}/Resources" --enable-extensions=true`; | ||
|
||
const plist = `<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>${title} ${git_version} © ${team} ${year_copyright}</string> | ||
<key>CFBundleExecutable</key> | ||
<string>bootstrapper</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.${team_dashed}.${title_dashed}</string> | ||
<key>CFBundleName</key> | ||
<string>${title}</string> | ||
<key>CFBundleIconFile</key> | ||
<string>icon.png</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>0.${git_count}</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>IFMajorVersion</key> | ||
<integer>0</integer> | ||
<key>IFMinorVersion</key> | ||
<integer>${git_count}</integer> | ||
</dict> | ||
</plist>`; | ||
|
||
const out_dir = `./dist/mac/${title}`; | ||
|
||
mkdirSync(`./dist/mac/`); | ||
mkdirSync(out_dir); | ||
mkdirSync(`${out_dir}/Contents`); | ||
mkdirSync(`${out_dir}/Contents/MacOS`); | ||
mkdirSync(`${out_dir}/Contents/Resources`); | ||
|
||
writeFileSync(`${out_dir}/Contents/MacOS/bootstrapper`, bootstrapper); | ||
writeFileSync(`${out_dir}/Contents/info.plist`, plist); | ||
copyFileSync(`${build_path}/${game_dir}-mac_universal`, `${out_dir}/Contents/MacOS/game`); | ||
copyFileSync(`${build_path}/resources.neu`, `${out_dir}/Contents/Resources/resources.neu`); | ||
copyFileSync(`./src/public/icon.png`, `${out_dir}/Contents/Resources/icon.png`); | ||
renameSync(out_dir, `${out_dir}.app`); | ||
|
||
try { | ||
execSync(`mkisofs -J -R -o ./dist/${title_dashed}-mac.dmg -mac-name -V "${title}" -apple -v -dir-mode 777 -file-mode 777 "./dist/mac/"`); | ||
} catch (err) { | ||
console.log(`Failed to build dmg`); | ||
} | ||
}; | ||
|
||
export default function buildMacApp() { | ||
return { | ||
name: 'build-mac-bundle', | ||
apply: 'build', | ||
closeBundle: BuildMacApp, | ||
} as PluginOption; | ||
} |
Oops, something went wrong.