feat: add iOS build workflow to GitHub Actions for streamlined release process
- Introduced a new job in the GitHub Actions workflow to build the iOS app, including steps for checking out the repository, setting up Flutter, installing dependencies, and generating Freezed classes. - Implemented versioning logic to derive the release tag and build number dynamically based on the event type (manual or tag push). - Added steps for setting up Xcode, installing CocoaPods, building the iOS app without signing, creating an IPA from the app bundle, and uploading artifacts. - Enhanced release updates with the ability to handle both tag pushes and manual rebuilds, ensuring a more efficient release process.
This commit is contained in:
116
.github/workflows/release.yml
vendored
116
.github/workflows/release.yml
vendored
@@ -136,6 +136,7 @@ jobs:
|
||||
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'
|
||||
@@ -148,3 +149,118 @@ jobs:
|
||||
removeArtifacts: ${{ inputs.remove_old_assets }}
|
||||
makeLatest: true
|
||||
omitBodyDuringUpdate: true
|
||||
|
||||
build-ios:
|
||||
name: Build iOS
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
#1 Checkout Repository
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
#2 Setup Flutter
|
||||
- name: Set Up Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable'
|
||||
|
||||
#3 Install Dependencies
|
||||
- name: Install Dependencies
|
||||
run: flutter pub get
|
||||
|
||||
- name: Generate Freezed Classes
|
||||
run: flutter pub run build_runner build --delete-conflicting-outputs
|
||||
|
||||
- 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
|
||||
uses: maxim-lobanov/setup-xcode@v1
|
||||
with:
|
||||
xcode-version: latest-stable
|
||||
|
||||
#5 Install CocoaPods
|
||||
- name: Install CocoaPods
|
||||
run: |
|
||||
cd ios
|
||||
pod install
|
||||
|
||||
#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"
|
||||
|
||||
#7 Create IPA from App Bundle
|
||||
- name: Create IPA
|
||||
run: |
|
||||
mkdir -p build/ios/ipa
|
||||
cd build/ios/Release-iphoneos
|
||||
mkdir Payload
|
||||
cp -r Runner.app Payload/
|
||||
zip -r ../ipa/conduit-${{ env.VERSION_NAME }}.ipa Payload
|
||||
cd ../ipa
|
||||
shasum -a 256 conduit-${{ env.VERSION_NAME }}.ipa > conduit-${{ env.VERSION_NAME }}.ipa.sha256
|
||||
|
||||
#8 Upload Artifacts
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
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'
|
||||
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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user