Skip to content

Commit 3e4f286

Browse files
authored
Add ignore flag for publish.yaml (#237)
* Add ignore flag for `publish.yaml` * Add local debug of publish * Fix path * Add multiline * Add ignore-packages option * Comment on workflows * Rev version * Add documentation
1 parent 7d8ec47 commit 3e4f286

File tree

8 files changed

+55
-80
lines changed

8 files changed

+55
-80
lines changed

.github/workflows/post_summaries.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
workflow_call:
77
workflow_run:
88
workflows:
9-
- Publish
9+
- Publish:Internal
1010
- Health:Internal
1111
types:
1212
- completed

.github/workflows/publish.yaml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ name: Publish
4646
# with:
4747
# write-comments: false
4848

49+
# It is also possible to ignore certain packages in the repository
50+
# via a glob.
51+
#
52+
# jobs:
53+
# publish:
54+
# uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main
55+
# with:
56+
# ignore-packages: pkgs/non-published-package
57+
4958
on:
5059
workflow_call:
5160
inputs:
@@ -83,6 +92,16 @@ on:
8392
default: false
8493
required: false
8594
type: boolean
95+
ignore-packages:
96+
description: Which packages to ignore.
97+
default: "\"\""
98+
required: false
99+
type: string
100+
local_debug:
101+
description: Whether to use a local copy of package:firehose - only for debug
102+
default: false
103+
type: boolean
104+
required: false
86105

87106
jobs:
88107
# Note that this job does not require the specified environment.
@@ -113,13 +132,22 @@ jobs:
113132

114133
- name: Install firehose
115134
run: dart pub global activate firehose
135+
if: ${{ !inputs.local_debug }}
116136

137+
- name: Install local firehose
138+
run: dart pub global activate --source path pkgs/firehose/
139+
if: ${{ inputs.local_debug }}
140+
117141
- name: Validate packages
118142
env:
119143
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120144
ISSUE_NUMBER: ${{ github.event.number }}
121145
PR_LABELS: "${{ join(github.event.pull_request.labels.*.name) }}"
122-
run: dart pub global run firehose --validate ${{ fromJSON('{"true":"--use-flutter","false":"--no-use-flutter"}')[inputs.use-flutter] }}
146+
run: |
147+
dart pub global run firehose \
148+
--validate \
149+
${{ fromJSON('{"true":"--use-flutter","false":"--no-use-flutter"}')[inputs.use-flutter] }} \
150+
--ignore-packages ${{ inputs.ignore-packages }}
123151
124152
- name: Get comment id
125153
if: ${{ (hashFiles('output/comment.md') != '') && inputs.write-comments }}

.github/workflows/publish_internal.yaml

Lines changed: 6 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3,81 +3,17 @@
33
# We don't use the regular publish.yaml script here in order to dogfood the
44
# publishing code at head.
55

6-
name: Publish
7-
6+
name: Publish:Internal
87
on:
98
pull_request:
109
branches: [ main ]
1110
types: [opened, synchronize, reopened, labeled, unlabeled]
1211
push:
1312
tags: [ '[A-z]+-v[0-9]+.[0-9]+.[0-9]+*' ]
14-
15-
env:
16-
use-flutter: false
17-
write-comments: false
18-
1913
jobs:
2014
publish:
21-
if: github.repository_owner == 'dart-lang'
22-
23-
# These permissions are required for authentication using OIDC and to enable
24-
# us to create comments on PRs.
25-
permissions:
26-
id-token: write
27-
pull-requests: write
28-
29-
runs-on: ubuntu-latest
30-
steps:
31-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
32-
- uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
33-
34-
- name: Pub get
35-
working-directory: pkgs/firehose
36-
run: dart pub get
37-
38-
- name: Validate packages
39-
if: ${{ github.event_name == 'pull_request' }}
40-
env:
41-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42-
ISSUE_NUMBER: ${{ github.event.number }}
43-
PR_LABELS: "${{ join(github.event.pull_request.labels.*.name) }}"
44-
run: dart pkgs/firehose/bin/firehose.dart --validate ${{ fromJSON('{"true":"--use-flutter","false":"--no-use-flutter"}')[env.use-flutter] }}
45-
46-
- name: Get comment id
47-
if: ${{ (hashFiles('output/comment.md') != '') && fromJSON(env.write-comments ) }}
48-
run: |
49-
touch -a output/commentId
50-
COMMENT_ID=$(cat output/commentId)
51-
echo "COMMENT_ID=$COMMENT_ID" >> $GITHUB_ENV
52-
53-
- name: Create comment
54-
uses: peter-evans/create-or-update-comment@3509deb8e3e0d7847ba5297bcac581b636533971
55-
if: ${{ (hashFiles('output/comment.md') != '') && fromJSON(env.write-comments ) && (env.COMMENT_ID == '') }}
56-
with:
57-
issue-number: ${{ github.event.number }}
58-
body-path: 'output/comment.md'
59-
edit-mode: replace
60-
61-
- name: Update comment
62-
uses: peter-evans/create-or-update-comment@3509deb8e3e0d7847ba5297bcac581b636533971
63-
if: ${{ (hashFiles('output/comment.md') != '') && fromJSON(env.write-comments ) && (env.COMMENT_ID != '') }}
64-
with:
65-
comment-id: ${{ env.COMMENT_ID }}
66-
body-path: 'output/comment.md'
67-
edit-mode: replace
68-
69-
- name: Save PR number
70-
if: ${{ !fromJSON(env.write-comments ) }}
71-
run: |
72-
mkdir -p output/ && echo ${{ github.event.number }} > output/issueNumber
73-
74-
- name: Upload folder with number and markdown
75-
if: ${{ !fromJSON(env.write-comments ) }}
76-
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
77-
with:
78-
name: output
79-
path: output/
80-
81-
- name: Publish tagged package
82-
if: ${{ github.event_name == 'push' }}
83-
run: dart pkgs/firehose/bin/firehose.dart --publish ${{ fromJSON('{"true":"--use-flutter","false":"--no-use-flutter"}')[env.use-flutter] }}
15+
uses: ./.github/workflows/publish.yaml
16+
with:
17+
local_debug: true
18+
use-flutter: false
19+
write-comments: false

pkgs/firehose/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.7.0
2+
3+
- Add `ignore-packages` flag to the publish workflow.
4+
15
## 0.6.1
26

37
- Add `ignore` flags to the health workflow.

pkgs/firehose/bin/firehose.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'dart:io';
77
import 'package:args/args.dart';
88
import 'package:firehose/firehose.dart';
99
import 'package:firehose/src/github.dart';
10+
import 'package:glob/glob.dart';
1011

1112
const helpFlag = 'help';
1213
const validateFlag = 'validate';
@@ -26,6 +27,10 @@ void main(List<String> arguments) async {
2627
final validate = argResults[validateFlag] as bool;
2728
final publish = argResults[publishFlag] as bool;
2829
final useFlutter = argResults[useFlutterFlag] as bool;
30+
final ignoredPackages = (argResults['ignore-packages'] as List<String>)
31+
.where((pattern) => pattern.isNotEmpty)
32+
.map((pattern) => Glob(pattern, recursive: true))
33+
.toList();
2934

3035
if (!validate && !publish) {
3136
_usage(argParser,
@@ -41,7 +46,7 @@ void main(List<String> arguments) async {
4146
exit(1);
4247
}
4348

44-
final firehose = Firehose(Directory.current, useFlutter);
49+
final firehose = Firehose(Directory.current, useFlutter, ignoredPackages);
4550

4651
if (validate) {
4752
await firehose.validate();
@@ -88,5 +93,9 @@ ArgParser _createArgs() {
8893
useFlutterFlag,
8994
negatable: true,
9095
help: 'Whether this is a Flutter project.',
96+
)
97+
..addMultiOption(
98+
'ignore-packages',
99+
help: 'Which packages to ignore.',
91100
);
92101
}

pkgs/firehose/lib/firehose.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ const String _ignoreWarningsLabel = 'publish-ignore-warnings';
2525
class Firehose {
2626
final Directory directory;
2727
final bool useFlutter;
28+
final List<Glob> ignoredPackages;
2829

29-
Firehose(this.directory, this.useFlutter);
30+
Firehose(this.directory, this.useFlutter, this.ignoredPackages);
3031

3132
/// Validate the packages in the repository.
3233
///
@@ -92,10 +93,7 @@ Saving existing comment id $existingCommentId to file ${idFile.path}''');
9293
github.close();
9394
}
9495

95-
Future<VerificationResults> verify(
96-
GithubApi github, [
97-
List<Glob> ignoredPackages = const [],
98-
]) async {
96+
Future<VerificationResults> verify(GithubApi github) async {
9997
var repo = Repository(directory);
10098
var packages = repo.locatePackages(ignoredPackages);
10199

pkgs/firehose/lib/src/health/health.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class Health {
146146
Future<HealthCheckResult> validateCheck() async {
147147
//TODO: Add Flutter support for PR health checks
148148
var results =
149-
await Firehose(directory, false).verify(github, ignoredPackages);
149+
await Firehose(directory, false, ignoredPackages).verify(github);
150150

151151
var markdownTable = '''
152152
| Package | Version | Status |

pkgs/firehose/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: firehose
22
description: A tool to automate publishing of Pub packages from GitHub actions.
3-
version: 0.6.1
3+
version: 0.7.0
44
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose
55

66
environment:

0 commit comments

Comments
 (0)