could not load the saved OAuth2 credentials
Description Action fails to run because it can't load the credentials:
Warning: could not load the saved OAuth2 credentials.
Obtaining new credentials...
Pub needs your authorization to upload packages on your behalf.
I'm running this workflow:
jobs:
build:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_pub_publish.yml@v1
with:
pub_credentials: secrets.PUB_CREDENTIALS
in PUB_CREDENTIALS y copy & pasted the contents of pub-credentials.json
https://workflows.vgv.dev/docs/workflows/flutter_pub_publish#example-usage
+1
Also using ${{ secrets.PUB_CREDENTIALS }} doesn't work.
Pinging you here @wolfenrain
My guess is you should be using secrets over inputs for the secret.
It needs base64 support on credentials to make it work:
name: Publish to pub.dev
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
publish:
defaults:
run:
working-directory: "."
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
flutter-version: [3.10.x]
flutter-channel: [stable]
steps:
- name: 📚 Git Checkout
uses: actions/checkout@v4
- name: 🐦 Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ matrix.flutter-version }}
channel: ${{ matrix.flutter-channel }}
cache: true
- name: 📦 Install Dependencies
run: flutter pub get
- name: 🔐 Setup Pub Credentials
run: |
mkdir -p $XDG_CONFIG_HOME/dart
echo '${{secrets.PUB_CREDENTIALS}}' | base64 --decode > "$XDG_CONFIG_HOME/dart/pub-credentials.json"
- name: 🌵 Dry Run
run: flutter pub publish --dry-run
- name: 📢 Publish
run: flutter pub publish -f
Thanks @KeidsID for the info here. Seems like this is something we can add into the documentation to make sure others don't fall into this.
Adding the Documentation tag here as that seems like the right change here.
I don't think that is the right way to tackle this. You need to properly use secrets over inputs, that will fix all the issues. No workarounds needed.