Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix publish workflow #162

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.number }}
PR_LABELS: "${{ join(github.event.pull_request.labels.*.name) }}"
run: dart pub global run firehose --validate --use-flutter ${{ inputs.use-flutter }}
run: dart pub global run firehose --validate ${{ inputs.use-flutter && '--use-flutter' || '--no-use-flutter' }}

publish:
if: ${{ github.event_name == 'push' }}
Expand Down Expand Up @@ -124,4 +124,4 @@ jobs:
run: dart pub global activate firehose

- name: Publish packages
run: dart pub global run firehose --publish --use-flutter ${{ inputs.use-flutter }}
run: dart pub global run firehose --publish ${{ inputs.use-flutter && '--use-flutter' || '--no-use-flutter' }}
2 changes: 2 additions & 0 deletions pkgs/firehose/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
## 0.3.27

- Fix Flutter support.

## 0.3.26

- Add support for Flutter package auto-publishing, fixing [#154](https://github.com/dart-lang/ecosystem/issues/154).

## 0.3.25

- Switch to pub.dev API in `package:firehose`.
Expand Down
29 changes: 15 additions & 14 deletions pkgs/firehose/bin/firehose.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,40 @@ import 'package:args/args.dart';
import 'package:firehose/firehose.dart';
import 'package:firehose/src/github.dart';

const validateOption = 'validate';
const publishOption = 'publish';
const useFlutterOption = 'use-flutter';
const helpFlag = 'help';
const validateFlag = 'validate';
const publishFlag = 'publish';
const useFlutterFlag = 'use-flutter';

void main(List<String> arguments) async {
var argParser = _createArgs();
try {
var argResults = argParser.parse(arguments);
final argResults = argParser.parse(arguments);

if (argResults['help'] == true) {
if (argResults[helpFlag] as bool) {
_usage(argParser);
exit(0);
}

var validate = argResults[validateOption] == true;
var publish = argResults[publishOption] == true;
var useFlutter = argResults[useFlutterOption] == true;
final validate = argResults[validateFlag] as bool;
final publish = argResults[publishFlag] as bool;
final useFlutter = argResults[useFlutterFlag] as bool;

if (!validate && !publish) {
_usage(argParser,
error: 'Error: one of --validate or --publish must be specified.');
exit(1);
}

var github = Github();
final github = Github();
if (publish && !github.inGithubContext) {
_usage(argParser,
error: 'Error: --publish can only be executed from within a GitHub '
'action.');
exit(1);
}

var firehose = Firehose(Directory.current, useFlutter);
final firehose = Firehose(Directory.current, useFlutter);

if (validate) {
await firehose.validate();
Expand All @@ -67,24 +68,24 @@ void _usage(ArgParser argParser, {String? error}) {
ArgParser _createArgs() {
return ArgParser()
..addFlag(
'help',
helpFlag,
abbr: 'h',
negatable: false,
help: 'Print tool help.',
)
..addFlag(
validateOption,
validateFlag,
negatable: false,
help: 'Validate packages and indicate whether --publish would publish '
'anything.',
)
..addFlag(
publishOption,
publishFlag,
negatable: false,
help: 'Publish any changed packages.',
)
..addFlag(
useFlutterOption,
useFlutterFlag,
negatable: true,
help: 'Whether this is a Flutter project.',
);
Expand Down