Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add os agnostic build system #34

Merged
merged 20 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
vojtechsimetka marked this conversation as resolved.
Show resolved Hide resolved

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)))
}
Comment on lines +1 to +42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is POC but can these be in typescript? Happy to help.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine, it is not very obvious since this script is specified in package.json as a property of forge but I'll check 🙂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you check? :)

Loading