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

feat: add os agnostic build system #34

merged 20 commits into from
Apr 12, 2022

Conversation

Cafe137
Copy link
Collaborator

@Cafe137 Cafe137 commented Apr 6, 2022

No description provided.

@vojtechsimetka
Copy link
Contributor

Can I test this without having windows somehow? Any idea? :)

@Cafe137
Copy link
Collaborator Author

Cafe137 commented Apr 6, 2022

Can I test this without having windows somehow? Any idea? :)

Gave up on it, I built a Windows PC 😄

@agazso
Copy link
Member

agazso commented Apr 6, 2022

Can I test this without having windows somehow? Any idea? :)

You may want to try Windows in a VirtualBox, that's what I do.

* 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)
@Cafe137 Cafe137 changed the title feat: add windows support feat: add os agnostic build system Apr 7, 2022
@Cafe137 Cafe137 marked this pull request as draft April 7, 2022 13:24
@Cafe137 Cafe137 marked this pull request as ready for review April 8, 2022 08:33
Comment on lines +1 to +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('[email protected]', join(options.outputPaths[0], '[email protected]'))
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)))
}
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? :)

.github/workflows/release.yml Show resolved Hide resolved
Copy link
Contributor

@vojtechsimetka vojtechsimetka left a comment

Choose a reason for hiding this comment

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

LGTM and seems to work on mac

Comment on lines +1 to +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('[email protected]', join(options.outputPaths[0], '[email protected]'))
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)))
}
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? :)

package.json Outdated Show resolved Hide resolved
@Cafe137 Cafe137 merged commit aef4ad8 into master Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants