Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a01aede
Support package provenance signing in publish workflow and firehose
mosuem Aug 14, 2026
dd40ae0
Add --package-only mode to firehose and attest-build-provenance step …
mosuem Aug 14, 2026
61912c0
Fix analysis warnings in tests and add attestations permission to pub…
mosuem Aug 14, 2026
9f39c57
Fix commit SHA pin for actions/attest-build-provenance
mosuem Aug 14, 2026
843e694
Use actions/attest instead of actions/attest-build-provenance
mosuem Aug 14, 2026
ca8f3f5
Isolate packaging and attestation into separate jobs for SLSA L3
mosuem Aug 18, 2026
df3936d
Pass --skip-validation to pub publish --to-archive for hermetic packa…
mosuem Aug 18, 2026
3c5ea66
Add validate-release job before hermetic packaging
mosuem Aug 18, 2026
6febfc1
Remove actions/cache from release jobs for clean-room hermetic builds
mosuem Aug 18, 2026
be27129
Execute pub publish --to-archive inside unshare -r -n on Linux
mosuem Aug 18, 2026
45e4178
Wrap firehose --package-only step in unshare -r -n in publish.yaml
mosuem Aug 18, 2026
b4d9bb3
Fix actions/upload-artifact hash pin and add contents: read to publis…
mosuem Aug 18, 2026
f21ab82
Add skip-validation workflow input and git tag override support
mosuem Aug 18, 2026
32ac4c5
Activate firehose using the called workflow_ref in external repos
mosuem Aug 19, 2026
f17dff0
Add firehose_ref input to allow testing branches in external repos
mosuem Aug 19, 2026
bb1c806
Use sudo unshare -n to isolate network namespace on GitHub Actions ru…
mosuem Aug 19, 2026
d951a87
Pass -H to sudo to set user home directory properly
mosuem Aug 19, 2026
b7392c0
Preserve environment with sudo -E when running firehose in unshare
mosuem Aug 19, 2026
6988fac
Upload attestation-bundle as a downloadable workflow artifact
mosuem Aug 19, 2026
e78d744
Support use-prebuilt-archive input for custom caller build pipelines
mosuem Aug 19, 2026
bba1780
Fix zizmor template-injection warnings by passing FIREHOSE_REF via env
mosuem Aug 19, 2026
15b0423
Use job.workflow_sha to automatically pin firehose to the reusable wo…
mosuem Aug 19, 2026
c6b6da9
Remove firehose_ref input and rely on job.workflow_sha
mosuem Aug 19, 2026
c108f13
Strictly use job.workflow_sha for firehose activation without fallback
mosuem Aug 19, 2026
acff054
Set FIREHOSE_REF at job-level env for all jobs
mosuem Aug 19, 2026
0efc029
Use dart install instead of dart pub global activate/run in publish w…
mosuem Aug 19, 2026
85d1c38
Set FIREHOSE_REF on step-level env where job context is available
mosuem Aug 19, 2026
e516187
Fix YAML syntax for dart install commands using block scalars
mosuem Aug 19, 2026
b4772d8
Export Dart install bin directory to GITHUB_PATH after dart install
mosuem Aug 19, 2026
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
234 changes: 213 additions & 21 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,33 @@ on:
default: "v"
required: false
type: string
provenance:
description: >-
Whether to enable package provenance signing (experimental).
default: false
required: false
type: boolean
skip-validation:
description: >-
Whether to skip the pre-release validation step. Useful if you run
your own custom validation before publishing.
default: false
required: false
type: boolean
use-prebuilt-archive:
description: >-
Whether to use a pre-built package archive uploaded by the caller workflow
(named by `package-archive-name` or defaulting to 'package-archive').
When true, skips the internal `validate-release` and `package` jobs.
default: false
required: false
type: boolean
package-archive-name:
description: >-
The name of the uploaded artifact containing the package archive(s).
default: "package-archive"
required: false
type: string
local_debug:
description: Whether to use a local copy of package:firehose - only for debug
default: false
Expand Down Expand Up @@ -149,15 +176,23 @@ jobs:
env:
GIT_URL: ${{ github.event.pull_request.head.repo.clone_url || 'https://github.com/dart-lang/ecosystem' }}
GIT_REF: ${{ github.head_ref || github.ref_name }}
run: dart pub global activate --source git "$GIT_URL" --git-path pkgs/firehose/ --git-ref "$GIT_REF"
run: |
dart install "firehose@{git: {url: '$GIT_URL', path: pkgs/firehose, ref: '$GIT_REF'}}"
echo "$HOME/.local/state/Dart/install/bin" >> "$GITHUB_PATH"

- name: Install firehose (external)
if: ${{ !inputs.local_debug && github.repository != 'dart-lang/ecosystem' }}
run: dart pub global activate --source git https://github.com/dart-lang/ecosystem --git-path pkgs/firehose/
env:
FIREHOSE_REF: ${{ job.workflow_sha }}
run: |
dart install "firehose@{git: {url: https://github.com/dart-lang/ecosystem, path: pkgs/firehose, ref: '$FIREHOSE_REF'}}"
echo "$HOME/.local/state/Dart/install/bin" >> "$GITHUB_PATH"

- name: Install local firehose
run: dart pub global activate --source path pkgs/firehose/
if: ${{ inputs.local_debug }}
run: |
dart install "firehose@{path: $PWD/pkgs/firehose}"
echo "$HOME/.local/state/Dart/install/bin" >> "$GITHUB_PATH"

- name: Fetch labels
id: fetch-labels
Expand Down Expand Up @@ -186,7 +221,7 @@ jobs:
else
FLUTTER_FLAG="--no-use-flutter"
fi
dart pub global run firehose \
firehose \
--validate \
"$FLUTTER_FLAG" \
--ignore-packages "$INPUTS_IGNORE_PACKAGES" \
Expand All @@ -206,14 +241,14 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.number }}
run: dart pub global run firehose:comment create-or-update --issue "$ISSUE_NUMBER" --body-path output/comment.md
run: comment create-or-update --issue "$ISSUE_NUMBER" --body-path output/comment.md

- name: Update comment
if: ${{ (hashFiles('output/comment.md') != '') && inputs.write-comments && (steps.comment-id.outputs.comment != '') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMENT_ID: ${{ steps.comment-id.outputs.comment }}
run: dart pub global run firehose:comment create-or-update --comment-id "$COMMENT_ID" --body-path output/comment.md
run: comment create-or-update --comment-id "$COMMENT_ID" --body-path output/comment.md

- name: Save PR number
if: ${{ !inputs.write-comments }}
Expand All @@ -224,34 +259,154 @@ jobs:

- name: Upload folder with number and markdown
if: ${{ !inputs.write-comments }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
with:
name: output
path: output/

validate-release:
if: ${{ github.event_name == 'push' && inputs.provenance && !inputs.use-prebuilt-archive && !inputs.skip-validation && !contains(github.ref_name, 'skip-validation') }}
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
submodules: ${{ inputs.checkout_submodules }}

- uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2
if: ${{ inputs.use-flutter }}
with:
channel: ${{ inputs.sdk }}
cache: true

- uses: dart-lang/setup-dart@65eb853c7ba17dde3be364c3d2858773e7144260
if: ${{ !inputs.use-flutter }}
with:
sdk: ${{ inputs.sdk }}

- name: Install firehose (internal)
if: ${{ !inputs.local_debug && github.repository == 'dart-lang/ecosystem' }}
env:
GIT_URL: ${{ github.event.pull_request.head.repo.clone_url || 'https://github.com/dart-lang/ecosystem' }}
GIT_REF: ${{ github.head_ref || github.ref_name }}
run: |
dart install "firehose@{git: {url: '$GIT_URL', path: pkgs/firehose, ref: '$GIT_REF'}}"
echo "$HOME/.local/state/Dart/install/bin" >> "$GITHUB_PATH"

- name: Install firehose (external)
if: ${{ !inputs.local_debug && github.repository != 'dart-lang/ecosystem' }}
env:
FIREHOSE_REF: ${{ job.workflow_sha }}
run: |
dart install "firehose@{git: {url: https://github.com/dart-lang/ecosystem, path: pkgs/firehose, ref: '$FIREHOSE_REF'}}"
echo "$HOME/.local/state/Dart/install/bin" >> "$GITHUB_PATH"

- name: Install local firehose
if: ${{ inputs.local_debug }}
run: |
dart install "firehose@{path: $PWD/pkgs/firehose}"
echo "$HOME/.local/state/Dart/install/bin" >> "$GITHUB_PATH"

- name: Validate package for release
env:
INPUTS_TAG_PREFIX: ${{ inputs.tag-prefix }}
USE_FLUTTER: ${{ inputs.use-flutter }}
run: |
if [ "$USE_FLUTTER" = "true" ]; then
FLUTTER_FLAG="--use-flutter"
else
FLUTTER_FLAG="--no-use-flutter"
fi
firehose \
--validate-release \
"$FLUTTER_FLAG" \
--tag-prefix "$INPUTS_TAG_PREFIX"

package:
if: ${{ github.event_name == 'push' && inputs.provenance && !inputs.use-prebuilt-archive && !cancelled() && !failure() }}
needs: [validate-release]
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
submodules: ${{ inputs.checkout_submodules }}

- uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2
if: ${{ inputs.use-flutter }}
with:
channel: ${{ inputs.sdk }}
cache: true

- uses: dart-lang/setup-dart@65eb853c7ba17dde3be364c3d2858773e7144260
if: ${{ !inputs.use-flutter }}
with:
sdk: ${{ inputs.sdk }}

- name: Install firehose (internal)
if: ${{ !inputs.local_debug && github.repository == 'dart-lang/ecosystem' }}
env:
GIT_URL: ${{ github.event.pull_request.head.repo.clone_url || 'https://github.com/dart-lang/ecosystem' }}
GIT_REF: ${{ github.head_ref || github.ref_name }}
run: |
dart install "firehose@{git: {url: '$GIT_URL', path: pkgs/firehose, ref: '$GIT_REF'}}"
echo "$HOME/.local/state/Dart/install/bin" >> "$GITHUB_PATH"

- name: Install firehose (external)
if: ${{ !inputs.local_debug && github.repository != 'dart-lang/ecosystem' }}
env:
FIREHOSE_REF: ${{ job.workflow_sha }}
run: |
dart install "firehose@{git: {url: https://github.com/dart-lang/ecosystem, path: pkgs/firehose, ref: '$FIREHOSE_REF'}}"
echo "$HOME/.local/state/Dart/install/bin" >> "$GITHUB_PATH"

- name: Install local firehose
if: ${{ inputs.local_debug }}
run: |
dart install "firehose@{path: $PWD/pkgs/firehose}"
echo "$HOME/.local/state/Dart/install/bin" >> "$GITHUB_PATH"

- name: Package archive for provenance
env:
INPUTS_TAG_PREFIX: ${{ inputs.tag-prefix }}
USE_FLUTTER: ${{ inputs.use-flutter }}
run: |
if [ "$USE_FLUTTER" = "true" ]; then
FLUTTER_FLAG="--use-flutter"
else
FLUTTER_FLAG="--no-use-flutter"
fi
sudo -E unshare -n sudo -u $(whoami) -E env "PATH=$PATH" "HOME=$HOME" firehose \
--package-only \
"$FLUTTER_FLAG" \
--tag-prefix "$INPUTS_TAG_PREFIX"

- name: Upload package archive
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
with:
name: package-archive
path: output/

publish:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it common to split the building and generating the attestation into different jobs? I'd have expected that the attestation is generated by the build.

https://github.com/actions/attest#usage says to use attest in the same workflow (which you're doing) but doesn't say if you should or shouldn't split build and attestation into separate jobs. All the examples seem to have build and attestation in the same job.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read in the SLSA docs that the build step should not have access to the secrets from the attestation step. In our case the build is just zipping files, so maybe its fine?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I says "The build platform MUST guarantee the following", so I'd say it's GHA that needs to guarantee that. I don't know (and couldn't find anything in the GHA documentation) if the job boundary is a stronger security boundary than the step boundary.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two jobs does mean two different VMs, while two steps don't. Also the permissions are different for the jobs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, we could make reusable workflow that we know will only run pub publish without running any untrusted code or code from the author of the package.

Then said job could both create archive, attest and publish.

But if we want to run code from the package author, yes, two jobs is probably the best option.

The job doing the attention should be trusted so keys can't be exfiltrated.

if: ${{ github.event_name == 'push' }}
if: ${{ github.event_name == 'push' && !cancelled() && !failure() }}
needs: [package]

# Require the github deployment environment if supplied.
environment: ${{ inputs.environment }}

# This permission is required for authentication using OIDC.
# This permission is required for authentication using OIDC and for artifact attestations.
permissions:
id-token: write
attestations: write

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
submodules: ${{ inputs.checkout_submodules }}

- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-cache-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pub-cache-

- uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2
if: ${{ inputs.use-flutter }}
with:
Expand All @@ -268,27 +423,64 @@ jobs:
env:
GIT_URL: ${{ github.event.pull_request.head.repo.clone_url || 'https://github.com/dart-lang/ecosystem' }}
GIT_REF: ${{ github.head_ref || github.ref_name }}
run: dart pub global activate --source git "$GIT_URL" --git-path pkgs/firehose/ --git-ref "$GIT_REF"
run: |
dart install "firehose@{git: {url: '$GIT_URL', path: pkgs/firehose, ref: '$GIT_REF'}}"
echo "$HOME/.local/state/Dart/install/bin" >> "$GITHUB_PATH"

- name: Install firehose (external)
if: ${{ !inputs.local_debug && github.repository != 'dart-lang/ecosystem' }}
run: dart pub global activate --source git https://github.com/dart-lang/ecosystem --git-path pkgs/firehose/
env:
FIREHOSE_REF: ${{ job.workflow_sha }}
run: |
dart install "firehose@{git: {url: https://github.com/dart-lang/ecosystem, path: pkgs/firehose, ref: '$FIREHOSE_REF'}}"
echo "$HOME/.local/state/Dart/install/bin" >> "$GITHUB_PATH"

- name: Install local firehose
run: dart pub global activate --source path pkgs/firehose/
if: ${{ inputs.local_debug }}
run: |
dart install "firehose@{path: $PWD/pkgs/firehose}"
echo "$HOME/.local/state/Dart/install/bin" >> "$GITHUB_PATH"

- name: Download package archive
if: ${{ inputs.provenance || inputs.use-prebuilt-archive }}
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: ${{ inputs.package-archive-name }}
path: output/

- name: Generate Build Provenance
if: ${{ inputs.provenance || inputs.use-prebuilt-archive }}
id: attest
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
with:
subject-path: 'output/*.tar.gz'

- name: Upload attestation bundle
if: ${{ inputs.provenance || inputs.use-prebuilt-archive }}
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
with:
name: attestation-bundle
path: ${{ steps.attest.outputs.bundle-path }}

- name: Publish packages
env:
INPUTS_TAG_PREFIX: ${{ inputs.tag-prefix }}
USE_FLUTTER: ${{ inputs.use-flutter }}
PROVENANCE: ${{ inputs.provenance }}
USE_PREBUILT_ARCHIVE: ${{ inputs.use-prebuilt-archive }}
run: |
if [ "$USE_FLUTTER" = "true" ]; then
FLUTTER_FLAG="--use-flutter"
else
FLUTTER_FLAG="--no-use-flutter"
fi
dart pub global run firehose \
if [ "$PROVENANCE" = "true" ] || [ "$USE_PREBUILT_ARCHIVE" = "true" ]; then
PROVENANCE_FLAG="--provenance"
else
PROVENANCE_FLAG=""
fi
firehose \
--publish \
"$FLUTTER_FLAG" \
--tag-prefix "$INPUTS_TAG_PREFIX"
--tag-prefix "$INPUTS_TAG_PREFIX" \
$PROVENANCE_FLAG
2 changes: 2 additions & 0 deletions .github/workflows/publish_internal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ jobs:
permissions:
id-token: write
pull-requests: write
attestations: write
contents: read
1 change: 1 addition & 0 deletions pkgs/firehose/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 0.13.2-wip

- Add `--provenance` option to `firehose` and `provenance` input to `publish.yaml` to support package provenance signing.
- Add `--tag-prefix` option to `firehose` and `tag-prefix` input to `publish.yaml` to allow configuring the release tag prefix (defaults to `'v'`).
- Run `pub get` before `dart format` in `groundskeeper`.
- Add `groundskeeper` executable to format and fix packages.
Expand Down
Loading
Loading