Skip to content

Commit

Permalink
feat: remove auto release
Browse files Browse the repository at this point in the history
  • Loading branch information
yantze committed Mar 4, 2022
1 parent b01df97 commit fcd7c02
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 110 deletions.
51 changes: 11 additions & 40 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,23 @@ name: RELEASE
on:
push:
tags:
- 'v*'
- "v*"
workflow_dispatch:

jobs:
windows-build:
runs-on: windows-latest
release:
name: Publish for ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
matrix:
node_version: [14.x]
include:
- os: windows-latest
TARGET_PLATFORMS: win32

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Package Electron
run: |
npm i
npm run rebuild-native
npm run pack
env:
TARGET_PLATFORMS: win32


- uses: 'marvinpinto/action-automatic-releases@latest'
with:
repo_token: '${{ secrets.GITHUB_TOKEN }}'
prerelease: true
files: |
LICENSE
out/*.dmg
out/*.exe
macos-build:
runs-on: macos-latest

strategy:
matrix:
node_version: [14.x]
- os: macos-latest
TARGET_PLATFORMS: darwin

steps:
- uses: actions/checkout@v2
Expand All @@ -60,13 +34,10 @@ jobs:
npm i
npm run rebuild-native
npm run pack
env:
TARGET_PLATFORMS: darwin

- uses: 'marvinpinto/action-automatic-releases@latest'
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: '${{ secrets.GITHUB_TOKEN }}'
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: true
files: |
LICENSE
Expand Down
79 changes: 9 additions & 70 deletions scripts/rebuild-native.js
Original file line number Diff line number Diff line change
@@ -1,76 +1,15 @@
const os = require('os');
const { join } = require('path');
const { execSync } = require('child_process');
const { pathExistsSync, copySync, removeSync } = require('fs-extra');
const path = require('path');
const argv = require('yargs').argv;
const electronRebuild = require('electron-rebuild');

const nativeModules = [
join(__dirname, '../node_modules/node-pty'),
join(__dirname, '../node_modules/nsfw'),
join(__dirname, '../node_modules/spdlog')
]
const electronVersion = argv.electronVersion || require('electron/package.json').version;

let commands;
console.log('rebuilding native for electron version ' + electronVersion);
const force = argv['force-rebuild'] === 'true';
const buildPath = path.resolve(__dirname, '..');

const target = argv.target || 'node';
const arch = argv.arch || os.arch();
let version;

if (target === 'electron') {

version = argv.electronVersion || require('electron/package.json').version;

console.log('rebuilding native for electron version ' + version);

commands = [
`npm_config_arch=${arch}`,
`npm_config_target_arch=${arch}`,
os.platform() === 'win32'
? 'set HOME=~/.electron-gyp'
: 'HOME=~/.electron-gyp',

os.platform() === 'win32'
? join(__dirname, '..\\node_modules\\.bin\\electron-rebuild.cmd')
: join(__dirname, '../node_modules/.bin/electron-rebuild'),
];

} else if (target === 'node') {

console.log('rebuilding native for node version ' + process.version);

version = process.version;

commands = ['node-gyp', 'rebuild']

}

function rebuildModule(modulePath, type, version) {
const info = require(join(modulePath, './package.json'));
console.log('rebuilding ' + info.name)
const cache = getBuildCacheDir(modulePath, type, version, target);
if (pathExistsSync(cache) && !argv['force-rebuild']) {
console.log('cache found for ' + info.name)
copySync(cache, join(modulePath, 'build'));
}
else {
const command = commands.join(' ');
console.log(command);
execSync(command, {
cwd: modulePath,
HOME: target === 'electron' ? '~/.electron-gyp' : undefined
});
removeSync(cache);
copySync(join(modulePath, 'build'), cache);
}

}

function getBuildCacheDir(modulePath, type, version, target) {
const info = require(join(modulePath, './package.json'));
return join(require('os').tmpdir(), 'ide_build_cache', target, info.name + '-' + info.version, type + '-' + version);
if (force) {
console.log('Force rebuild flag enabled.');
}


nativeModules.forEach(path => {
rebuildModule(path, target, version);
})
electronRebuild.rebuild({ buildPath, electronVersion, force })

0 comments on commit fcd7c02

Please sign in to comment.