-
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
Showing
36 changed files
with
575 additions
and
166 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 |
---|---|---|
|
@@ -12,53 +12,64 @@ jobs: | |
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v1 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Install dependencies | ||
uses: bahmutov/npm-install@v1 | ||
run: npm install && sudo apt install genisoimage | ||
|
||
- name: Load game.config.json | ||
uses: antifree/[email protected] | ||
with: | ||
useLockFile: false | ||
filename: 'game.config.json' | ||
prefix: game | ||
|
||
- name: Build project | ||
run: npm run build | ||
|
||
- name: Upload production-ready build files | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: production-files | ||
path: ./dist | ||
|
||
deploy: | ||
name: Deploy | ||
needs: build | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' | ||
|
||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v2 | ||
- name: Load meta.json | ||
uses: antifree/[email protected] | ||
with: | ||
name: production-files | ||
path: ./built/ | ||
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: ./built/unpacked | ||
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: "Rerooted latest build" | ||
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: | | ||
/home/runner/work/uprooting/uprooting/built/Rerooted-GGJ2023-release.zip | ||
/home/runner/work/uprooting/uprooting/built/game-web.zip | ||
./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
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 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
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,64 @@ | ||
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 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>game</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/info.plist`, plist); | ||
copyFileSync(`${build_path}/${game_dir}-mac_universal`, `${out_dir}/Contents/MacOS/game`); | ||
copyFileSync(`${build_path}/resources.neu`, `${out_dir}/Contents/MacOS/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; | ||
} |
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,16 @@ | ||
import { execSync } from 'child_process'; | ||
import { PluginOption } from 'vite'; | ||
import WriteNeuConfig from './write-neu-config'; | ||
|
||
export default function neuBuild(): PluginOption { | ||
return { | ||
name: 'neu-build', | ||
apply: 'build', | ||
enforce: 'pre', | ||
closeBundle() { | ||
console.log('Building game app'); | ||
WriteNeuConfig(); | ||
execSync('neu build'); | ||
}, | ||
}; | ||
} |
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,10 @@ | ||
import { exec } from 'child_process'; | ||
import WriteNeuConfig from './write-neu-config'; | ||
|
||
WriteNeuConfig(); | ||
const vite = exec('vite'); | ||
vite.stdout?.pipe(process.stdout); | ||
exec('neu run --frontend-lib-dev -- --window-enable-inspector=true').on('close', () => { | ||
vite.kill(); | ||
process.exit(); | ||
}); |
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,38 @@ | ||
import { PluginOption } from 'vite'; | ||
import { readFileSync } from 'fs'; | ||
|
||
const tryCatch = <T>(fun: () => T, fallback: T): T => { | ||
try { | ||
return fun(); | ||
} catch(e) { | ||
return fallback; | ||
} | ||
} | ||
|
||
const getGlobalsPath = () => { | ||
const isDev = process.env.NODE_ENV == 'development'; | ||
const authInfo = JSON.parse(tryCatch(() => readFileSync('.tmp/auth_info.json').toString(), '{}')); | ||
const port = authInfo.port; | ||
return `${(isDev && port) ? `http://localhost:${port}/` : ''}__neutralino_globals.js` | ||
} | ||
|
||
export default function neuInject(): PluginOption { | ||
return { | ||
name: 'neu-inject', | ||
transformIndexHtml: (html) => { | ||
return { | ||
html, | ||
tags: [{ | ||
tag: 'script', | ||
injectTo: 'head-prepend', | ||
attrs: { | ||
src: getGlobalsPath() | ||
}, | ||
}] | ||
}; | ||
} | ||
}; | ||
} | ||
|
||
|
||
|
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,43 @@ | ||
{ | ||
"applicationId": "chocobois-jam-template", | ||
"version": "1.0.0", | ||
"defaultMode": "window", | ||
"port": 0, | ||
"documentRoot": "/dist/web", | ||
"url": "/", | ||
"enableServer": true, | ||
"enableNativeAPI": true, | ||
"tokenSecurity": "one-time", | ||
"logging": { | ||
"enabled": true, | ||
"writeToLogFile": false | ||
}, | ||
"nativeAllowList": ["app.exit", "window.center"], | ||
"modes": { | ||
"window": { | ||
"title": "Chocobois Game Jam Template", | ||
"width": 1440, | ||
"height": 845, | ||
"minWidth": 960, | ||
"minHeight": 570, | ||
"fullScreen": false, | ||
"alwaysOnTop": false, | ||
"icon": "src/public/icon.png", | ||
"enableInspector": false, | ||
"borderless": false, | ||
"maximize": false, | ||
"hidden": false, | ||
"resizable": true, | ||
"exitProcessOnClose": true | ||
} | ||
}, | ||
"cli": { | ||
"binaryName": "chocobois-jam-template", | ||
"resourcesPath": "/dist/", | ||
"binaryVersion": "4.12.0", | ||
"frontendLibrary": { | ||
"patchFile": "/src/index.html", | ||
"devUrl": "http://127.0.0.1:5173/" | ||
} | ||
} | ||
} |
Oops, something went wrong.