Skip to content

Commit

Permalink
feat: add os agnostic build system (#34)
Browse files Browse the repository at this point in the history
* feat: add windows support

* build: add forge hook to copy assets (#42)

* build: add forge hook to copy assets

* ci: add forge publish workflow (#43)

* ci: add forge publish workflow

* build: download bee binary in forge hook (#44)

* feat: add os agnostic pathfinder (#41)

* fix: add function to test paths and fix hardcoded separators

* fix: add makePath fn

* chore: remove unused script

* fix: fix more path issues

* fix: make pathfinder stay in root directory

* fix: add regex instead of sep

* fix: do not prepend / on windows

* fix: update binary links

* refactor: improve path handling

* build: add rimraf

* chore: add clean script

* build(fix): ignore publisher dependency

* build(fix): ignore additional devDependencies

* chore: use .depcheckrc

* chore: use clean script instead of duplicating rimraf

Co-authored-by: Cafe137 <aron@aronsoos.com>
  • Loading branch information
Cafe137 and Cafe137 authored Apr 12, 2022
1 parent 68e6891 commit aef4ad8
Show file tree
Hide file tree
Showing 13 changed files with 748 additions and 270 deletions.
2 changes: 2 additions & 0 deletions .depcheckrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"ignores": [
"@electron-forge/publisher-github",
"@electron-forge/maker-deb",
"@electron-forge/maker-deb",
"@electron-forge/maker-rpm",
"@electron-forge/maker-squirrel",
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release
on:
release:
types:
- created

jobs:
publish_on_linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@master
with:
node-version: 14
- name: install dependencies
run: npm install
- name: publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run publish

publish_on_mac:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@master
with:
node-version: 14
- name: install dependencies
run: npm install
- name: publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run publish

publish_on_win:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@master
with:
node-version: 14
- name: install dependencies
run: npm install
- name: publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run publish
7 changes: 0 additions & 7 deletions copy-assets.sh

This file was deleted.

42 changes: 42 additions & 0 deletions hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const { existsSync, writeFileSync } = require('fs')
const { copySync } = require('fs-extra')
const { join } = require('path')
const { platform } = require('os')
const { default: fetch } = require('node-fetch')
const { execSync } = require('child_process')

const binaries = {
darwin: ['https://github.com/ethersphere/bee/releases/download/v1.5.1/bee-darwin-amd64', 'bee'],
linux: ['https://github.com/ethersphere/bee/releases/download/v1.5.1/bee-linux-amd64', 'bee'],
win32: ['https://github.com/ethersphere/bee/releases/download/v1.5.1/bee-windows-amd64.exe', 'bee.exe'],
}

module.exports = {
generateAssets: async () => {
const target = binaries[platform()]
if (!existsSync(target[1])) {
await downloadFile(target[0], target[1])
try {
execSync(`chmod +x ${target[1]}`)
} catch {}
}
},
postPackage: (_, options) => {
if (existsSync('bee')) {
copySync('bee', join(options.outputPaths[0], 'bee'))
}
if (existsSync('bee.exe')) {
copySync('bee.exe', join(options.outputPaths[0], 'bee.exe'))
}
copySync('tray.png', join(options.outputPaths[0], 'tray.png'))
copySync('tray@2x.png', join(options.outputPaths[0], 'tray@2x.png'))
copySync('icon.png', join(options.outputPaths[0], 'icon.png'))
copySync('static', join(options.outputPaths[0], 'static'))
},
}

function downloadFile(url, target) {
return fetch(url)
.then(x => x.arrayBuffer())
.then(x => writeFileSync(target, Buffer.from(x)))
}
Loading

0 comments on commit aef4ad8

Please sign in to comment.