Skip to content

Commit 449da81

Browse files
committed
feature added + docs updated
1 parent 3cbf56d commit 449da81

File tree

6 files changed

+53
-31
lines changed

6 files changed

+53
-31
lines changed

README.md

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# GitHub Action — Get Target Platforms of Your Flutter Project from the pubspec File.
22

3-
This GitHub Action (written in composite run steps) allows you to leverage GitHub Actions to get the [Flutter](https://flutter.dev) Platforms from the pubspec file.
3+
This GitHub Action allows you to get The Target Platforms from the pubspec file with Name of it!
4+
5+
also optionally you can get value of any key inside pubspec.yaml file with passing 'custom_key' to it!
46

57
## Usage
68
### Pre-requisites
@@ -9,18 +11,21 @@ Create a workflow `.yml` file in your `.github/workflows` directory. An [example
911
### Inputs
1012
For more information on this input, see the [Workflow syntax for GitHub Actions](https://docs.github.com/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepswith)
1113

12-
* `pubspec-file-path`: The pubspec.yaml file path. Optional. Default: `pubspec.yaml`
14+
* `pubspec_path`: The pubspec.yaml file path. Optional. Default: `pubspec.yaml`
15+
* `custom_key`: a custom key for retrive from pubspec.yaml file(optional).
1316

1417
### Outputs
1518
For more information on this output, see the [Workflow syntax for GitHub Actions](https://docs.github.com/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs) and the [Context and expression syntax for GitHub Actions](https://docs.github.com/actions/reference/context-and-expression-syntax-for-github-actions#steps-context)
1619

1720
* `name`: your Flutter project name
18-
* `android`: your Flutter project should Release on android platform
19-
* `ios`: your Flutter project should Release on ios platform
20-
* `web`: your Flutter project should Release on web platform
21-
* `windows`: your Flutter project should Release on windows platform
22-
* `linux`: your Flutter project should Release on linux platform
23-
* `macos`: your Flutter project should Release on macos platform
21+
* `android`: your Flutter project should Release on android platform(String Boolean)
22+
* `ios`: your Flutter project should Release on ios platform(String Boolean)
23+
* `web`: your Flutter project should Release on web platform(String Boolean)
24+
* `windows`: your Flutter project should Release on windows platform(String Boolean)
25+
* `linux`: your Flutter project should Release on linux platform(String Boolean)
26+
* `macos`: your Flutter project should Release on macos platform(String Boolean)
27+
* `macos`: your Flutter project should Release on macos platform(String Boolean)
28+
* `custom_value`: value of the custom key retrived from pubspec.yaml file
2429

2530
### Common workflow
2631

@@ -33,7 +38,8 @@ platforms:
3338
windows:
3439
macos:
3540
```
36-
2. Use the action's output as an input to [Flutter action](https://github.com/marketplace/actions/flutter-action). For example:
41+
42+
For example:
3743
```yaml
3844
on: push
3945

@@ -46,21 +52,18 @@ jobs:
4652
steps:
4753
- name: Checkout code
4854
uses: actions/checkout@v2
49-
- name: Get Flutter version
50-
id: get-flutter-version
51-
uses: zgosalvez/github-actions-get-flutter-version-env@v2
52-
- name: Set up Flutter
53-
uses: subosito/flutter-action@v1
55+
- name: Get Target Platforms from pubspec.yaml
56+
id: platform_check
57+
uses: Ali-Fadaei/flutter-platforms-action@v1.0.3
5458
with:
55-
flutter-version: ${{ steps.get-flutter-version.outputs.version }}
59+
custom_key: custom_key_wanted_from_pubspec.yml
60+
outputs:
61+
package_name: ${{steps.platform_check.outputs.name}}
62+
build_android: ${{steps.platform_check.outputs.android}}
63+
build_web: ${{steps.platform_check.outputs.web}}
64+
build_windows: ${{steps.platform_check.outputs.windows}}
65+
build_ios: ${{steps.platform_check.outputs.ios}}
66+
build_linux: ${{steps.platform_check.outputs.linux}}
67+
build_macos: ${{steps.platform_check.outputs.macos}}
68+
custom_key_value: ${{steps.platform_check.outputs.custom-value}}
5669
```
57-
58-
## Shout-out
59-
A special mention goes to [@daohoangson](https://github.com/daohoangson), who came up with the initial solution at [subosito/flutter-action/issues/47#issuecomment-675821988](https://github.com/subosito/flutter-action/issues/47#issuecomment-675821988).
60-
61-
### Flutter Workflows
62-
63-
This is used in my opinionated [GitHub Actions: Flutter Workflows](https://github.com/zgosalvez/github-actions-flutter-workflows) repository along with other actions for a complete end-to-end DevOps experience.
64-
65-
## License
66-
The scripts and documentation in this project are released under the [MIT License](LICENSE.md)

action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ name: 'Get Target Platforms from pubspec.yaml'
22
description: 'Get Target Platforms of Your Flutter Project from the pubspec File.'
33
author: 'Ali Fadaei'
44
inputs:
5-
pubspec-path:
5+
pubspec_path:
66
description: 'The pubspec.yaml file path. Optional. Default: `pubspec.yaml`'
77
default: 'pubspec.yaml'
8+
custom_key:
9+
description: 'a custom key for retrive from pubspec.yaml file'
10+
required: false
11+
812
outputs:
913
name:
1014
description: "your Flutter project name"
@@ -20,6 +24,9 @@ outputs:
2024
description: "your Flutter project should Release on linux platform"
2125
macos:
2226
description: "your Flutter project should Release on macos platform"
27+
custom_value:
28+
description: 'value of the custom key retrived from pubspec.yaml file'
29+
2330

2431
runs:
2532
using: 'node20'

dist/index.js

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "flutter-platforms-action",
3-
"version": "1.0.0",
4-
"description": "Get Target Platforms of Your Flutter Project from the pubspec File.",
3+
"version": "1.0.3",
4+
"description": "Get Target Platforms from pubspec.yaml",
55
"main": "dist/index.js",
66
"scripts": {
77
"lint": "eslint .",

src/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ const yaml = require('yaml');
44

55
async function run() {
66
try {
7-
const pubspecFilePath = core.getInput('pubspec-path');
7+
const pubspecFilePath = core.getInput('pubspec_path');
8+
const customKey = core.getInput('custom_key');
89
const fileContents = fs.readFileSync(pubspecFilePath, 'utf8');
910
const yamlContents = yaml.parse(fileContents);
1011
const platforms = yamlContents['platforms'];
@@ -31,6 +32,8 @@ async function run() {
3132

3233
const macos = platforms['macos'] !== undefined;
3334

35+
const customValue = yamlContents[customKey];
36+
3437
core.setOutput('name', name);
3538

3639
core.setOutput('android', android);
@@ -45,6 +48,9 @@ async function run() {
4548

4649
core.setOutput('macos', macos);
4750

51+
if (customValue !== undefined)
52+
core.setOutput('custom_value', customValue);
53+
4854
} catch (error) {
4955
core.setFailed(error.message);
5056
}

0 commit comments

Comments
 (0)