mirror of
https://github.com/subosito/flutter-action.git
synced 2024-08-16 10:19:50 +02:00
add support for master channel
This commit is contained in:
parent
26bf50084a
commit
d7578c4eec
3 changed files with 42 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
import io = require('@actions/io');
|
||||
import exec = require('@actions/exec');
|
||||
import fs = require('fs');
|
||||
import path = require('path');
|
||||
import nock = require('nock');
|
||||
|
@ -42,6 +43,27 @@ describe('installer tests', () => {
|
|||
expect(fs.existsSync(path.join(sdkDir, 'bin'))).toBe(true);
|
||||
}, 300000);
|
||||
|
||||
it('Downloads flutter from master channel', async () => {
|
||||
await installer.getFlutter('', 'master');
|
||||
const sdkDir = path.join(toolDir, 'flutter', 'master', 'x64');
|
||||
|
||||
let stdout = '';
|
||||
|
||||
const options = {
|
||||
listeners: {
|
||||
stdout: (data: Buffer) => {
|
||||
stdout += data.toString();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(fs.existsSync(`${sdkDir}.complete`)).toBe(true);
|
||||
expect(fs.existsSync(path.join(sdkDir, 'bin'))).toBe(true);
|
||||
|
||||
await exec.exec(path.join(sdkDir, 'bin', 'flutter'), ['channel'], options);
|
||||
expect(stdout).toContain('* master');
|
||||
}, 300000);
|
||||
|
||||
it('Throws if no location contains correct flutter version', async () => {
|
||||
let thrown = false;
|
||||
try {
|
||||
|
|
|
@ -6,6 +6,14 @@ async function run() {
|
|||
const version = core.getInput('flutter-version') || '';
|
||||
const channel = core.getInput('channel') || 'stable';
|
||||
|
||||
if (channel == 'master' && version != '') {
|
||||
core.setFailed(
|
||||
'using `flutter-version` with master channel is not supported.'
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
await installer.getFlutter(version, channel);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import * as core from '@actions/core';
|
||||
import * as io from '@actions/io';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import {CONNREFUSED} from 'dns';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import {format} from 'path';
|
||||
import * as release from './release';
|
||||
|
||||
export async function getFlutter(
|
||||
|
@ -12,14 +11,18 @@ export async function getFlutter(
|
|||
channel: string
|
||||
): Promise<void> {
|
||||
const platform = release.getPlatform();
|
||||
const useMaster = channel == 'master';
|
||||
|
||||
const {version: selected, downloadUrl} = await release.determineVersion(
|
||||
version,
|
||||
channel,
|
||||
useMaster ? 'dev' : channel,
|
||||
platform
|
||||
);
|
||||
|
||||
let cleanver = `${selected.replace('+', '-')}-${channel}`;
|
||||
let cleanver = useMaster
|
||||
? channel
|
||||
: `${selected.replace('+', '-')}-${channel}`;
|
||||
|
||||
let toolPath = tc.find('flutter', cleanver);
|
||||
|
||||
if (toolPath) {
|
||||
|
@ -37,6 +40,11 @@ export async function getFlutter(
|
|||
core.exportVariable('FLUTTER_HOME', toolPath);
|
||||
core.addPath(path.join(toolPath, 'bin'));
|
||||
core.addPath(path.join(toolPath, 'bin', 'cache', 'dart-sdk', 'bin'));
|
||||
|
||||
if (useMaster) {
|
||||
await exec.exec('flutter', ['channel', 'master']);
|
||||
await exec.exec('flutter', ['upgrade']);
|
||||
}
|
||||
}
|
||||
|
||||
function tmpBaseDir(platform: string): string {
|
||||
|
|
Loading…
Reference in a new issue