Manual Publish to pub.dev #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Manual Publish to pub.dev | |
on: | |
workflow_dispatch: # ✅ Allows manual trigger from GitHub UI | |
jobs: | |
publish: | |
name: Publish to pub.dev | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write # ✅ Required for authentication using OIDC | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Setup Dart & Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: "3.29.0" # Replace with the latest available version | |
channel: "stable" # Specify a stable Flutter version | |
- name: Install Dependencies | |
run: flutter pub get | |
- name: Authenticate & Publish | |
env: | |
PUB_CREDENTIALS: ${{ secrets.PUB_CREDENTIALS }} # 🔑 Uses stored credentials | |
run: | | |
mkdir -p ~/.config/dart | |
echo "$PUB_CREDENTIALS" > ~/.config/dart/pub-credentials.json | |
flutter pub publish --force # ✅ Publishes the package | |
rm ~/.config/dart/pub-credentials.json # 🧹 Clean up | |
- name: Success Message | |
if: success() | |
run: echo "✅ Package published successfully!" | |
- name: Failure Message | |
if: failure() | |
run: echo "❌ Publishing failed. Check logs for details." |