Browse Source

Build release zip from GHA (#8093)

Paul Beusterien 4 years ago
parent
commit
d9343f6c56

+ 37 - 12
.github/workflows/zip.yml

@@ -21,6 +21,29 @@ on:
         default: 'https://github.com/firebase/SpecsStaging.git'
 
 jobs:
+  package-release:
+    # Don't run on private repo.
+    if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
+    runs-on: macOS-latest
+    steps:
+    - uses: actions/checkout@v2
+    - name: Xcode 12.2
+      run: sudo xcode-select -s /Applications/Xcode_12.2.app/Contents/Developer
+    - name: Setup Bundler
+      run: ./scripts/setup_bundler.sh
+    - name: ZipBuildingTest
+      run: |
+         mkdir -p release_zip_dir
+         sh -x scripts/build_zip.sh release_zip_dir \
+           "${{ github.event.inputs.custom_spec_repos || 'https://github.com/firebase/SpecsStaging.git' }}"
+    - uses: actions/upload-artifact@v1
+      with:
+        name: Firebase-release-zip-zip
+        # Zip the entire output directory since the builder adds subdirectories we don't know the
+        # name of.
+        path: release_zip_dir
+
+
   build:
     # Don't run on private repo unless it is a PR.
     if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
@@ -34,7 +57,7 @@ jobs:
         cd ReleaseTooling
         swift build -v
 
-  package:
+  package-head:
     # Don't run on private repo.
     if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
     needs: build
@@ -48,7 +71,9 @@ jobs:
     - name: ZipBuildingTest
       run: |
          mkdir -p zip_output_dir
-         sh -x scripts/build_zip.sh zip_output_dir "${{ github.event.inputs.custom_spec_repos || 'https://github.com/firebase/SpecsStaging.git,https://github.com/firebase/SpecsDev.git' }}"
+         sh -x scripts/build_zip.sh \
+           zip_output_dir "${{ github.event.inputs.custom_spec_repos || 'https://github.com/firebase/SpecsStaging.git,https://github.com/firebase/SpecsDev.git' }}" \
+           build-head
     - uses: actions/upload-artifact@v1
       with:
         name: Firebase-actions-dir
@@ -59,7 +84,7 @@ jobs:
   quickstart_framework_abtesting:
     # Don't run on private repo.
     if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
-    needs: package
+    needs: package-head
     env:
       plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
       signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -103,7 +128,7 @@ jobs:
   quickstart_framework_auth:
     # Don't run on private repo.
     if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
-    needs: package
+    needs: package-head
     env:
       plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
       signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -147,7 +172,7 @@ jobs:
   quickstart_framework_config:
     # Don't run on private repo.
     if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
-    needs: package
+    needs: package-head
     env:
       plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
       signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -188,7 +213,7 @@ jobs:
   quickstart_framework_crashlytics:
     # Don't run on private repo.
     if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
-    needs: package
+    needs: package-head
     env:
       plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
       signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -241,7 +266,7 @@ jobs:
   quickstart_framework_database:
     # Don't run on private repo.
     if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
-    needs: package
+    needs: package-head
     env:
       plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
       signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -286,7 +311,7 @@ jobs:
   quickstart_framework_dynamiclinks:
     # Don't run on private repo.
     if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
-    needs: package
+    needs: package-head
     env:
       plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
       signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -336,7 +361,7 @@ jobs:
   quickstart_framework_firestore:
     # Don't run on private repo.
     if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
-    needs: package
+    needs: package-head
     env:
       plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
       signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -379,7 +404,7 @@ jobs:
   quickstart_framework_inappmessaging:
     # Don't run on private repo.
     if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
-    needs: package
+    needs: package-head
     env:
       plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
       signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -425,7 +450,7 @@ jobs:
   quickstart_framework_messaging:
     # Don't run on private repo.
     if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
-    needs: package
+    needs: package-head
     env:
       plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
       signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -470,7 +495,7 @@ jobs:
   quickstart_framework_storage:
     # Don't run on private repo.
     if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
-    needs: package
+    needs: package-head
     env:
       plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
       signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}

+ 1 - 0
.gitignore

@@ -65,6 +65,7 @@ DerivedData
 
 # Swift Package Manager
 */.build
+ReleaseTooling/.swiftpm
 ReleaseTooling/Packages
 ReleaseTooling/*.xcodeproj
 ReleaseTooling/Package.resolved

+ 0 - 4
ReleaseTooling/.gitignore

@@ -1,4 +0,0 @@
-.DS_Store
-/.build
-/Packages
-/*.xcodeproj

+ 3 - 3
ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift

@@ -23,9 +23,9 @@ import Foundation
 public let shared = Manifest(
   version: "8.0.0",
   pods: [
-    Pod("FirebaseCoreDiagnostics"),
-    Pod("FirebaseCore"),
-    Pod("FirebaseInstallations"),
+    Pod("FirebaseCoreDiagnostics", zip: true),
+    Pod("FirebaseCore", zip: true),
+    Pod("FirebaseInstallations", zip: true),
     Pod("GoogleAppMeasurement", isClosedSource: true, platforms: ["ios"]),
     Pod("FirebaseAnalytics", isClosedSource: true, platforms: ["ios"], zip: true),
     Pod("FirebaseAnalyticsSwift", isBeta: true, platforms: ["ios"]),

+ 4 - 14
ReleaseTooling/Sources/ZipBuilder/CarthageUtils.swift

@@ -42,22 +42,14 @@ extension CarthageUtils {
   static func packageCarthageRelease(templateDir: URL,
                                      artifacts: ZipBuilder.ReleaseArtifacts,
                                      options: CarthageBuildOptions) -> URL? {
-    guard let zipLocation = artifacts.carthageDir else { return nil }
+    guard let carthagePath = artifacts.carthageDir else { return nil }
 
     do {
       print("Creating Carthage release...")
-      let carthagePath =
-        zipLocation.deletingLastPathComponent().appendingPathComponent("carthage_build")
-      // Create a copy of the release directory since we'll be modifying it.
-      let fileManager = FileManager.default
-      fileManager.removeIfExists(at: carthagePath)
-      try fileManager.copyItem(at: zipLocation, to: carthagePath)
-
       // Package the Carthage distribution with the current directory structure.
-      let carthageDir = zipLocation.deletingLastPathComponent().appendingPathComponent("carthage")
-      fileManager.removeIfExists(at: carthageDir)
-      let output = carthageDir.appendingPathComponents([artifacts.firebaseVersion, "latest"])
-      try fileManager.createDirectory(at: output, withIntermediateDirectories: true)
+      let carthageDir = carthagePath.deletingLastPathComponent().appendingPathComponent("carthage")
+      let output = carthageDir.appendingPathComponents([artifacts.firebaseVersion])
+      try FileManager.default.createDirectory(at: output, withIntermediateDirectories: true)
       generateCarthageRelease(fromPackagedDir: carthagePath,
                               templateDir: templateDir,
                               jsonDir: options.jsonDir,
@@ -65,8 +57,6 @@ extension CarthageUtils {
                               outputDir: output,
                               versionCheckEnabled: options.isVersionCheckEnabled)
 
-      // Remove the duplicated Carthage build directory.
-      fileManager.removeIfExists(at: carthagePath)
       print("Done creating Carthage release! Files written to \(output)")
 
       // Save the directory for later copying.

+ 3 - 0
ReleaseTooling/Sources/ZipBuilder/ZipBuilder.swift

@@ -418,9 +418,12 @@ struct ZipBuilder {
     let analyticsPods = analyticsFrameworks.map {
       $0.replacingOccurrences(of: ".framework", with: "")
     }
+    // Skip Analytics and the pods bundled with it.
     let remainingPods = installedPods.filter {
       $0.key != "FirebaseAnalytics" &&
         $0.key != "FirebaseCore" &&
+        $0.key != "FirebaseCoreDiagnostics" &&
+        $0.key != "FirebaseInstallations" &&
         $0.key != "Firebase" &&
         podsToInstall.map { $0.name }.contains($0.key)
     }.sorted { $0.key < $1.key }

+ 1 - 1
ReleaseTooling/Sources/ZipBuilder/main.swift

@@ -56,7 +56,7 @@ struct ZipBuilderTool: ParsableCommand {
   /// Flag to enable or disable Carthage version checks. Skipping the check can speed up dev
   /// iterations.
   @Flag(default: true,
-        // Allows `enableCarthageVersionCheck` and `disableCarthageVersionCheck`.
+        // Allows `--enable-carthage-version-check` and `--disable-carthage-version-check`.
         inversion: FlagInversion.prefixedEnableDisable,
         help: ArgumentHelp("A flag for enabling or disabling versions checks for Carthage builds."))
   var carthageVersionCheck: Bool

+ 14 - 2
scripts/build_zip.sh

@@ -22,10 +22,21 @@ EOF
   exit 1
 fi
 
+# The release build won't generage Carthage distro if the curreent
+# PackageManifest version has already been released.
+carthage_version_check="--enable-carthage-version-check"
+
+# If there is a third option set, add options to build from head instead of
+# staging and/or trunk.
+if [[ $# -gt 2 ]]; then
+  build_head_option="--local-podspec-path"
+  build_head_value="$REPO"
+  carthage_version_check="--disable-carthage-version-check"
+fi
+
 # The first and only argument to this script should be the name of the
 # output directory.
 OUTPUT_DIR="$REPO/$1"
-
 CUSTOM_SPEC_REPOS="$2"
 
 source_repo=()
@@ -34,6 +45,7 @@ read -a specrepo <<< "${CUSTOM_SPEC_REPOS}"
 
 cd ReleaseTooling
 swift run zip-builder --keep-build-artifacts --update-pod-repo \
-    --local-podspec-path "${REPO}" \
+    ${build_head_option} ${build_head_value} \
     --output-dir "${OUTPUT_DIR}" \
+    "${carthage_version_check}" \
     --custom-spec-repos  "${specrepo[@]}"