*solution *
Always prefer GITHUB_TOKEN with permissions: contents: write for GitHub release actions unless you have a specific need for a custom token.
- name: Create Release (GitHub CLI)
id: create_release_cli
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Attempting release creation with GitHub CLI"
gh release create v1.0.${{ github.run_number }} ./build/app/outputs/apk/release/*.apk \
--title "Release v1.0.${{ github.run_number }}" \
--notes "Release created by GitHub Actions"
continue-on-error: true
You use the GitHub CLI (gh release create) with:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Full code
name: "Build & Release Debug"
on:
push:
branches: [main, master, develop]
permissions:
contents: write
jobs:
build:
name: Build & Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Debug step to check token existence
- name: Debug - Check Token Existence
run: |
echo "Token exists: ${{ secrets.rakesh != '' }}"
echo "Runner OS: ${{ runner.os }}"
echo "GitHub Reference: ${{ github.ref }}"
echo "Run Number: ${{ github.run_number }}"
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
architecture: x64
- run: flutter pub get
- run: flutter build apk --release --split-per-abi
# Debug step to verify APK files exist
- name: Debug - Check APK Files
run: |
echo "Listing APK files:"
find build/app/outputs/apk/release -type f -name "*.apk" | sort
echo "File count: $(find build/app/outputs/apk/release -type f -name "*.apk" | wc -l)"
echo "Directory structure:"
ls -la build/app/outputs/apk/release/
# Try a GitHub-based approach first with detailed GitHub token
- name: Create Release (GitHub CLI)
id: create_release_cli
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Attempting release creation with GitHub CLI"
gh release create v1.0.${{ github.run_number }} ./build/app/outputs/apk/release/*.apk \
--title "Release v1.0.${{ github.run_number }}" \
--notes "Release created by GitHub Actions"
continue-on-error: true
# Only run ncipollo action if GitHub CLI approach fails
- name: Push to Releases (Original)
if: steps.create_release_cli.outcome != 'success'
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/apk/release/*"
tag: v1.0.${{ github.run_number }}
token: ${{ secrets.rakesh }}
name: "Release v1.0.${{ github.run_number }} (ncipollo)"
draft: false
prerelease: false
allowUpdates: true
replacesArtifacts: true
# Debug step to report final status
- name: Debug - Workflow Summary
run: |
echo "GitHub CLI release status: ${{ steps.create_release_cli.outcome }}"
echo "Workflow completed at: $(date)"
echo "Check the Releases page at: https://github.com/${{ github.repository }}/releases"
Top comments (0)