Compare commits

..
59 Commits
Author SHA1 Message Date
Alif Rachmawadi 2f01469b02 remove unused files 2022-01-06 09:31:17 +00:00
Alif Rachmawadi f6d2e5de5d update readme 2022-01-06 09:23:09 +00:00
Alif Rachmawadi f5fec4dcb7 remove unused files 2022-01-06 09:22:58 +00:00
Alif Rachmawadi 37e2edb15e add any channel 2022-01-06 09:21:17 +00:00
Alif Rachmawadi c64fa18722 add master channel 2022-01-06 09:05:37 +00:00
Alif Rachmawadi a3bd2fdf17 add version matrix test 2022-01-06 08:57:24 +00:00
Alif Rachmawadi a7e6ec0df9 add PUBCACHE 2022-01-06 08:48:07 +00:00
Alif Rachmawadi 23835ee500 add dart bin to path 2022-01-06 08:45:45 +00:00
Alif Rachmawadi 84b5c35087 download archive 2022-01-06 08:38:04 +00:00
Alif Rachmawadi 365543a8d9 update env name 2022-01-06 07:51:59 +00:00
Alif Rachmawadi 49d7a2a9ae rewrite flutter-action 2022-01-06 07:48:39 +00:00
Alif RachmawadiandGitHub 409aab1aac Merge pull request #119 from subosito/dependabot/npm_and_yarn/ansi-regex-5.0.1
Bump ansi-regex from 5.0.0 to 5.0.1
2021-11-17 15:46:32 +07:00
Alif RachmawadiandGitHub f0c3acec24 Merge pull request #95 from tianhaoz95/fix/update-java-requirements
chore: migrate setup java in the instructions to v2
2021-11-17 15:28:02 +07:00
dependabot[bot]andGitHub 399a47813e Bump ansi-regex from 5.0.0 to 5.0.1
Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/chalk/ansi-regex/releases)
- [Commits](https://github.com/chalk/ansi-regex/compare/v5.0.0...v5.0.1)

---
updated-dependencies:
- dependency-name: ansi-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-17 08:27:53 +00:00
Alif RachmawadiandGitHub 87ca224aa8 Merge pull request #114 from subosito/dependabot/npm_and_yarn/tmpl-1.0.5
Bump tmpl from 1.0.4 to 1.0.5
2021-11-17 15:27:12 +07:00
dependabot[bot]andGitHub a1905c800f Bump tmpl from 1.0.4 to 1.0.5
Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-21 11:54:45 +00:00
Alif RachmawadiandGitHub 14cf1a3f11 Merge pull request #111 from subosito/dependabot/npm_and_yarn/path-parse-1.0.7
Bump path-parse from 1.0.6 to 1.0.7
2021-08-13 16:11:10 +07:00
dependabot[bot]andGitHub 858d2d954a Bump path-parse from 1.0.6 to 1.0.7
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-11 08:46:00 +00:00
Alif Rachmawadi 4389e6cbc6 re-use new releases assets url path 2021-06-14 02:47:16 +00:00
Alif RachmawadiandGitHub a471b152dc Merge pull request #97 from subosito/dependabot/npm_and_yarn/ws-7.4.6
Bump ws from 7.4.5 to 7.4.6
2021-06-11 15:33:35 +07:00
dependabot[bot]andGitHub 56a652e69d Bump ws from 7.4.5 to 7.4.6
Bumps [ws](https://github.com/websockets/ws) from 7.4.5 to 7.4.6.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.4.5...7.4.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-11 08:20:48 +00:00
Alif Rachmawadi 8e1e9c4d87 update dist 2021-06-11 08:19:02 +00:00
Alif Rachmawadi 017da32f19 update dependencies 2021-06-11 08:18:38 +00:00
Alif Rachmawadi cb226e935b Back to original path of release assets 2021-06-11 08:13:00 +00:00
Alif RachmawadiandGitHub 5188e41281 Merge pull request #100 from chatsen/master
Fix the endpoint for flutter releases
2021-06-02 10:48:10 +07:00
William BulinandGitHub 1ced41a989 Update index.js 2021-06-02 01:38:26 +02:00
William BulinandGitHub 4ac301c302 Update release.ts 2021-06-02 01:36:53 +02:00
Tianhao ZhouandGitHub 5c3d315241 fix: add missing arguments for java setup 2021-05-17 01:10:08 -07:00
Alif RachmawadiandGitHub 0600af6a5c Merge pull request #93 from subosito/dependabot/npm_and_yarn/hosted-git-info-2.8.9
Bump hosted-git-info from 2.7.1 to 2.8.9
2021-05-15 14:04:20 +07:00
dependabot[bot]andGitHub 1c63d3b831 Bump hosted-git-info from 2.7.1 to 2.8.9
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.7.1 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.7.1...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-11 01:25:41 +00:00
Alif RachmawadiandGitHub 086f9fb649 Merge pull request #90 from kuhnroyal/feature/pub-cache
Export PUB_CACHE if it is not in env
2021-05-01 08:31:38 +07:00
Peter Leibiger 8f6ad7c383 Export PUB_CACHE if it is not in env
Export `PUB_CACHE` if it is not configured before calling the action.
This ensures that flutter and dart use the same cache.
It also enables other tools to use this official Dart env variable.
2021-04-28 20:43:14 +02:00
Alif Rachmawadi 13141e86c3 update readme 2021-04-26 14:56:05 +00:00
Alif Rachmawadi 41992c08db adjust windows example 2021-04-26 14:49:19 +00:00
Alif RachmawadiandGitHub d94ad8f4a5 Merge pull request #68 from majudhu/patch-1
add example to build for windows
2021-04-26 21:47:15 +07:00
Alif Rachmawadi 7bb7a2ead1 pin prettier 2021-04-26 14:35:27 +00:00
Alif Rachmawadi 08d7837173 update dist 2021-04-26 14:31:40 +00:00
Alif Rachmawadi cb118effe2 update dependencies 2021-04-26 14:30:05 +00:00
Alif Rachmawadi 8c0828b9c2 update readme 2021-04-26 14:24:54 +00:00
Alif Rachmawadi 30d8b6aed2 update tests 2021-04-26 14:24:40 +00:00
Alif RachmawadiandGitHub e7b018ff3a Merge pull request #83 from subosito/dependabot/npm_and_yarn/y18n-4.0.1
Bump y18n from 4.0.0 to 4.0.1
2021-04-02 20:14:32 +07:00
dependabot[bot]andGitHub 267db14c3d Bump y18n from 4.0.0 to 4.0.1
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-30 22:16:18 +00:00
Alif RachmawadiandGitHub 123325ea84 Merge pull request #79 from jpnurmi/pub-cache-path
Add .pub-cache/bin to PATH
2021-03-07 19:03:55 +07:00
J-P Nurmi 06a5370154 Add .pub-cache/bin to PATH 2021-03-05 18:29:25 +01:00
Alif RachmawadiandGitHub 5781588262 Merge pull request #71 from subosito/dependabot/npm_and_yarn/node-notifier-8.0.1
Bump node-notifier from 8.0.0 to 8.0.1
2021-01-07 09:38:37 +07:00
dependabot[bot]andGitHub 2d5af0bae8 Bump node-notifier from 8.0.0 to 8.0.1
Bumps [node-notifier](https://github.com/mikaelbr/node-notifier) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/mikaelbr/node-notifier/releases)
- [Changelog](https://github.com/mikaelbr/node-notifier/blob/v8.0.1/CHANGELOG.md)
- [Commits](https://github.com/mikaelbr/node-notifier/compare/v8.0.0...v8.0.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-22 08:02:28 +00:00
Alif Rachmawadi d2a92405ab update examples 2020-12-01 15:49:09 +00:00
Alif Rachmawadi c1329a99f0 fix test 2020-12-01 15:44:22 +00:00
Alif RachmawadiandGitHub 618ffe6e1a Merge pull request #67 from dmitry-shibanov/add-any-channel
Add any channel
2020-12-01 22:08:51 +07:00
MajudhuandGitHub 1b4d6c711f add example to build for windows
add example script which will build a windows executable and also upload it to action artifacts
2020-11-25 14:07:49 +05:00
Dmitry Shibanov 2ed9c88ae0 build project 2020-11-23 16:13:25 +03:00
Dmitry Shibanov d8b5280c4b add any channel 2020-11-23 16:11:57 +03:00
Alif RachmawadiandGitHub 8ffad233a0 Merge pull request #66 from sidrao2006/patch-1
Use FLUTTER_ROOT instead of FLUTTER_HOME
2020-11-21 05:57:49 +07:00
Aneesh RaoandGitHub 2dc29df57b Use FLUTTER_ROOT instead of FLUTTER_HOME 2020-11-19 20:31:28 +05:30
Alif RachmawadiandGitHub d141f1640a Merge pull request #64 from cclauss/patch-1
README.md: actions/checkout@v2
2020-10-20 20:03:42 +07:00
Christian ClaussandGitHub c4e0544d9c fixup! Fix typo 2020-10-20 14:50:34 +02:00
Christian ClaussandGitHub 2ff7205390 README.md: actions/checkout@v2 2020-10-14 12:50:28 +02:00
Alif Rachmawadi 4a44bbb8a6 update dist 2020-10-08 04:42:13 +00:00
Alif Rachmawadi d7578c4eec add support for master channel 2020-10-08 04:36:23 +00:00
19 changed files with 271 additions and 24807 deletions
+63 -11
View File
@@ -1,22 +1,74 @@
name: Main workflow
on: [push]
jobs:
run:
name: Run
test_channel:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest]
channel: [stable, beta, dev]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node.js 10.x
uses: actions/setup-node@v1
- uses: ./
with:
node-version: 10.x
- name: npm install
run: npm install
- name: Lint
run: npm run format-check
- name: npm test
run: npm test
channel: ${{ matrix.channel }}
- name: Print FLUTTER_ROOT
shell: bash
run: echo "FLUTTER_ROOT set to $FLUTTER_ROOT"
- name: Print PUBCACHE
shell: bash
run: echo "PUBCACHE set to $PUBCACHE"
- name: Run dart --version
shell: bash
run: dart --version
- name: Run flutter --version
shell: bash
run: flutter --version
test_version:
runs-on: ubuntu-latest
strategy:
matrix:
version: [ 2.5.3, 2.x, 1, v1.12 ]
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: ./
with:
channel: stable
flutter-version: ${{ matrix.version }}
- name: Run dart --version
shell: bash
run: dart --version
- name: Run flutter --version
shell: bash
run: flutter --version
test_master_channel:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: ./
with:
channel: master
- name: Run dart --version
shell: bash
run: dart --version
- name: Run flutter --version
shell: bash
run: flutter --version
test_any_channel:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: ./
with:
channel: any
flutter-version: 2
- name: Run dart --version
shell: bash
run: dart --version
- name: Run flutter --version
shell: bash
run: flutter --version
-3
View File
@@ -1,3 +0,0 @@
node_modules/
lib/
__tests__/runner/*
-11
View File
@@ -1,11 +0,0 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"parser": "typescript"
}
+107 -79
View File
@@ -6,82 +6,30 @@ This action sets up a flutter environment for use in actions. It works on Linux,
```yaml
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2
with:
flutter-version: '1.9.1+hotfix.6'
flutter-version: '2.0.5'
- run: flutter pub get
- run: flutter test
- run: flutter build apk
```
Build for iOS too (macOS only):
```yaml
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
flutter-version: '1.9.1+hotfix.6'
- run: flutter pub get
- run: flutter test
- run: flutter build apk
- run: flutter build ios --release --no-codesign
```
Use app bundle, instead of APK:
```yaml
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
flutter-version: '1.9.1+hotfix.6'
- run: flutter pub get
- run: flutter test
- run: flutter build appbundle
```
Build for the web:
```yaml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: subosito/flutter-action@v1
with:
channel: beta
- run: flutter config --enable-web
- run: flutter pub get
- run: flutter test
- run: flutter build web
```
Use latest release for particular channel:
```yaml
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2
with:
channel: 'stable' # or: 'dev' or 'beta'
channel: 'stable' # or: 'beta', 'dev' or 'master'
- run: flutter pub get
- run: flutter test
- run: flutter build apk
@@ -91,17 +39,100 @@ Use latest release for particular version and/or channel:
```yaml
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2
with:
flutter-version: '1.12.x' # you can use 1.12
channel: 'dev' # optional, default to: 'stable'
flutter-version: '1.22.x' # or, you can use 1.22
channel: 'dev'
- run: flutter pub get
- run: flutter test
```
Use particular version on any channel:
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2
with:
flutter-version: '2.x'
channel: 'any'
- run: flutter pub get
- run: flutter test
```
Build Android APK and app bundle:
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2
with:
flutter-version: '2.0.5'
- run: flutter pub get
- run: flutter test
- run: flutter build apk
- run: flutter build appbundle
```
Build for iOS too (macOS only):
```yaml
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2
with:
flutter-version: '2.0.5'
- run: flutter pub get
- run: flutter test
- run: flutter build apk
- run: flutter build ios --release --no-codesign
```
Build for the web:
```yaml
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
with:
flutter-version: '2.0.5'
- run: flutter pub get
- run: flutter test
- run: flutter build web
```
Build for Windows:
```yaml
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
with:
channel: beta
- run: flutter config --enable-windows-desktop
- run: flutter build windows
```
Matrix Testing:
@@ -115,18 +146,15 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2
with:
flutter-version: '1.11.0'
flutter-version: '1.20.2'
channel: 'beta'
- run: dart --version
- run: flutter --version
- run: flutter pub get
- run: flutter test
- run: flutter build apk
```
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-54
View File
@@ -1,54 +0,0 @@
import io = require('@actions/io');
import fs = require('fs');
import path = require('path');
import nock = require('nock');
const toolDir = path.join(__dirname, 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp');
const dataDir = path.join(__dirname, 'data');
process.env['RUNNER_TOOL_CACHE'] = toolDir;
process.env['RUNNER_TEMP'] = tempDir;
import * as installer from '../src/installer';
import * as release from '../src/release';
describe('installer tests', () => {
beforeAll(async () => {
await io.rmRF(toolDir);
await io.rmRF(tempDir);
}, 100000);
beforeEach(() => {
const platform = release.getPlatform();
nock('https://storage.googleapis.com', {allowUnmocked: true})
.get(`/flutter_infra/releases/releases_${platform}.json`)
.replyWithFile(200, path.join(dataDir, `releases_${platform}.json`));
});
afterEach(async () => {
nock.cleanAll();
nock.enableNetConnect();
await io.rmRF(toolDir);
await io.rmRF(tempDir);
}, 100000);
it('Downloads flutter', async () => {
await installer.getFlutter('1.0.0', 'stable');
const sdkDir = path.join(toolDir, 'flutter', '1.0.0-stable', 'x64');
expect(fs.existsSync(`${sdkDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(sdkDir, 'bin'))).toBe(true);
}, 300000);
it('Throws if no location contains correct flutter version', async () => {
let thrown = false;
try {
await installer.getFlutter('1000.0', 'dev');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
});
});
-117
View File
@@ -1,117 +0,0 @@
import fs = require('fs');
import path = require('path');
import nock = require('nock');
import * as release from '../src/release';
const platform = release.getPlatform();
describe('release tests', () => {
it('getPlatform', () => {
const platformMap: {[index: string]: string} = {
linux: 'linux',
darwin: 'macos',
win32: 'windows'
};
expect(platform).toEqual(platformMap[process.platform]);
});
describe('determineVersion', () => {
beforeEach(() => {
const dataDir = path.join(__dirname, 'data');
nock('https://storage.googleapis.com', {allowUnmocked: true})
.get(`/flutter_infra/releases/releases_${platform}.json`)
.replyWithFile(200, path.join(dataDir, `releases_${platform}.json`));
});
afterEach(() => {
nock.cleanAll();
nock.enableNetConnect();
});
it('channel: "stable", version: ""', async () => {
const result = await release.determineVersion('', 'stable', platform);
expect(result.version).toEqual('1.22.0');
expect(result.rawVersion).toEqual('1.22.0');
expect(result.downloadUrl).toContain('1.22.0');
});
it('channel: "beta", version: ""', async () => {
const result = await release.determineVersion('', 'beta', platform);
expect(result.version).toEqual('1.22.0-12.3.pre');
expect(result.rawVersion).toEqual('1.22.0-12.3.pre');
expect(result.downloadUrl).toContain('1.22.0-12.3.pre');
});
it('channel: "dev", version: ""', async () => {
const result = await release.determineVersion('', 'dev', platform);
expect(result.version).toEqual('1.23.0-7.0.pre');
expect(result.rawVersion).toEqual('1.23.0-7.0.pre');
expect(result.downloadUrl).toContain('1.23.0-7.0.pre');
});
it('channel: "dev", version: "1.17.x"', async () => {
const result = await release.determineVersion('1.17.x', 'dev', platform);
expect(result.version).toEqual('1.17.0-dev.5.0');
expect(result.rawVersion).toEqual('1.17.0-dev.5.0');
expect(result.downloadUrl).toContain('1.17.0-dev.5.0');
});
it('channel: "dev", version: "1.17"', async () => {
const result = await release.determineVersion('1.17', 'dev', platform);
expect(result.version).toEqual('1.17.0-dev.5.0');
expect(result.rawVersion).toEqual('1.17.0-dev.5.0');
expect(result.downloadUrl).toContain('1.17.0-dev.5.0');
});
it('channel: "dev", version: "1.7.x" (old format)', async () => {
const result = await release.determineVersion('1.7.x', 'dev', platform);
expect(result.version).toEqual('1.7.11');
expect(result.rawVersion).toEqual('v1.7.11');
expect(result.downloadUrl).toContain('v1.7.11');
});
it('channel: "dev", version: "1.7" (old format)', async () => {
const result = await release.determineVersion('1.7', 'dev', platform);
expect(result.version).toEqual('1.7.11');
expect(result.rawVersion).toEqual('v1.7.11');
expect(result.downloadUrl).toContain('v1.7.11');
});
it('channel: "dev", version: "0.12.x" (unknown)', async () => {
try {
await release.determineVersion('0.12.x', 'dev', platform);
} catch (e) {
expect(e.message).toEqual('unable to find release for 0.12.x');
}
});
it('channel: "dev", version: "0.12" (unknown)', async () => {
try {
await release.determineVersion('0.12', 'dev', platform);
} catch (e) {
expect(e.message).toEqual('unable to find release for 0.12');
}
});
it('channel: "dev", version: "1.17.0-dev.5.0"', async () => {
const result = await release.determineVersion(
'1.17.0-dev.5.0',
'dev',
platform
);
expect(result.version).toEqual('1.17.0-dev.5.0');
expect(result.rawVersion).toEqual('1.17.0-dev.5.0');
expect(result.downloadUrl).toContain('1.17.0-dev.5.0');
});
});
});
+7 -5
View File
@@ -1,6 +1,9 @@
name: 'Flutter action'
description: 'Setup your runner with Flutter environment'
author: 'Alif Rachmawadi'
branding:
icon: 'maximize'
color: 'blue'
inputs:
flutter-version:
description: 'The Flutter version to make available on the path'
@@ -10,8 +13,7 @@ inputs:
required: false
default: 'stable'
runs:
using: 'node12'
main: 'dist/index.js'
branding:
icon: 'maximize'
color: 'blue'
using: 'composite'
steps:
- run: $GITHUB_ACTION_PATH/setup.sh ${{ inputs.channel }} ${{ inputs.flutter-version }}
shell: bash
-7550
View File
File diff suppressed because it is too large Load Diff
-11
View File
@@ -1,11 +0,0 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}
-7827
View File
File diff suppressed because it is too large Load Diff
-53
View File
@@ -1,53 +0,0 @@
{
"name": "flutter-action",
"version": "1.3.2",
"private": true,
"description": "Flutter environment for use in actions",
"main": "lib/index.js",
"scripts": {
"build-tsc": "tsc",
"build-ncc": "ncc build",
"build": "run-s build-tsc build-ncc",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"test": "jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/subosito/flutter-action.git"
},
"keywords": [
"actions",
"node",
"flutter",
"setup"
],
"author": "Alif Rachmawadi <arch@subosito.com>",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/exec": "^1.0.4",
"@actions/http-client": "^1.0.8",
"@actions/io": "^1.0.2",
"@actions/tool-cache": "^1.6.0",
"semver": "^7.3.2",
"uuid": "^8.3.1"
},
"devDependencies": {
"@types/jest": "^26.0.14",
"@types/node": "^14.11.5",
"@types/semver": "^7.3.4",
"@types/uuid": "^8.3.0",
"@vercel/ncc": "^0.24.1",
"jest": "^26.5.2",
"jest-circus": "^26.5.2",
"nock": "^13.0.4",
"npm-run-all": "^4.1.5",
"prettier": "1.19.1",
"ts-jest": "^26.4.1",
"typescript": "^4.0.3"
},
"resolutions": {
"minimist": "^1.2.2"
}
}
Executable
+94
View File
@@ -0,0 +1,94 @@
#!/bin/bash
OS_NAME=$(echo "$RUNNER_OS" | awk '{print tolower($0)}')
MANIFEST_BASE_URL="https://storage.googleapis.com/flutter_infra_release/releases"
MANIFEST_URL="${MANIFEST_BASE_URL}/releases_${OS_NAME}.json"
# convert version like 2.5.x to 2.5
normalize_version() {
if [[ $1 == *x ]]; then
echo ${1::-2}
else
echo $1
fi
}
latest_version() {
jq --arg channel "$1" '.releases | map(select(.channel==$channel)) | first'
}
wildcard_version() {
if [[ $1 == any ]]; then
jq --arg version "^$2" '.releases | map(select(.version | test($version))) | first'
else
jq --arg channel "$1" --arg version "^$2" '.releases | map(select(.channel==$channel) | select(.version | test($version))) | first'
fi
}
get_version() {
if [[ -z $2 ]]; then
latest_version $1
else
wildcard_version $1 $2
fi
}
get_version_manifest() {
releases_manifest=$(curl --silent --connect-timeout 15 --retry 5 $MANIFEST_URL)
version_manifest=$(echo $releases_manifest | get_version $1 $(normalize_version $2))
if [[ $version_manifest == null ]]; then
# fallback through legacy version format
echo $releases_manifest | wildcard_version $1 "v$(normalize_version $2)"
else
echo $version_manifest
fi
}
download_archive() {
archive_url="$MANIFEST_BASE_URL/$1"
archive_name=$(basename $1)
archive_local="$HOME/$archive_name"
curl --connect-timeout 15 --retry 5 $archive_url >$archive_local
if [[ $archive_name == *zip ]]; then
unzip -o "$archive_local" -d "$2"
else
tar xf "$archive_local" -C "$2"
fi
rm $archive_local
}
CHANNEL="$1"
VERSION="$2"
if [[ $CHANNEL == master ]]; then
git clone -b master https://github.com/flutter/flutter.git "$RUNNER_TOOL_CACHE/flutter"
else
VERSION_MANIFEST=$(get_version_manifest $CHANNEL $VERSION)
if [[ $VERSION_MANIFEST == null ]]; then
echo "Unable to determine Flutter version for $CHANNEL $VERSION"
exit 1
fi
ARCHIVE_PATH=$(echo $VERSION_MANIFEST | jq -r '.archive')
download_archive "$ARCHIVE_PATH" "$RUNNER_TOOL_CACHE"
fi
if [[ $OS_NAME == windows ]]; then
FLUTTER_ROOT="${RUNNER_TOOL_CACHE}\\flutter"
PUBCACHE="${USERPROFILE}\\.pub-cache"
else
FLUTTER_ROOT="${RUNNER_TOOL_CACHE}/flutter"
PUBCACHE="${HOME}/.pub-cache"
fi
echo "FLUTTER_ROOT=${FLUTTER_ROOT}" >>$GITHUB_ENV
echo "PUB_CACHE=${PUBCACHE}" >>$GITHUB_ENV
echo "${FLUTTER_ROOT}/bin" >>$GITHUB_PATH
echo "${FLUTTER_ROOT}/bin/cache/dart-sdk/bin" >>$GITHUB_PATH
echo "${PUBCACHE}/bin" >>$GITHUB_PATH
-15
View File
@@ -1,15 +0,0 @@
import * as core from '@actions/core';
import * as installer from './installer';
async function run() {
try {
const version = core.getInput('flutter-version') || '';
const channel = core.getInput('channel') || 'stable';
await installer.getFlutter(version, channel);
} catch (error) {
core.setFailed(error.message);
}
}
run();
-103
View File
@@ -1,103 +0,0 @@
import * as core from '@actions/core';
import * as io from '@actions/io';
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(
version: string,
channel: string
): Promise<void> {
const platform = release.getPlatform();
const {version: selected, downloadUrl} = await release.determineVersion(
version,
channel,
platform
);
let cleanver = `${selected.replace('+', '-')}-${channel}`;
let toolPath = tc.find('flutter', cleanver);
if (toolPath) {
core.debug(`Tool found in cache ${toolPath}`);
} else {
core.debug(`Downloading Flutter from Google storage ${downloadUrl}`);
const sdkFile = await tc.downloadTool(downloadUrl);
const sdkCache = await tmpDir(platform);
const sdkDir = await extract(sdkFile, sdkCache, path.basename(downloadUrl));
toolPath = await tc.cacheDir(sdkDir, 'flutter', cleanver);
}
core.exportVariable('FLUTTER_HOME', toolPath);
core.addPath(path.join(toolPath, 'bin'));
core.addPath(path.join(toolPath, 'bin', 'cache', 'dart-sdk', 'bin'));
}
function tmpBaseDir(platform: string): string {
let tempDirectory = process.env['RUNNER_TEMP'] || '';
if (tempDirectory) {
return tempDirectory;
}
let baseLocation;
switch (platform) {
case 'windows':
baseLocation = process.env['USERPROFILE'] || 'C:\\';
break;
case 'macos':
baseLocation = '/Users';
break;
default:
baseLocation = '/home';
break;
}
return path.join(baseLocation, 'actions', 'temp');
}
async function tmpDir(platform: string): Promise<string> {
const baseDir = tmpBaseDir(platform);
const tempDir = path.join(
baseDir,
'temp_' + Math.floor(Math.random() * 2000000000)
);
await io.mkdirP(tempDir);
return tempDir;
}
async function extract(
sdkFile: string,
sdkCache: string,
originalFilename: string
): Promise<string> {
const fileStats = fs.statSync(path.normalize(sdkFile));
if (fileStats.isFile()) {
const stats = fs.statSync(sdkFile);
if (!stats) {
throw new Error(`Failed to extract ${sdkFile} - it doesn't exist`);
} else if (stats.isDirectory()) {
throw new Error(`Failed to extract ${sdkFile} - it is a directory`);
}
if (originalFilename.endsWith('tar.xz')) {
await tc.extractTar(sdkFile, sdkCache, 'x');
} else {
await tc.extractZip(sdkFile, sdkCache);
}
return path.join(sdkCache, fs.readdirSync(sdkCache)[0]);
} else {
throw new Error(`Flutter sdk argument ${sdkFile} is not a file`);
}
}
-175
View File
@@ -1,175 +0,0 @@
import * as core from '@actions/core';
import * as httpm from '@actions/http-client';
import * as semver from 'semver';
export const storageUrl =
'https://storage.googleapis.com/flutter_infra/releases';
interface IFlutterChannel {
[key: string]: string;
beta: string;
dev: string;
stable: string;
}
interface IFlutterRelease {
hash: string;
channel: string;
version: string;
archive: string;
}
interface IFlutterStorage {
current_release: IFlutterChannel;
releases: IFlutterRelease[];
}
export function getPlatform(): string {
const platform = process.platform;
if (platform == 'win32') {
return 'windows';
}
if (platform == 'darwin') {
return 'macos';
}
return platform;
}
export async function determineVersion(
version: string,
channel: string,
platform: string
): Promise<{version: string; rawVersion: string; downloadUrl: string}> {
const storage = await getReleases(platform);
if (version === '') {
return getLatestVersion(storage, channel);
}
if (version.endsWith('.x')) {
return getWildcardVersion(storage, channel, version);
}
return getVersion(storage, channel, version);
}
async function getReleases(platform: string): Promise<IFlutterStorage> {
const releasesUrl: string = `${storageUrl}/releases_${platform}.json`;
const http: httpm.HttpClient = new httpm.HttpClient('flutter-action');
const storage: IFlutterStorage | null = (
await http.getJson<IFlutterStorage | null>(releasesUrl)
).result;
if (!storage) {
throw new Error('unable to get flutter releases');
}
return storage;
}
async function getLatestVersion(
storage: IFlutterStorage,
channel: string
): Promise<{version: string; rawVersion: string; downloadUrl: string}> {
const channelVersion = storage.releases.find(release => {
return (
release.hash === storage.current_release[channel] &&
release.channel == channel
);
});
if (!channelVersion) {
throw new Error(`unable to get latest version from channel ${channel}`);
}
let rver = channelVersion.version;
let cver = rver.startsWith('v') ? rver.slice(1, rver.length) : rver;
core.debug(`latest version from channel ${channel} is ${rver}`);
return {
version: cver,
rawVersion: rver,
downloadUrl: `${storageUrl}/${channelVersion.archive}`
};
}
async function getWildcardVersion(
storage: IFlutterStorage,
channel: string,
version: string
): Promise<{version: string; rawVersion: string; downloadUrl: string}> {
let sver = version.endsWith('.x')
? version.slice(0, version.length - 2)
: version;
const releases = storage.releases.filter(release => {
if (release.channel != channel) return false;
return prefixCompare(sver, release.version);
});
const versions = releases
.map(release => release.version)
.map(version =>
version.startsWith('v') ? version.slice(1, version.length) : version
);
const sortedVersions = versions.sort(semver.rcompare);
let cver = sortedVersions[0];
let release = releases.find(release => compare(cver, release.version));
if (!release) {
throw new Error(`unable to find release for ${version}`);
}
core.debug(
`latest version of ${version} from channel ${channel} is ${release.version}`
);
return {
version: cver,
rawVersion: release.version,
downloadUrl: `${storageUrl}/${release.archive}`
};
}
async function getVersion(
storage: IFlutterStorage,
channel: string,
version: string
): Promise<{version: string; rawVersion: string; downloadUrl: string}> {
const release = storage.releases.find(release => {
if (release.channel != channel) return false;
return compare(version, release.version);
});
if (!release) {
return getWildcardVersion(storage, channel, version);
}
return {
version,
rawVersion: release.version,
downloadUrl: `${storageUrl}/${release.archive}`
};
}
function compare(version: string, releaseVersion: string): boolean {
if (releaseVersion.startsWith('v')) {
return releaseVersion === `v${version}`;
}
return releaseVersion === version;
}
function prefixCompare(version: string, releaseVersion: string): boolean {
if (releaseVersion.startsWith('v')) {
return releaseVersion.startsWith(`v${version}`);
}
return releaseVersion.startsWith(version);
}
-11
View File
@@ -1,11 +0,0 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "./lib",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true
},
"exclude": ["node_modules", "**/*.test.ts"]
}