Use Task to build pinned CLI for IDE2.

Closes #1313

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta 2022-08-10 13:56:05 +02:00 committed by Akos Kitta
parent 9cabd40429
commit a39ab47e70
4 changed files with 34 additions and 4 deletions

View File

@ -66,6 +66,12 @@ jobs:
with: with:
python-version: '3.x' python-version: '3.x'
- name: Install Taskfile
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Package - name: Package
shell: bash shell: bash
env: env:

View File

@ -31,6 +31,12 @@ jobs:
node-version: '14.x' node-version: '14.x'
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
- name: Install Taskfile
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Install dependencies - name: Install dependencies
run: yarn run: yarn

View File

@ -6,7 +6,7 @@
const semver = require('semver'); const semver = require('semver');
const moment = require('moment'); const moment = require('moment');
const downloader = require('./downloader'); const downloader = require('./downloader');
const { goBuildFromGit } = require('./utils'); const { taskBuildFromGit } = require('./utils');
const version = (() => { const version = (() => {
const pkg = require(path.join(__dirname, '..', 'package.json')); const pkg = require(path.join(__dirname, '..', 'package.json'));
@ -82,6 +82,6 @@
shell.exit(1); shell.exit(1);
} }
} else { } else {
goBuildFromGit(version, destinationPath, 'CLI'); taskBuildFromGit(version, destinationPath, 'CLI');
} }
})(); })();

View File

@ -1,3 +1,14 @@
/**
* Clones something from GitHub and builds it with [`Task`](https://taskfile.dev/).
*
* @param version {object} the version object.
* @param destinationPath {string} the absolute path of the output binary. For example, `C:\\folder\\arduino-cli.exe` or `/path/to/arduino-language-server`
* @param taskName {string} for the CLI logging . Can be `'CLI'` or `'language-server'`, etc.
*/
exports.taskBuildFromGit = (version, destinationPath, taskName) => {
return buildFromGit('task', version, destinationPath, taskName);
};
/** /**
* Clones something from GitHub and builds it with `Golang`. * Clones something from GitHub and builds it with `Golang`.
* *
@ -6,6 +17,13 @@
* @param taskName {string} for the CLI logging . Can be `'CLI'` or `'language-server'`, etc. * @param taskName {string} for the CLI logging . Can be `'CLI'` or `'language-server'`, etc.
*/ */
exports.goBuildFromGit = (version, destinationPath, taskName) => { exports.goBuildFromGit = (version, destinationPath, taskName) => {
return buildFromGit('go', version, destinationPath, taskName);
};
/**
* The `command` is either `go` or `task`.
*/
function buildFromGit(command, version, destinationPath, taskName) {
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const temp = require('temp'); const temp = require('temp');
@ -62,7 +80,7 @@ exports.goBuildFromGit = (version, destinationPath, taskName) => {
} }
shell.echo(`>>> Building the ${taskName}...`); shell.echo(`>>> Building the ${taskName}...`);
if (shell.exec('go build', { cwd: tempRepoPath }).code !== 0) { if (shell.exec(`${command} build`, { cwd: tempRepoPath }).code !== 0) {
shell.exit(1); shell.exit(1);
} }
shell.echo(`<<< Done ${taskName} build.`); shell.echo(`<<< Done ${taskName} build.`);
@ -89,4 +107,4 @@ exports.goBuildFromGit = (version, destinationPath, taskName) => {
shell.exit(1); shell.exit(1);
} }
shell.echo(`>>> Verified ${taskName}.`); shell.echo(`>>> Verified ${taskName}.`);
}; }