File tree 4 files changed +59
-0
lines changed
4 files changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : publish
2
+
3
+ on :
4
+ push :
5
+
6
+ jobs :
7
+ # https://dart.dev/tools/pub/automated-publishing
8
+ publish :
9
+ runs-on : ubuntu-latest
10
+ permissions :
11
+ id-token : write
12
+ contents : read
13
+ steps :
14
+ - uses : actions/checkout@v4
15
+ - uses : flutter-actions/setup-flutter@v3
16
+ - uses : ./
Original file line number Diff line number Diff line change
1
+ # About
2
+ GitHub Action to configuring credentials for automated publishing of packages to pub.dev
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ if [[ -z " ${ACTIONS_ID_TOKEN_REQUEST_URL} " ]] && [[ -z " ${ACTIONS_ID_TOKEN_REQUEST_TOKEN} " ]]; then
4
+ echo " ==> No GitHub OIDC token found, skipping..."
5
+ exit 0
6
+ fi
7
+
8
+ log_group_start () {
9
+ echo " ::group::${1} "
10
+ }
11
+ log_group_end () {
12
+ echo " ::endgroup::"
13
+ }
14
+
15
+ jwtd () {
16
+ log_group_start " Decoding JWT data..."
17
+ jq -R ' split(".") | .[0],.[1] | @base64d | fromjson' <<< " ${1}"
18
+ echo " Signature: $( echo " ${1} " | awk -F' .' ' {print $3}' ) "
19
+ log_group_end
20
+ }
21
+
22
+ INPUT_GITHUB_OIDC_AUDIENCE=" https://pub.dev"
23
+
24
+ echo " Create the OIDC token used for pub.dev publishing..."
25
+ GITHUB_OIDC_RESPONSE=$( curl -s -H " Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN " " $ACTIONS_ID_TOKEN_REQUEST_URL &audience=${INPUT_GITHUB_OIDC_AUDIENCE} " )
26
+ GITHUB_OIDC_IDTOKEN=$( jq -r ' .value' <<< " ${GITHUB_OIDC_RESPONSE}" )
27
+ export PUB_TOKEN=${GITHUB_OIDC_IDTOKEN}
28
+ echo " PUB_TOKEN=${GITHUB_OIDC_IDTOKEN} " >> $GITHUB_ENV
29
+
30
+ jwtd " $GITHUB_OIDC_IDTOKEN "
31
+
32
+ echo " The Dart CLI successfully authenticated with the GitHub OIDC token,"
33
+ dart pub token add ${INPUT_GITHUB_OIDC_AUDIENCE} --env-var PUB_TOKEN
Original file line number Diff line number Diff line change
1
+ name : " Setup Pub.dev credentials"
2
+ description : " Configuring credentials for automated publishing of packages to pub.dev"
3
+ runs :
4
+ using : " composite"
5
+ steps :
6
+ - name : Setup Pub.dev credentials
7
+ run : $GITHUB_ACTION_PATH/action.sh
8
+ shell : bash
You can’t perform that action at this time.
0 commit comments