chore: simplify fastlane config and release workflows

This commit is contained in:
cogwheel0
2025-10-24 13:37:24 +05:30
parent 1fe4a2db26
commit cb6a01a09e
6 changed files with 69 additions and 172 deletions

View File

@@ -4,17 +4,10 @@ on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Existing release tag to update (e.g. v1.2.3)'
required: true
type: string
remove_old_assets:
description: 'Remove existing assets before uploading new ones'
required: false
default: true
type: boolean
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
jobs:
build-android:
@@ -24,59 +17,33 @@ jobs:
steps:
#1 Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
#2 Setup Java
- name: Set Up Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
distribution: 'temurin'
java-version: '21'
- name: Setup Gradle and caching
uses: gradle/actions/setup-gradle@v3
#3 Setup Flutter
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
#4 Install Dependencies
- name: Install Dependencies
run: flutter pub get
run: flutter pub get --enforce-lockfile
- name: Generate Freezed Classes
run: flutter pub run build_runner build --delete-conflicting-outputs
- name: Generate code (build_runner)
run: dart run build_runner build --delete-conflicting-outputs -q
- name: Determine Release Tag and Version
id: meta
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
RELEASE_TAG="${{ inputs.tag }}"
else
RELEASE_TAG="${{ github.ref_name }}"
fi
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
# Derive VERSION_NAME (strip leading v)
VERSION_NAME="${RELEASE_TAG#v}"
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
# Extract current build number from pubspec.yaml if present, otherwise 1
CURRENT_VERSION_LINE=$(grep "^version:" pubspec.yaml || true)
CURRENT_BUILD=$(echo "$CURRENT_VERSION_LINE" | awk -F'+' '{print $2}')
if [[ -z "$CURRENT_BUILD" ]]; then CURRENT_BUILD=1; fi
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
# Rebuild mode: compute a unique, monotonic build number without committing
# Use CI run number offset to avoid conflicts across multiple rebuilds
BASE_BUILD=$CURRENT_BUILD
RUN_NUM=${GITHUB_RUN_NUMBER:-1}
BUILD_NUMBER=$((BASE_BUILD + RUN_NUM))
else
# Tag build: honor the build number committed in pubspec, default to CURRENT_BUILD
BUILD_NUMBER="$CURRENT_BUILD"
fi
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV
echo "Using tag=$RELEASE_TAG version=$VERSION_NAME build=$BUILD_NUMBER"
#5 Setup Keystore
- name: Create Keystore
@@ -89,10 +56,10 @@ jobs:
working-directory: android
- name: Build APK
run: flutter build apk --split-per-abi --release --build-name "$VERSION_NAME" --build-number "$BUILD_NUMBER"
run: flutter build apk --split-per-abi --release
- name: Build appBundle
run: flutter build appbundle --release --build-name "$VERSION_NAME" --build-number "$BUILD_NUMBER"
run: flutter build appbundle --release
- name: Upload Artifacts
uses: actions/upload-artifact@v4
@@ -104,50 +71,16 @@ jobs:
build/app/outputs/flutter-apk/app-x86_64-release.apk
build/app/outputs/bundle/release/app-release.aab
- name: Generate Release Notes
id: release_notes
run: |
# Get the previous tag
PREVIOUS_TAG=$(git tag --sort=-version:refname | head -2 | tail -1)
# If no previous tag exists, use the first commit
if [ -z "$PREVIOUS_TAG" ]; then
PREVIOUS_TAG=$(git rev-list --max-parents=0 HEAD)
fi
# Generate commit messages since the previous tag
echo "" >> release_notes.md
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..${{ github.ref_name }} >> release_notes.md
# Set the release notes as output
echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
cat release_notes.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
if: github.event_name == 'push'
- name: Create or Update Release (tag push)
if: github.event_name == 'push'
- name: Create or Update Release
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/flutter-apk/app-arm64-v8a-release.apk,build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk,build/app/outputs/flutter-apk/app-x86_64-release.apk,build/app/outputs/bundle/release/app-release.aab"
tag: ${{ env.RELEASE_TAG }}
tag: ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{ steps.release_notes.outputs.RELEASE_NOTES }}
generateReleaseNotes: true
allowUpdates: true
makeLatest: true
- name: Update Existing Release (manual rebuild)
if: github.event_name == 'workflow_dispatch'
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/flutter-apk/app-arm64-v8a-release.apk,build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk,build/app/outputs/flutter-apk/app-x86_64-release.apk,build/app/outputs/bundle/release/app-release.aab"
tag: ${{ env.RELEASE_TAG }}
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
removeArtifacts: ${{ inputs.remove_old_assets }}
makeLatest: true
omitBodyDuringUpdate: true
build-ios:
name: Build iOS
@@ -156,52 +89,23 @@ jobs:
steps:
#1 Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
#2 Setup Flutter
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
#3 Install Dependencies
- name: Install Dependencies
run: flutter pub get
run: flutter pub get --enforce-lockfile
- name: Generate Freezed Classes
run: flutter pub run build_runner build --delete-conflicting-outputs
- name: Generate code (build_runner)
run: dart run build_runner build --delete-conflicting-outputs -q
- name: Determine Release Tag and Version
id: meta
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
RELEASE_TAG="${{ inputs.tag }}"
else
RELEASE_TAG="${{ github.ref_name }}"
fi
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
# Derive VERSION_NAME (strip leading v)
VERSION_NAME="${RELEASE_TAG#v}"
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
# Extract current build number from pubspec.yaml if present, otherwise 1
CURRENT_VERSION_LINE=$(grep "^version:" pubspec.yaml || true)
CURRENT_BUILD=$(echo "$CURRENT_VERSION_LINE" | awk -F'+' '{print $2}')
if [[ -z "$CURRENT_BUILD" ]]; then CURRENT_BUILD=1; fi
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
# Rebuild mode: compute a unique, monotonic build number without committing
# Use CI run number offset to avoid conflicts across multiple rebuilds
BASE_BUILD=$CURRENT_BUILD
RUN_NUM=${GITHUB_RUN_NUMBER:-1}
BUILD_NUMBER=$((BASE_BUILD + RUN_NUM))
else
# Tag build: honor the build number committed in pubspec, default to CURRENT_BUILD
BUILD_NUMBER="$CURRENT_BUILD"
fi
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV
echo "Using tag=$RELEASE_TAG version=$VERSION_NAME build=$BUILD_NUMBER"
#4 Setup Xcode
- name: Setup Xcode
@@ -209,16 +113,34 @@ jobs:
with:
xcode-version: latest-stable
#5 Install CocoaPods
#5 Cache CocoaPods
- name: Cache CocoaPods
uses: actions/cache@v4
with:
path: |
ios/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Install CocoaPods
run: |
cd ios
pod install
pod install --verbose
#6 Cache Xcode DerivedData
- name: Cache Xcode DerivedData
uses: actions/cache@v4
with:
path: |
~/Library/Developer/Xcode/DerivedData
key: ${{ runner.os }}-xcode-${{ hashFiles('ios/Podfile.lock', 'ios/Runner.xcodeproj/project.pbxproj', 'pubspec.lock') }}
restore-keys: |
${{ runner.os }}-xcode-
#6 Build iOS App (without signing)
- name: Build iOS App
run: |
flutter build ios --release --no-codesign --build-name "$VERSION_NAME" --build-number "$BUILD_NUMBER"
flutter build ios --release --no-codesign
#7 Create IPA from App Bundle
- name: Create IPA
@@ -227,9 +149,8 @@ jobs:
cd build/ios/Release-iphoneos
mkdir Payload
cp -r Runner.app Payload/
zip -r ../ipa/conduit-${{ env.VERSION_NAME }}.ipa Payload
zip -r ../ipa/conduit.ipa Payload
cd ../ipa
shasum -a 256 conduit-${{ env.VERSION_NAME }}.ipa > conduit-${{ env.VERSION_NAME }}.ipa.sha256
#8 Upload Artifacts
- name: Upload Artifacts
@@ -238,28 +159,13 @@ jobs:
name: iOS-Release
path: |
build/ios/ipa/*.ipa
build/ios/ipa/*.sha256
#9 Update Release (tag push)
- name: Update Release with IPA (tag push)
if: github.event_name == 'push'
#9 Update Release
- name: Update Release with IPA
uses: ncipollo/release-action@v1
with:
artifacts: "build/ios/ipa/*.ipa,build/ios/ipa/*.sha256"
tag: ${{ env.RELEASE_TAG }}
artifacts: "build/ios/ipa/*.ipa"
tag: ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
makeLatest: true
#10 Update Release (manual rebuild)
- name: Update Release with IPA (manual rebuild)
if: github.event_name == 'workflow_dispatch'
uses: ncipollo/release-action@v1
with:
artifacts: "build/ios/ipa/*.ipa,build/ios/ipa/*.sha256"
tag: ${{ env.RELEASE_TAG }}
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
removeArtifacts: ${{ inputs.remove_old_assets }}
makeLatest: true
omitBodyDuringUpdate: true