Skip to content

Commit

Permalink
Merge pull request #14 from ilteoood/master
Browse files Browse the repository at this point in the history
Added dry run option + script refactor
  • Loading branch information
sakebook authored May 23, 2020
2 parents 150ed86 + bd221f9 commit 618eb17
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ You can use `open ~/.pub-cache`.

**Optional** Package directory. Default: `"."`

### `dry_run`

**Optional** Dry run, no publish. Default: `false`

## Example usage

```yaml
Expand All @@ -46,4 +50,5 @@ jobs:
credential: ${{ secrets.CREDENTIAL_JSON }}
flutter_package: false
skip_test: true
dry_run: true
```
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ inputs:
description: '(Optional) Package directory (default: ".")'
required: false
default: '.'
dry_run:
description: '(Optional) Dry run, no publish (default: false)'
required: false
default: false
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
49 changes: 21 additions & 28 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,52 +25,45 @@ EOF
echo "OK"
}

test_dart() {
echo "Run test for dart"
pub get
pub test
create_prefix() {
FLUTTER_PREFIX=""
PUB_PREFIX="pub"
if "${INPUT_FLUTTER_PACKAGE}"; then
FLUTTER_PREFIX="flutter"
PUB_PREFIX=""
fi
}

test_flutter() {
echo "Run test for flutter"
flutter pub get
flutter test
test() {
echo "Run test"
$FLUTTER_PREFIX pub get
$FLUTTER_PREFIX $PUB_PREFIX test
}

run_test_if_needed() {
if "${INPUT_SKIP_TEST}"; then
echo 'Skip test'
else
if "${INPUT_FLUTTER_PACKAGE}"; then
test_flutter
else
test_dart
fi
test
fi
}

publish_package_dart() {
echo "Publish dart package to Pub"
pub publish --dry-run
pub publish -f
}

publish_package_flutter() {
echo "Publish flutter package to Pub"
flutter pub pub publish --dry-run
flutter pub pub publish -f
dry_run() {
echo "Executing package validation"
$FLUTTER_PREFIX pub publish --dry-run
}

publish_package() {
if "${INPUT_FLUTTER_PACKAGE}"; then
publish_package_flutter
else
publish_package_dart
dry_run
if [ "${INPUT_DRY_RUN}" = false ]; then
echo "Publish package to Pub"
$FLUTTER_PREFIX pub publish -f
fi
}

check_credentials
copy_credential
switch_working_directory
create_prefix
run_test_if_needed
publish_package
publish_package

0 comments on commit 618eb17

Please sign in to comment.