Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ jobs:
run: nix develop .#dart -c ./payjoin-ffi/dart/contrib/prepare-publish.sh

- name: Publish to pub.dev
run: nix develop .#dart -c bash -c 'cd payjoin-ffi/dart && dart pub publish --force'
run: nix develop .#dart -c ./payjoin-ffi/dart/contrib/publish.sh
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@
rustVersions.msrv
dart
bzip2
curl
jq
]
++ lib.optionals pkgs.stdenv.isLinux [
pkg-config
Expand Down
28 changes: 28 additions & 0 deletions payjoin-ffi/dart/contrib/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail

# Publish the package to pub.dev via automated publishing (OIDC).
# `dart pub publish` has no non-interactive authentication mode: without a
# registered token it falls back to the browser sign-in flow and hangs the
# job, so the runner-injected ACTIONS_ID_TOKEN_REQUEST_* variables (present
# only in jobs granted `id-token: write`) are exchanged here for a
# short-lived token that pub.dev verifies against the repository, tag
# pattern, and environment configured on the package's admin page. This is
# the same exchange the dart-lang/setup-dart action performs; we install
# Dart through nix, so it has to happen here instead. Run
# prepare-publish.sh first to generate the bindings that get packed.

: "${ACTIONS_ID_TOKEN_REQUEST_URL:?must run in a GitHub Actions job with id-token: write}"
: "${ACTIONS_ID_TOKEN_REQUEST_TOKEN:?must run in a GitHub Actions job with id-token: write}"

PUB_TOKEN="$(
curl --silent --show-error --fail --location \
--header "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=https://pub.dev" |
jq --raw-output .value
)"
export PUB_TOKEN
dart pub token add https://pub.dev --env-var PUB_TOKEN

cd "$(dirname "$0")/.."
dart pub publish --force
Loading