Skip to content

Commit

Permalink
Merge branch 'iNavFlight:master' into timeonlysec
Browse files Browse the repository at this point in the history
  • Loading branch information
druckgott authored Aug 15, 2024
2 parents 19ab03e + c93ce34 commit 979fecc
Show file tree
Hide file tree
Showing 9 changed files with 4,188 additions and 11,345 deletions.
180 changes: 180 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
name: Build Configurator
# Don't enable CI on push, just on PR. If you
# are working on the main repo and want to trigger
# a CI build submit a draft PR.
on:
pull_request:

workflow_call:
#inputs:
# release_build:
# description: 'Specifies if it is a build that should include commit hash in hex file names or not'
# default: false
# required: false
# type: boolean

jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup environment
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
run: |
# This is the hash of the commit for the PR
# when the action is triggered by PR, empty otherwise
COMMIT_ID=${{ github.event.pull_request.head.sha }}
# This is the hash of the commit when triggered by push
# but the hash of refs/pull/<n>/merge, which is different
# from the hash of the latest commit in the PR, that's
# why we try github.event.pull_request.head.sha first
COMMIT_ID=${COMMIT_ID:-${{ github.sha }}}
BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID})
VERSION=$(grep version package.json | sed 's/.*"\([0-9][0-9]*.[0-9]*.[0-9]*\)".*/\1/g')
echo "ACTIONS_STEP_DEBUG=true" >> $GITHUB_ENV
echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV
echo "BUILD_NAME=inav-configurator_linux_x64_${VERSION}_${BUILD_SUFFIX}" >> $GITHUB_ENV
mkdir ./apps/
- uses: actions/setup-node@v4
with:
node-version: 20
check-latest: true
cache: 'npm'
- name: Install dependencies
run: sudo apt-get update && sudo apt-get -y install dpkg fakeroot rpm build-essential libudev-dev
- name: Install deps
uses: nick-fields/retry@v3
with:
max_attempts: 3
retry_on: error
command: npm install
timeout_minutes: 10
- name: Build Linux
run: npm run gulp release -- --platform="linux64" --installer
- name: Upload Linux deb
uses: actions/upload-artifact@v4
with:
name: ${{ env.BUILD_NAME }}_DEB
path: ./apps/*amd64.deb
- name: Upload Linux rpm
uses: actions/upload-artifact@v4
with:
name: ${{ env.BUILD_NAME }}_RPM
path: ./apps/*.rpm
- name: Upload Linux zip
uses: actions/upload-artifact@v4
with:
name: ${{ env.BUILD_NAME }}_ZIP
path: ./apps/*.zip
- name: Upload Linux tgz
uses: actions/upload-artifact@v4
with:
name: ${{ env.BUILD_NAME }}_TGZ
path: ./apps/*.tar.gz

build-mac:
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- name: Setup environment
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
run: |
# This is the hash of the commit for the PR
# when the action is triggered by PR, empty otherwise
COMMIT_ID=${{ github.event.pull_request.head.sha }}
# This is the hash of the commit when triggered by push
# but the hash of refs/pull/<n>/merge, which is different
# from the hash of the latest commit in the PR, that's
# why we try github.event.pull_request.head.sha first
COMMIT_ID=${COMMIT_ID:-${{ github.sha }}}
BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID})
VERSION=$(grep version package.json | sed 's/.*"\([0-9][0-9]*.[0-9]*.[0-9]*\)".*/\1/g')
echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV
echo "BUILD_NAMEx64=inav-configurator_darwin_x64_${VERSION}_${BUILD_SUFFIX}" >> $GITHUB_ENV
mkdir ./apps/
- uses: actions/setup-node@v4
with:
node-version: 20
check-latest: true
cache: 'npm'
# Workaround due to a bug in node-gyp: https://github.com/electron/rebuild/issues/1116
- name: Install Setuptools
run: python3 -m pip install --break-system-packages setuptools
- name: Install deps
uses: nick-fields/retry@v3
with:
max_attempts: 3
retry_on: error
command: arch -arch x86_64 npm install
timeout_minutes: 10
- name: Bad bodge hack to fix nw-builder
run: perl -pi -e 's/semver.satisfies\(self._version.version, "<=0.12.3"\)/false/g' node_modules/nw-builder/lib/index.cjs
- name: Build MacOS x64
run: arch -arch x86_64 npm run gulp release -- --platform="osx64" --installer
- name: Upload MacOS x64 zip
uses: actions/upload-artifact@v4
with:
name: ${{env.BUILD_NAMEx64}}_ZIP
path: ./apps/*.zip
- name: Upload MacOS x64 dmg
uses: actions/upload-artifact@v4
with:
name: ${{env.BUILD_NAMEx64}}_DMG
path: ./apps/*.dmg

build-windows-win64:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install linux utils
run: choco install --force -y awk grep sed
- name: Setup environment
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
run: |
# This is the hash of the commit for the PR
# when the action is triggered by PR, empty otherwise
COMMIT_ID=${{ github.event.pull_request.head.sha }}
# This is the hash of the commit when triggered by push
# but the hash of refs/pull/<n>/merge, which is different
# from the hash of the latest commit in the PR, that's
# why we try github.event.pull_request.head.sha first
COMMIT_ID=${COMMIT_ID:-${{ github.sha }}}
BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID})
VERSION=$(grep version package.json | sed 's/.*"\([0-9][0-9]*.[0-9]*.[0-9]*\)".*/\1/g')
echo "ACTIONS_STEP_DEBUG=true" >> $GITHUB_ENV
echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV
echo "BUILD_NAMEx64=inav-configurator_win64_x64_${VERSION}_${BUILD_SUFFIX}" >> $GITHUB_ENV
mkdir ./apps/
shell: bash
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- uses: engineerd/[email protected]
with:
name: "Wix Toolset 3.1.4"
url: "https://github.com/wixtoolset/wix3/releases/download/wix3141rtm/wix314-binaries.zip"
pathInArchive: "/"
- name: Install deps
uses: nick-fields/retry@v3
with:
max_attempts: 3
retry_on: error
command: npm install
timeout_minutes: 10
- name: Build windows
run: npm run gulp release -- --platform="win64" --installer
- name: Upload Windows x64 zip
uses: actions/upload-artifact@v4
with:
name: ${{env.BUILD_NAMEx64}}_ZIP
path: ./apps/*.zip
- name: Upload Windows x64 msi
uses: actions/upload-artifact@v4
with:
name: ${{env.BUILD_NAMEx64}}_MSI
path: ./apps/*.msi

39 changes: 14 additions & 25 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ var minimist = require('minimist');

var archiver = require('archiver');
var del = require('del');
var NwBuilder = require('nw-builder');
var semver = require('semver');

const NwBuilder = require('nw-builder');
const semver = require('semver');

var gulp = require('gulp');
var concat = require('gulp-concat');
Expand All @@ -37,10 +38,10 @@ function getArguments() {

// Get platform from commandline args
// #
// # gulp <task> [<platform>]+ Run only for platform(s) (with <platform> one of --linux64, --osx64, or --win32 --chromeos)
// # gulp <task> [<platform>]+ Run only for platform(s) (with <platform> one of --linux64, --osx64, or --win64 --chromeos)
// #
function getPlatforms() {
const defaultPlatforms = ['win32', 'osx64', 'linux64'];
const defaultPlatforms = ['win64', 'osx64', 'linux64'];
const platform = getArguments().platform;
if (platform) {
if (defaultPlatforms.indexOf(platform) < 0) {
Expand Down Expand Up @@ -70,8 +71,8 @@ function getRunDebugAppCommand() {
return path.join(debugDir, pkg.name, 'linux64', pkg.name);

break;
case 'win32':
return path.join(debugDir, pkg.name, 'win32', pkg.name + '.exe');
case 'win64':
return path.join(debugDir, pkg.name, 'win64', pkg.name + '.exe');

break;

Expand Down Expand Up @@ -217,10 +218,9 @@ gulp.task('apps', gulp.series(['dist', 'clean-apps'], function (done) {
winIco: './images/inav_icon.ico',
version: get_nw_version()
});
builder.on('log', console.log);
builder.build(function (err) {
if (err) {
console.log('Error building NW apps: ' + err);
console.log('Error building NW apps: ' + err + "\n" + err.stack);
// done();
// return;
gulp.series(['clean-apps'], function() {
Expand Down Expand Up @@ -250,7 +250,7 @@ gulp.task('debug', gulp.series(['dist', 'clean-debug'], function (done) {
version: get_nw_version()
});

builder.on('log', console.log);
//builder.on('log', console.log);
builder.build(function (err) {
if (err) {
console.log('Error building NW apps: ' + err);
Expand Down Expand Up @@ -309,8 +309,8 @@ function build_win_iss(arch) {
// Extra parameters to replace inside the iss file
parameters.push(`/Dversion=${pkg.version}`);
parameters.push(`/DarchName=${arch}`);
parameters.push(`/DarchAllowed=${(arch === 'win32') ? 'x86 x64' : 'x64'}`);
parameters.push(`/DarchInstallIn64bit=${(arch === 'win32') ? '' : 'x64'}`);
parameters.push(`/DarchAllowed=x64`);
parameters.push(`/DarchInstallIn64bit=x64`);
parameters.push(`/DsourceFolder=${APPS_DIR}`);
parameters.push(`/DtargetFolder=${APPS_DIR}`);

Expand All @@ -332,8 +332,7 @@ function build_win_iss(arch) {
}
}

gulp.task('release-win32', gulp.series(build_win_zip('win32'), build_win_iss('win32')));
//gulp.task('release-win64', gulp.series(build_win_zip('win64'), build_win_iss('win64')));
gulp.task('release-win64', gulp.series(build_win_zip('win64'), build_win_iss('win64')));

gulp.task('release-osx64', function(done) {
var pkg = require('./package.json');
Expand Down Expand Up @@ -535,6 +534,7 @@ function release_deb(arch) {

console.log(`Generating deb package for ${arch}`);

console.log("Metadata Version: "+metadata.version);
return gulp.src([path.join(appsDir, metadata.name, arch, '*')])
.pipe(deb({
package: metadata.name,
Expand Down Expand Up @@ -567,18 +567,6 @@ function post_release_deb(arch) {
done();
return null;
}
if ((arch === 'linux32') || (arch === 'linux64')) {
var rename = require("gulp-rename");
const metadata = require('./package.json');
const renameFrom = path.join(appsDir, metadata.name + '_' + metadata.version + '_' + getLinuxPackageArch('.deb', arch) + '.deb');
const renameTo = path.join(appsDir, get_release_filename_base(arch) + '_' + metadata.version + '.deb');
// Rename .deb build to common naming
console.log(`Renaming .deb installer ${renameFrom} to ${renameTo}`);
return gulp.src(renameFrom)
.pipe(rename(renameTo))
.pipe(gulp.dest("."));
}

return done();
}
}
Expand Down Expand Up @@ -669,6 +657,7 @@ function releaseLinux(bits) {
var pkg = require('./package.json');
var src = path.join(appsDir, pkg.name, dirname);
var output = fs.createWriteStream(path.join(appsDir, get_release_filename(dirname, 'tar.gz')));
console.log("Writting to " + path.join(appsDir, get_release_filename(dirname, 'tar.gz')));
var archive = archiver('tar', {
zlib: { level: 9 },
gzip: true
Expand Down
Loading

0 comments on commit 979fecc

Please sign in to comment.