Skip to content

Commit d9343f6

Browse files
authored
Build release zip from GHA (#8093)
1 parent 3cce657 commit d9343f6

File tree

8 files changed

+63
-36
lines changed

8 files changed

+63
-36
lines changed

.github/workflows/zip.yml

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,29 @@ on:
2121
default: 'https://github.com/firebase/SpecsStaging.git'
2222

2323
jobs:
24+
package-release:
25+
# Don't run on private repo.
26+
if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
27+
runs-on: macOS-latest
28+
steps:
29+
- uses: actions/checkout@v2
30+
- name: Xcode 12.2
31+
run: sudo xcode-select -s /Applications/Xcode_12.2.app/Contents/Developer
32+
- name: Setup Bundler
33+
run: ./scripts/setup_bundler.sh
34+
- name: ZipBuildingTest
35+
run: |
36+
mkdir -p release_zip_dir
37+
sh -x scripts/build_zip.sh release_zip_dir \
38+
"${{ github.event.inputs.custom_spec_repos || 'https://github.com/firebase/SpecsStaging.git' }}"
39+
- uses: actions/upload-artifact@v1
40+
with:
41+
name: Firebase-release-zip-zip
42+
# Zip the entire output directory since the builder adds subdirectories we don't know the
43+
# name of.
44+
path: release_zip_dir
45+
46+
2447
build:
2548
# Don't run on private repo unless it is a PR.
2649
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:
3457
cd ReleaseTooling
3558
swift build -v
3659
37-
package:
60+
package-head:
3861
# Don't run on private repo.
3962
if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
4063
needs: build
@@ -48,7 +71,9 @@ jobs:
4871
- name: ZipBuildingTest
4972
run: |
5073
mkdir -p zip_output_dir
51-
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' }}"
74+
sh -x scripts/build_zip.sh \
75+
zip_output_dir "${{ github.event.inputs.custom_spec_repos || 'https://github.com/firebase/SpecsStaging.git,https://github.com/firebase/SpecsDev.git' }}" \
76+
build-head
5277
- uses: actions/upload-artifact@v1
5378
with:
5479
name: Firebase-actions-dir
@@ -59,7 +84,7 @@ jobs:
5984
quickstart_framework_abtesting:
6085
# Don't run on private repo.
6186
if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
62-
needs: package
87+
needs: package-head
6388
env:
6489
plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
6590
signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -103,7 +128,7 @@ jobs:
103128
quickstart_framework_auth:
104129
# Don't run on private repo.
105130
if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
106-
needs: package
131+
needs: package-head
107132
env:
108133
plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
109134
signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -147,7 +172,7 @@ jobs:
147172
quickstart_framework_config:
148173
# Don't run on private repo.
149174
if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
150-
needs: package
175+
needs: package-head
151176
env:
152177
plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
153178
signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -188,7 +213,7 @@ jobs:
188213
quickstart_framework_crashlytics:
189214
# Don't run on private repo.
190215
if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
191-
needs: package
216+
needs: package-head
192217
env:
193218
plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
194219
signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -241,7 +266,7 @@ jobs:
241266
quickstart_framework_database:
242267
# Don't run on private repo.
243268
if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
244-
needs: package
269+
needs: package-head
245270
env:
246271
plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
247272
signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -286,7 +311,7 @@ jobs:
286311
quickstart_framework_dynamiclinks:
287312
# Don't run on private repo.
288313
if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
289-
needs: package
314+
needs: package-head
290315
env:
291316
plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
292317
signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -336,7 +361,7 @@ jobs:
336361
quickstart_framework_firestore:
337362
# Don't run on private repo.
338363
if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
339-
needs: package
364+
needs: package-head
340365
env:
341366
plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
342367
signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -379,7 +404,7 @@ jobs:
379404
quickstart_framework_inappmessaging:
380405
# Don't run on private repo.
381406
if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
382-
needs: package
407+
needs: package-head
383408
env:
384409
plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
385410
signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -425,7 +450,7 @@ jobs:
425450
quickstart_framework_messaging:
426451
# Don't run on private repo.
427452
if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
428-
needs: package
453+
needs: package-head
429454
env:
430455
plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
431456
signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
@@ -470,7 +495,7 @@ jobs:
470495
quickstart_framework_storage:
471496
# Don't run on private repo.
472497
if: (github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk') || github.event_name == 'workflow_dispatch'
473-
needs: package
498+
needs: package-head
474499
env:
475500
plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
476501
signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ DerivedData
6565

6666
# Swift Package Manager
6767
*/.build
68+
ReleaseTooling/.swiftpm
6869
ReleaseTooling/Packages
6970
ReleaseTooling/*.xcodeproj
7071
ReleaseTooling/Package.resolved

ReleaseTooling/.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import Foundation
2323
public let shared = Manifest(
2424
version: "8.0.0",
2525
pods: [
26-
Pod("FirebaseCoreDiagnostics"),
27-
Pod("FirebaseCore"),
28-
Pod("FirebaseInstallations"),
26+
Pod("FirebaseCoreDiagnostics", zip: true),
27+
Pod("FirebaseCore", zip: true),
28+
Pod("FirebaseInstallations", zip: true),
2929
Pod("GoogleAppMeasurement", isClosedSource: true, platforms: ["ios"]),
3030
Pod("FirebaseAnalytics", isClosedSource: true, platforms: ["ios"], zip: true),
3131
Pod("FirebaseAnalyticsSwift", isBeta: true, platforms: ["ios"]),

ReleaseTooling/Sources/ZipBuilder/CarthageUtils.swift

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,21 @@ extension CarthageUtils {
4242
static func packageCarthageRelease(templateDir: URL,
4343
artifacts: ZipBuilder.ReleaseArtifacts,
4444
options: CarthageBuildOptions) -> URL? {
45-
guard let zipLocation = artifacts.carthageDir else { return nil }
45+
guard let carthagePath = artifacts.carthageDir else { return nil }
4646

4747
do {
4848
print("Creating Carthage release...")
49-
let carthagePath =
50-
zipLocation.deletingLastPathComponent().appendingPathComponent("carthage_build")
51-
// Create a copy of the release directory since we'll be modifying it.
52-
let fileManager = FileManager.default
53-
fileManager.removeIfExists(at: carthagePath)
54-
try fileManager.copyItem(at: zipLocation, to: carthagePath)
55-
5649
// Package the Carthage distribution with the current directory structure.
57-
let carthageDir = zipLocation.deletingLastPathComponent().appendingPathComponent("carthage")
58-
fileManager.removeIfExists(at: carthageDir)
59-
let output = carthageDir.appendingPathComponents([artifacts.firebaseVersion, "latest"])
60-
try fileManager.createDirectory(at: output, withIntermediateDirectories: true)
50+
let carthageDir = carthagePath.deletingLastPathComponent().appendingPathComponent("carthage")
51+
let output = carthageDir.appendingPathComponents([artifacts.firebaseVersion])
52+
try FileManager.default.createDirectory(at: output, withIntermediateDirectories: true)
6153
generateCarthageRelease(fromPackagedDir: carthagePath,
6254
templateDir: templateDir,
6355
jsonDir: options.jsonDir,
6456
artifacts: artifacts,
6557
outputDir: output,
6658
versionCheckEnabled: options.isVersionCheckEnabled)
6759

68-
// Remove the duplicated Carthage build directory.
69-
fileManager.removeIfExists(at: carthagePath)
7060
print("Done creating Carthage release! Files written to \(output)")
7161

7262
// Save the directory for later copying.

ReleaseTooling/Sources/ZipBuilder/ZipBuilder.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,12 @@ struct ZipBuilder {
418418
let analyticsPods = analyticsFrameworks.map {
419419
$0.replacingOccurrences(of: ".framework", with: "")
420420
}
421+
// Skip Analytics and the pods bundled with it.
421422
let remainingPods = installedPods.filter {
422423
$0.key != "FirebaseAnalytics" &&
423424
$0.key != "FirebaseCore" &&
425+
$0.key != "FirebaseCoreDiagnostics" &&
426+
$0.key != "FirebaseInstallations" &&
424427
$0.key != "Firebase" &&
425428
podsToInstall.map { $0.name }.contains($0.key)
426429
}.sorted { $0.key < $1.key }

ReleaseTooling/Sources/ZipBuilder/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct ZipBuilderTool: ParsableCommand {
5656
/// Flag to enable or disable Carthage version checks. Skipping the check can speed up dev
5757
/// iterations.
5858
@Flag(default: true,
59-
// Allows `enableCarthageVersionCheck` and `disableCarthageVersionCheck`.
59+
// Allows `--enable-carthage-version-check` and `--disable-carthage-version-check`.
6060
inversion: FlagInversion.prefixedEnableDisable,
6161
help: ArgumentHelp("A flag for enabling or disabling versions checks for Carthage builds."))
6262
var carthageVersionCheck: Bool

scripts/build_zip.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,21 @@ EOF
2222
exit 1
2323
fi
2424

25+
# The release build won't generage Carthage distro if the curreent
26+
# PackageManifest version has already been released.
27+
carthage_version_check="--enable-carthage-version-check"
28+
29+
# If there is a third option set, add options to build from head instead of
30+
# staging and/or trunk.
31+
if [[ $# -gt 2 ]]; then
32+
build_head_option="--local-podspec-path"
33+
build_head_value="$REPO"
34+
carthage_version_check="--disable-carthage-version-check"
35+
fi
36+
2537
# The first and only argument to this script should be the name of the
2638
# output directory.
2739
OUTPUT_DIR="$REPO/$1"
28-
2940
CUSTOM_SPEC_REPOS="$2"
3041

3142
source_repo=()
@@ -34,6 +45,7 @@ read -a specrepo <<< "${CUSTOM_SPEC_REPOS}"
3445

3546
cd ReleaseTooling
3647
swift run zip-builder --keep-build-artifacts --update-pod-repo \
37-
--local-podspec-path "${REPO}" \
48+
${build_head_option} ${build_head_value} \
3849
--output-dir "${OUTPUT_DIR}" \
50+
"${carthage_version_check}" \
3951
--custom-spec-repos "${specrepo[@]}"

0 commit comments

Comments
 (0)